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

Lawrence Mitchell wence at gmx.li
Mon Mar 29 22:35:38 UTC 2004


Here's a different version, which uses just the one argument,
but allows it to be a list (FILENAME LINE [COLUMN]).  Though it
was pointed out that this disallows the editing of (setf foo) as
a function (probably, unless you do more special-casing on the
CAR of the list being a string/symbol/whatever)

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:34:26 -0000
@@ -1,3 +1,11 @@
+2004-03-29  Lawrence Mitchell  <wence at gmx.li>
+
+	* swank.lisp (ed-in-emacs): New allowed form for argument.
+
+	* slime.el (slime-ed): Deal with list form of argument.  For a
+	list (FILENAME LINE [COLUMN]), 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: 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 22:30:47 -0000
@@ -3638,7 +3638,14 @@
   "*When non-nil, `slime-ed' will create and reuse a dedicated frame.")
 
 (defun slime-ed (what)
-  "Edit WHAT, either a filename (string) or function name (symbol), or nil.
+  "Edit WHAT.
+
+WHAT can be:
+  A filename (string),
+  A list (FILENAME LINE [COLUMN]),
+  A function name (symbol),
+  nil.
+
 This for use in the implementation of COMMON-LISP:ED."
   ;; Without `save-excursion' very strange things happen if you call
   ;; (swank:ed-in-emacs X) from the REPL. -luke (18/Jan/2004)
@@ -3649,6 +3656,16 @@
       (select-frame slime-ed-frame))
     (cond ((stringp what)
            (find-file (slime-from-lisp-filename what)))
+          ((listp what) 
+           (find-file (first what))
+           (goto-line (second what))
+           ;; Find the correct column, without going past the end of
+           ;; the line.
+           (let ((col (third what)))
+             (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


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 22:33:05 -0000
@@ -1135,7 +1135,14 @@
 
 (defslimefun ed-in-emacs (&optional what)
   "Edit WHAT in Emacs.
-WHAT can be a filename (pathname or string) or function name (symbol)."
+
+WHAT can be:
+  A filename (string),
+  A list (FILENAME LINE [COLUMN]),
+  A function name (symbol),
+  nil."
+  (if (and (listp what) (pathnamep (first what)))
+      (setf (car what) (canonicalize-filename (car what))))
   (send-oob-to-emacs `(:ed ,(if (pathnamep what)
                                 (canonicalize-filename what)
                                 what))))

[...]


-- 
Lawrence Mitchell <wence at gmx.li>





More information about the slime-devel mailing list