I wish ivy(counsel) can provide a function to combine switch-to-buffer, recentf, bookmark together.
I want this function because I always open files, I don't know whether I closed buffer (it's in recentf), or not opened still in bookmark list. I want a union entry to access all of them despiting their state difference.
I like the behavior of helm-mini. It provide user to put resources into entry.
ivy-switch-buffer already combines switch-to-buffer and recentf. I can add an option for bookmarks, but it's probably better to have them separate: bookmarks are for quick access and change rarely; aggregating them into ivy-switch-buffer would mean that either they would be dead weight increasing the number of candidates for no reason, or bookmark-jump would become obsolete although it's faster for having less candidates and changing the candidate list rarely.
If you think combine them together is un-necessary in official repository.
I can accept define a user custom function in my init file.
Can you provide the code to do this? Thanks.
(setq ivy-use-virtual-buffers t)
Makes ivy-switch-buffer use bookmarks and recentf. Such an old feature that I forgot that it did bookmarks too.
By the way, this customization is also shown in (Info-goto-node "(ivy)").
I tried option ivy-use-virtual-buffers. It includes recentf. But does not have bookmarks.
It completes off bookmarks-alist. Do you have that variable configured properly (should be the case if you didn't touch it)?
I check out bookmark-alist, but it is nil. I tested with emacs -q. It is fine.
I will debug my configs. Thanks.
I found ivy switch buffers shows candidates does not match with my bookmarks result. (I also tested with emacs -q.)
Here are steps I use in emacs -q:
;; load bookmarks from file.
(expand-file-name "bookmarks.el" user-emacs-directory))
(setq ivy-use-virtual-buffers t ; treat recentf, bookmarks as virtual buffers.
ivy-count-format "(%d/%d) "
ivy-initial-inputs-alist nil ; remove initial ^ input.
ivy-extra-directories nil ; remove . and .. directory.
(global-set-key [remap switch-to-buffer] 'ivy-switch-buffer)
Here are two screenshots. one is using bookmark list, and another is using ivy-switch-buffer.
(mapcar (lambda (bookmark)
(cdr (assoc 'filename bookmark)))
Should return a list of strings.
This returned list of strings is correct with bookmark-bmenu-list result.
Have a look at:
Maybe bisect your config until the return result becomes correct.
After evaluating upper code, the returned result is wrong.
I will bisect my init files.
Thanks for your help.
I got different candidates result after setting ivy-virtual-abbreviate to 'full. The 'full value result is correct.
I know why now, because ivy-virtual-abbreviate 'name (uniquify) is enabled, makes bookmarks which has same file-name-nondirectory. They are combined to one candidate.
I've been using 'name for a very long time, with no problems. Other people prefer 'full. Something like 'uniquify is in the works, but it's boring to debug and release.
The bookmarks which has file path to the same filename like bellowing:
#("/home/stardiviner/Org/Wiki/Computer/Programming/Programming Languages/Python/Data/Packages/Packages.org" 0 103
#("/home/stardiviner/Org/Wiki/Computer/Programming/Programming Languages/TeX/Data/Macro Packages/Macro Packages.org" 0 112
#("/home/stardiviner/Org/Wiki/Computer/Programming/Programming Languages/Julia/Data/Packages/Packages.org" 0 102
I think ivy should not use bookmark filename path value as candidate, should use bookmark name instead. This can avoid uniquify like this issue.
Nothing says that the bookmark names are unique wrt buffer names.
I will 'full as the value. Problem is solved.