[Openmcl-devel] Printing the package along with the Lisp prompt

Ron Garret ron at flownet.com
Tue Jan 6 14:48:05 PST 2015

In the IDE, the current package is shown in the mini-buffer, but when you’re using CCL at the command line there is no indication of which package you’re in.  I just spent an hour trying to figure out how to fix that and finally came up with the following solution:

#+(and ccl (not hemlock)) (progn

(defun shortest-package-name (package)
  (let* ((name (package-name package))
         (len (length name)))
    (dolist (nick (package-nicknames package) name)
      (let* ((nicklen (length nick)))
        (if (< nicklen len)
          (setq name nick len nicklen))))))

(defun print-current-package-name (stream object &optional colon-p at-sign-p)
  (declare (ignore object colon-p at-sign-p))
  (format stream "~A" (shortest-package-name *package*)))

(setf ccl::*LISTENER-PROMPT-FORMAT* "~/print-current-package-name/~:* ~[>~:;~:*~d >~] ")


I’m posting it here just in case anyone else wants this feature and doesn’t feel like taking the time to figure out how to make it work.


More information about the Openmcl-devel mailing list