Skip to content

Instantly share code, notes, and snippets.

@mkhl
Created November 25, 2008 09:34
Show Gist options
  • Save mkhl/28863 to your computer and use it in GitHub Desktop.
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.
(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