[slime-devel] New argument to ED-IN-EMACS.

Lawrence Mitchell wence at gmx.li
Mon Mar 29 22:03:48 UTC 2004


While ANSI says that ED should only accept one optional
argument, it'd be nice if SLIME's ED-IN-EMACS could deal with
another, optional, position argument, making it more useful as a
general editing tool, as opposed to being quite lisp specific.
What are people's thoughts on something like this:

Index: ChangeLog
===================================================================
RCS file: /project/slime/cvsroot/slime/ChangeLog,v
retrieving revision 1.316
diff -u -r1.316 ChangeLog
--- ChangeLog	29 Mar 2004 17:08:17 -0000	1.316
+++ ChangeLog	29 Mar 2004 22:02:19 -0000
@@ -1,3 +1,11 @@
+2004-03-29  Lawrence Mitchell  <wence at gmx.li>
+
+	* swank.lisp (ed-in-emacs): New optional argument, WHERE.
+	Describes a LINE:COLUMN location in the file we're visiting.
+
+	* slime.el (slime-ed): Deal with new WHERE argument.  In the case
+	of a filename, visit the correct line and column number.
+
 2004-03-29  Helmut Eller  <e9626484 at stud3.tuwien.ac.at>
 
 	* swank-source-path-parser.lisp (cmucl-style-get-macro-character):

Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.155
diff -u -r1.155 swank.lisp
--- swank.lisp	27 Mar 2004 21:14:52 -0000	1.155
+++ swank.lisp	29 Mar 2004 21:56:36 -0000
@@ -1133,12 +1133,16 @@
            (let ((*package* *buffer-package*))
              (format nil "~{~S~^~%~}" values))))))
 
-(defslimefun ed-in-emacs (&optional what)
+(defslimefun ed-in-emacs (&optional what where)
   "Edit WHAT in Emacs.
-WHAT can be a filename (pathname or string) or function name (symbol)."
+WHAT can be a filename (pathname or string) or function name (symbol).
+
+If WHERE is non-nil, it should be a string of the form
+\"LINE[:COLUMN]\" telling us where in the file we should jump to."
   (send-oob-to-emacs `(:ed ,(if (pathnamep what)
                                 (canonicalize-filename what)
-                                what))))
+                                what)
+                           ,where)))
 
 ;;;; Compilation Commands.
 
Index: slime.el
===================================================================
RCS file: /project/slime/cvsroot/slime/slime.el,v
retrieving revision 1.248
diff -u -r1.248 slime.el
--- slime.el	29 Mar 2004 00:59:13 -0000	1.248
+++ slime.el	29 Mar 2004 21:59:26 -0000
@@ -1511,8 +1511,8 @@
        (setf (slime-use-sigint-for-interrupt) t))
       ((:%apply fn args)
        (apply (intern fn) args))
-      ((:ed what)
-       (slime-ed what))
+      ((:ed what where)
+       (slime-ed what where))
       ((:debug-condition thread message)
        (apply 'ignore thread) ; stupid XEmacs warns about unused variable
        (message "%s" message)))))
@@ -3637,7 +3637,7 @@
 (defvar slime-ed-use-dedicated-frame t
   "*When non-nil, `slime-ed' will create and reuse a dedicated frame.")
 
-(defun slime-ed (what)
+(defun slime-ed (what where)
   "Edit WHAT, either a filename (string) or function name (symbol), or nil.
 This for use in the implementation of COMMON-LISP:ED."
   ;; Without `save-excursion' very strange things happen if you call
@@ -3648,7 +3648,19 @@
         (setq slime-ed-frame (new-frame)))
       (select-frame slime-ed-frame))
     (cond ((stringp what)
-           (find-file (slime-from-lisp-filename what)))
+           (find-file (slime-from-lisp-filename what))
+           (when (string-match "\\([0-9]+\\):?\\([0-9]+\\)?" where)
+             ;; Go to the correct line.
+             (goto-line (string-to-number (match-string 1 where)))
+             ;; Check to see if we've specified a column, and if so,
+             ;; try and reach it, but don't go off the end of the
+             ;; current line.
+             (let ((col (match-string 2 where)))
+               (and col (setq col (string-to-number col)))
+               (while (and col
+                           (< (point) (point-at-eol))
+                           (/= (decf col) -1))
+                 (forward-char 1)))))
           ((and what (symbolp what))
            (slime-edit-definition (symbol-name what)))
           (t nil))))                    ; nothing in particular

-- 
Lawrence Mitchell <wence at gmx.li>





More information about the slime-devel mailing list