From 9fc3eb1e96b8515a1e7685bfcb61bcd09674ab73 Mon Sep 17 00:00:00 2001 From: BardofSprites <89086143+BardofSprites@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:37:15 -0400 Subject: vundo --- bard-emacs-modules/bard-emacs-essentials.el | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'bard-emacs-modules') diff --git a/bard-emacs-modules/bard-emacs-essentials.el b/bard-emacs-modules/bard-emacs-essentials.el index 79d8ea0..c64f271 100644 --- a/bard-emacs-modules/bard-emacs-essentials.el +++ b/bard-emacs-modules/bard-emacs-essentials.el @@ -147,6 +147,42 @@ :hook (prog-mode . breadcrumb-local-mode)) +(use-package vundo + :ensure t + :defer 1 + :bind + ( :map vundo-mode-map + ("C-/" . vundo-backward) + ("C-?" . vundo-forward) + ("g" . vundo-goto-last-saved) + ("p" . vundo-backward) + ("n" . vundo-forward) + ("f" . vundo-next) + ("b" . vundo-previous)) + :config + (setq vundo-glyph-alist vundo-unicode-symbols) + + (defvar prot/vundo-undo-functions '(undo undo-only undo-redo) + "List of undo functions to check if we need to visualise the undo ring.") + + (defvar prot/vundo-undo-command #'undo + "Command to call if we are not going to visualise the undo ring.") + + (defun prot/vundo-if-repeat-undo (&rest args) + "Use `vundo' if the last command is among `prot/vundo-undo-functions'. +In other words, start visualising the undo ring if we are going +to be cycling through the edits." + (interactive) + (if (and (member last-command prot/vundo-undo-functions) + (not undo-in-region)) + (call-interactively 'vundo) + (apply args))) + + (mapc + (lambda (fn) + (advice-add fn :around #'prot/vundo-if-repeat-undo)) + prot/vundo-undo-functions)) + ;; running emacs as server (require 'server) (setq server-client-instructions nil) -- cgit v1.2.3