Skip to content

Exiting vundo should (optionally) exit vundo-diff #88

@ideasman42

Description

@ideasman42

It would be good if quitting vundo would also close the vundo-diff buffer & window.
So viewing a vundo-diff buffer doesn't leave this buffer open once I've finished using vundo (which I need to manually exit). I'm not so fussed on this being on by default or not, just that it would be nice if it's a toggle.

Of course it's possible to write advice that does this but it seems like something users might want to enable without the hassle of implementing this themselves.

Note that vundo-post-exit-hook can't easily be used for this as the vundo buffer has been deleted (which is needed to access the name of the diff buffer).


This advice for vundo-quit works but it involves using internal names.

(advice-add
 'vundo-quit
 :around
 #'(lambda (old-fn &rest args)
     (let* ((orig vundo--orig-buffer)
            (oname (buffer-name orig))
            (diff-buf (get-buffer (concat "*vundo-diff-" oname "*"))))
       (when diff-buf
         (let ((diff-window (get-buffer-window diff-buf)))
           (when diff-window
             (delete-window diff-window))
           (kill-buffer diff-buf)))

       (let ((result (apply old-fn args)))
         result))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions