0

I want dired buffers to be included in jump list so I can visit them with Ctrl-i and Ctrl-o. One possible catch is that My Ctrl-x d binding is taken by ido-dired. What I've tried so far (without success):

(evil-add-command-properties #'ido-dired :jump t)
(evil-add-command-properties #'dired-jump :jump t)
(evil-add-command-properties #'dired-noselect :jump t)
(evil-add-command-properties #'dired :jump t)
(evil-add-command-properties #'ido-file-internal :jump t)

1 Answer 1

1

Folks on reddit pointed me to the right direction here: https://redd.it/8rg6zk

Will quote the response from @whism:

Looks like evil--jumps-push requires that (buffer-file-name) returns something, or that (buffer-name) matches the regexp in evil--jumps-buffer-targets in order to proceed. It looks like dired buffers would fail here by default. Perhaps that is your issue?

It got me to the idea of changing dired buffer names to be prefixed with Dired: and adding this prefix to evil--jumps-buffer-targets regexp:

(defun my-rename-dired-buffer ()
  (interactive)
  (unless (string-match-p "Dired:" (buffer-name))
    (rename-buffer (concat "Dired:" (buffer-name)) t)))

(add-hook 'dired-mode-hook 'my-rename-dired-buffer)
(setq evil--jumps-buffer-targets "\\(\\*\\(\\new\\|scratch\\)\\*\\|Dired:.+\\)")
(evil-add-command-properties #'dired-find-file :jump t)
3
  • What happens if you create a dired buffer, find a file from the buffer, kill the dired buffer, then try to jump back? Does it jump to the last available jump point, or does the jump fail with an error? Commented Jun 18, 2018 at 19:35
  • @purple_arrows Good question, just checked it out. Emacs will create a new buffer in fundamental mode with the name "Dired:buf_name" and will jump to it. It's not really an issue for me since I rarely kill buffers this way. But I can see how it could easily be fixed buffer deletion hook or something like this.
    – valignatev
    Commented Jun 19, 2018 at 3:50
  • Found an issue with "this buffer already in use" when renaming a buffer to the name which already exists. Passing t as the second argument to the rename-buffer solves it, I've updated the answer
    – valignatev
    Commented Jul 2, 2018 at 7:18

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.