Restrict adding certain buffers to jump list
gekoke opened this issue · comments
Issue type
- Question
Is there any way to restrict certain buffers being added to the jump list?
I use dirvish, which is a wrapper around dired. Often times after I'm done using dirvish, I press q
to bury its buffer. These visits get added to the evil jump list.
I'd like to avoid this behaviour for a few reasons:
- Dirvish follows my current directory whenever I open it, so from my point of view, there is only ever one global dirvish buffer that I can open or dismiss - I don't need to access it using the jump list.
- Dirvish has its own jump list, which I've bound (or would like to bind) to the same keys I've bound my evil jump list commands to. This jump list implements a directory visiting history.
I'm not sure if this behavior is specific to dirvish, or if it's the same with plain dired as well - I haven't tested that.
I would possibly even like to restrict the jump list to only file-visiting buffers, but I'm not sure if that's exactly what I want yet.
Have you tried adding patterns to evil-jumps-ignored-file-patterns
? I haven't tried it myself, but looks like it should work. Let me know if it doesn't.
Have you tried adding patterns to
evil-jumps-ignored-file-patterns
? I haven't tried it myself, but looks like it should work. Let me know if it doesn't.
That sounds like what I want. I couldn't find any mention of it in the docs. I'll try it out in a bit.
Do you know if non-file-visiting buffers being added to the jump list is expected behavior?
There's handling for non-file-visiting buffers in the code, so I'd say it probably is expected behaviour.
edit: ah that handling says if the buffer has no filename, but it does match evil--jumps-buffer-targets
then it's a valid jump target. So unless you add non-file-visiting buffer patterns there, I guess not.
Looks like this custom variable does what I need.
Line 55 in 16506d9
I got around to actually trying to implement the fix, but I'm running into some issues.
The buffers I wanted to ignore are dired buffers, and dired buffers are just set to the name of whatever directory they are visiting by default.
I tried to rename the dired buffers, figuring I could just match on them that way:
(use-package evil
;; ...
:config
(evil-mode 1)
(add-hook 'dired-mode-hook (lambda () (rename-buffer (generate-new-buffer-name (format "*Dired: %s*" dired-directory)))))
(add-to-list 'evil-jumps-ignored-file-patterns "\*Dirvish.*")
(add-to-list 'evil-jumps-ignored-file-patterns "\*Dired:.*"))
But this doesn't seem to work. I'm guessing evil adds it to the jump list before the rename occurs? :/
Working back from the source code, I was able to come up with this:
(use-package evil
:config
(evil-mode 1)
(add-to-list 'evil-jumps-ignored-file-patterns ".*/$"))
This works because the filename that evil internally assigns to dired buffers always ends with a /
character.
Perhaps a evil-jump-visit-dired-buffers
custom variable or similar would be a nice-to-have.