Created
June 20, 2013 07:31
-
-
Save milkypostman/5820870 to your computer and use it in GitHub Desktop.
grizzl'd
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
(defun to-string (object) | |
"Convert OBJECT to a string." | |
(cond | |
((symbolp object) (symbol-name object)) | |
((stringp object) object) | |
((numberp object) (number-to-string object)) | |
(t (prin1-to-string object)))) | |
(defadvice completing-read (around grizzl-advise-completing-read activate) | |
"Wrapper that uss grizzl" | |
(let* ((completions (mapcar 'to-string | |
(all-completions "" collection predicate))) | |
(search-index (grizzl-make-index completions))) | |
(if search-index | |
(setq ad-return-value | |
(grizzl-completing-read prompt search-index)) | |
ad-do-it))) | |
(progn | |
(ad-disable-advice 'completing-read 'around 'grizzl-advise-completing-read) | |
(ad-activate 'completing-read)) | |
(progn | |
(ad-enable-advice 'completing-read 'around 'grizzl-advise-completing-read) | |
(ad-activate 'completing-read)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@milkypostman holy crap, this is awesome. I love it :)