1

I really love the ability to quickly navigate to files opened in old editing sessions that desktop provides. However, there are a few things I don't like about it so I'd like to stop using it if possible, but I'm not quite there yet.

What I don't like about desktop: Note neither of these would be a problem if buffers were merely easily re-openable, rather than immediately re-opened (as desktop-change-dir does):

  • Slow startup with large numbers of buffers
  • A tendency to make it harder to diagnose problems in my emacs configuration, because of side-effects from opening buffers

What I'm trying to use instead of desktop:

  • ido-use-virtual-buffers: This ido feature keeps a list of closed buffers. When using ido to switch buffer, the closed buffers show up too (with a different face and different prioritization).
  • saveplace to save point (cursor position) in buffers
  • savehist to save minibuffer history

This is all great, except that ido is only saving a small number of buffers for me in ido.last. How can I have several hundred buffers saved by ido across emacs restart, and have them saved whether they are closed ('virtual') or not?

Customizing ido-max-work-file-list doesn't seem to have any effect for me. -- actually it does, see answer

I'm aware of projectile and use that too, but this is a bit different. I'm also aware of recentf, but I'd prefer to stick with ido-use-virtual-buffers, because aside from lack of persistence across emacs sessions it works perfectly for me.

1 Answer 1

2

ido gets its file history from multiple places:

If ido-use-virtual-buffers is enabled, ido uses recentf to save buffer history. At history save time (e.g. on emacs shutdown), recentf-files may include both virtual (closed) and non-virtual buffers, so recentf-save-list will save both to file ~/.emacs.d/recentf. When emacs is started again later on, they will all become ido virtual buffers.

ido also has "work directory" and "work file" features. These are used via ido-next-work-directory and ido-prev-work-directory (M-n / M-p or M-down / M-up), and by ido-next-work-file and ido-prev-work-file (C-M-o / C-o). ido-max-work-file-list controls the number of work files stored in ido-work-file-list (and similarly ido-max-work-directory-list controls ido-work-directory-list). These lists are persisted to file ~/.emacs.d/ido.last by ido-save-history.

The reason that I was seeing files not saved in ido.last is that buffers are not added to ido-work-file-list unless they are visited using ido. They are not added to that list if they are visited using dired. So I've added this to my init files so that regardless of how a file is opened, it gets added to the list:

(defun my/add-to-ido-work-file-list ()
    (ido-record-work-file (file-name-nondirectory (buffer-file-name)))
    (ido-record-work-directory (file-name-directory (buffer-file-name))))
(add-hook 'find-file-hook 'my/add-to-ido-work-file-list)
1
  • I've been using this setup with recentf, ido-virtual-buffers, saveplace and savehist for a while now and I'm finding it really great. No more waiting for desktop-mode to load my bloated desktop file with hundreds of buffers! Commented Dec 20, 2016 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.