|
195 | 195 |
|
196 | 196 | (define-key global-map (kbd "C-c g") #'magit-status))
|
197 | 197 |
|
| 198 | +(prot-emacs-package vundo |
| 199 | + ;; Waiting for my changes to be merged: |
| 200 | + ;; <https://github.com/casouri/vundo/pull/74>. |
| 201 | + (:install "https://github.com/protesilaos/vundo/") |
| 202 | + (:delay 30) |
| 203 | + (setq vundo-glyph-alist vundo-unicode-symbols) |
| 204 | + |
| 205 | + (define-key global-map (kbd "C-?") #'vundo) ; override `undo-redo' |
| 206 | + |
| 207 | + (defvar prot/vundo-diff-buffer-window nil |
| 208 | + "Window object of `prot/vundo-diff-buffer'.") |
| 209 | + |
| 210 | + (defun prot/vundo-quit-diff-window () |
| 211 | + "Quit `prot/vundo-diff-buffer-window' if it is live. |
| 212 | +Assign this function to the `vundo-post-exit-hook'." |
| 213 | + (when (and prot/vundo-diff-buffer-window |
| 214 | + (window-live-p prot/vundo-diff-buffer-window)) |
| 215 | + (quit-window nil prot/vundo-diff-buffer-window) |
| 216 | + (setq prot/vundo-diff-buffer-window nil))) |
| 217 | + |
| 218 | + (defun prot/vundo-diff-buffer (buffer) |
| 219 | + "Diff BUFFER with its underlying file, if possible. |
| 220 | +Assign this to `vundo-after-undo-functions'. BUFFER is provided |
| 221 | +by that special hook." |
| 222 | + (when (buffer-file-name buffer) |
| 223 | + (with-current-buffer (window-buffer (diff-buffer-with-file buffer)) |
| 224 | + (setq prot/vundo-diff-buffer-window (get-buffer-window))))) |
| 225 | + |
| 226 | + (add-hook 'vundo-after-undo-functions #'prot/vundo-diff-buffer) |
| 227 | + (add-hook 'vundo-post-exit-hook #'prot/vundo-quit-diff-window)) |
| 228 | + |
198 | 229 | (provide 'prot-emacs-git)
|
0 commit comments