[slime-devel] Canonical package nicknames patch
Peter Seibel
peter at javamonkey.com
Fri Jul 9 16:20:57 UTC 2004
So it mildly annoys me that SLIME does this:
CL-USER> (in-package :foo)
#<The FOO package>
FOO> (in-package :cl-user)
#<The COMMON-LISP-USER package>
USER>
Note the final prompt. I seem to recall some discussion of this. I
have a tiny patch to swank.lisp that causes shortest-package-nickname
to check a *canonical-packge-names* alist first to see if there's a
known prefered name for a given package. Currently
*canonical-packge-names* contains only ("COMMON-LISP-USER" .
"CL-USER"). I can check this in if folks think it's a good idea (or at
least not a bad one.) If you want I can also change the function name
from shortest-package-nickname to canonical-package-nickname which
would be more descriptive of the new behavior.
-Peter
Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.210
diff -u -r1.210 swank.lisp
--- swank.lisp 7 Jul 2004 15:09:33 -0000 1.210
+++ swank.lisp 9 Jul 2004 16:15:25 -0000
@@ -54,6 +54,9 @@
(defconstant keyword-package (find-package :keyword)
"The KEYWORD package.")
+(defvar *canonical-packge-names*
+ '(("COMMON-LISP-USER" . "CL-USER")))
+
(defvar *swank-io-package*
(let ((package (make-package :swank-io-package :use '())))
(import '(nil t quote) package)
@@ -1313,11 +1316,12 @@
(defun shortest-package-nickname (package)
"Return the shortest nickname (or canonical name) of PACKAGE."
- (loop for name in (cons (package-name package) (package-nicknames package))
- for shortest = name then (if (< (length name) (length shortest))
- name
- shortest)
- finally (return shortest)))
+ (or (cdr (assoc (package-name package) *canonical-packge-names* :test #'string=))
+ (loop for name in (cons (package-name package) (package-nicknames package))
+ for shortest = name then (if (< (length name) (length shortest))
+ name
+ shortest)
+ finally (return shortest))))
(defslimefun interactive-eval-region (string)
(with-buffer-syntax ()
--
Peter Seibel peter at javamonkey.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
More information about the slime-devel
mailing list