Created
November 25, 2008 09:34
-
-
Save mkhl/28863 to your computer and use it in GitHub Desktop.
Dump symbols to a file to support tab-completion in sn SBCL REPL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(with-open-file (!!!-stream (merge-pathnames ".sbcl_completions" (user-homedir-pathname)) | |
:direction :output | |
:if-exists :supersede) | |
(let ((!!!-seen (make-hash-table :size 6000 :test #'equal)) | |
(!!!-cl-package (find-package "CL")) | |
(!!!-cl-user-package (find-package "CL-USER"))) | |
(loop for !!!-package in (list-all-packages) | |
do (let ((!!!-prefixes | |
(if (or (eq !!!-package !!!-cl-package) | |
(eq !!!-package !!!-cl-user-package)) | |
(list "") | |
(mapcar #'(lambda (!!!-prefix) | |
(concatenate 'string | |
(string-downcase !!!-prefix) | |
":")) | |
(if (package-nicknames !!!-package) | |
(package-nicknames !!!-package) | |
(list (package-name !!!-package))))))) | |
(loop for !!!-symbol being the symbols of !!!-package | |
for !!!-symbol-name = (symbol-name !!!-symbol) | |
when (or (eq (nth-value 1 | |
(find-symbol !!!-symbol-name | |
!!!-package)) | |
:external) | |
(eq !!!-package !!!-cl-user-package)) | |
do (loop for !!!-prefix in !!!-prefixes | |
do (let ((!!!-completion | |
(format nil | |
"~A~A~%" | |
!!!-prefix | |
(string-downcase !!!-symbol)))) | |
(unless (or (gethash !!!-completion !!!-seen) | |
(string= "!!!-" | |
!!!-symbol-name | |
:end2 (min | |
(length !!!-symbol-name) | |
4))) | |
(setf (gethash !!!-completion !!!-seen) | |
t) | |
(princ !!!-completion !!!-stream))))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment