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)) |
Ugh... "in particular, allowing extending the default behaviour for things like 'find file'".
@milkypostman holy crap, this is awesome. I love it :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@milkypostman this looks awesome, thanks. I'm about to leave work and will be able to play around with this when I get home :) I'll be spending some time working on fiplr/grizzl tonight, with those extension points I mentioned... in particular.