waymondo / frog-jump-buffer

The fastest buffer-jumping Emacs lisp package around
158 stars 5 forks source link

Allow removing the current buffer from the list? #5

Closed jerrypnz closed 5 years ago

jerrypnz commented 5 years ago

First thanks for making this awesome package. I really like it and it's such a good companion of ivy-switch-buffer.

Currently the first candidate is always the current buffer, which doesn't seem that useful IMHO. Maybe add a defcustom which allows removing the current buffer from the list?

waymondo commented 5 years ago

Sounds valid enough for a defcustom. I personally like having the current buffer there as a way to exit with a rather than using C-g but I could see someone else have a different preference.

jerrypnz commented 5 years ago

That makes sense, although I'd rather having a dedicated keybinding like q for the exit. Still digging into frog-menu to figure out how to do that.

I managed to achieve what I wanted by (ab)using frog-jump-buffer-ignore-buffers:

  (defun jp-frog-jump-buffer (f &rest args)
      (let* ((current-buffer-name (buffer-name (current-buffer)))
             ;; ignore current buffer
             (frog-jump-buffer-ignore-buffers (cons (rx-to-string current-buffer-name)
                                                    frog-jump-buffer-ignore-buffers))
             ;; no background dimming
             (avy-background nil))
        (apply f args)))

    (advice-add #'frog-jump-buffer :around #'jp-frog-jump-buffer)
waymondo commented 5 years ago

You can now replace your advice with (setq frog-jump-buffer-include-current-buffer nil)

jerrypnz commented 5 years ago

Awesome! Thanks for implementing this.