-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] search buffers by project name. #60
Comments
@JSDurand Can you copy and paste the code wrapped with `? |
I found that wrapping the code with three back-ticks makes the code look a lot nicer. (defun durand-complete-buffer (str)
"Complete buffers; intended to be used as `collection' of `ivy-read' with `dynamic-collection' set to t.
If STR starts with \"-\", then complete also with mode name;
if STR starts with \"/\", then complete also with the file name;
if STR starts with a space, then consider also hidden buffers."
(cl-loop for buffer being buffers
when (let* ((nom (buffer-name buffer))
(re-str (funcall (or (ivy-state-re-builder ivy-last)
'ivy--regex-fuzzy)
str))
(matcher (if (stringp re-str) 'string-match 'ivy-re-match)))
(cond
((and (> (length str) 0)
(= (aref str 0) 32)
(= (aref nom 0) 32))
(funcall matcher re-str nom))
((= (aref nom 0) 32) nil)
((and (> (length str) 0)
(= (aref str 0) ?-))
(let* ((re-str
(funcall (or (ivy-state-re-builder ivy-last)
'ivy--regex-fuzzy)
(substring str 1)))
(matcher (if (stringp re-str) 'string-match 'ivy-re-match)))
(or (funcall matcher re-str nom)
(funcall matcher re-str
(ivy-rich-switch-buffer-major-mode
nom)))))
((and (> (length str) 0)
(= (aref str 0) ?/))
(let* ((re-str
(funcall (or (ivy-state-re-builder ivy-last)
'ivy--regex-fuzzy)
(substring str 1)))
(matcher (if (stringp re-str) 'string-match 'ivy-re-match)))
(or (funcall matcher re-str nom)
(funcall matcher re-str
(ivy-rich-switch-buffer-path nom)))))
(t (funcall matcher re-str nom))))
collect (buffer-name buffer))) This function might not be very thoughtful, so feel free to do what you like to it to fulfill your purposes. :) |
Thanks |
I'm currently looking to do exactly that: when I do |
I have proposed a simple modification to ivy which allows to filter based on additional columns supplied by ivy-rich (or any user-supplied transformer function), on a per-command basis (i.e. in my personal case I use it only to modify the behavior of |
I want to search buffers by projectile project name. then It will be more productive for me.
Or It will be good to search it by filepath or other infomation ivy-rich gives like buffer mode
The text was updated successfully, but these errors were encountered: