diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-12 09:53:28 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-12 09:53:28 -0500 |
| commit | ee73da1046f0a89b90f3fe2705901fb70cdb427a (patch) | |
| tree | 6163e84c26cb778a83b84e56236b6b672d1e1d6d /modules | |
| parent | c53c75a967ee09e38105d810770103308cd85793 (diff) | |
| download | dotemacs-ee73da1046f0a89b90f3fe2705901fb70cdb427a.tar.gz dotemacs-ee73da1046f0a89b90f3fe2705901fb70cdb427a.zip | |
fix(ui-navigation): correct cj/undo-kill-buffer off-by-one on plain invocation
(interactive "p") forces arg >= 1, so the old (if arg (nth arg ...) (car ...)) always took the nth branch and plain M-S-z re-opened the second-most-recently-killed file. Index with (nth (1- arg) ...) so a numeric prefix is 1-based and no prefix re-opens the most recent. The two undo-kill tests now exercise the real no-prefix path (arg=1 reopens the first) and a 1-based numeric prefix; both failed against the bug and pass after. Filed a follow-up for a separate delq-vs-delete skip-visited defect found in the same function.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ui-navigation.el | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/ui-navigation.el b/modules/ui-navigation.el index f1324c16..f0d2ef52 100644 --- a/modules/ui-navigation.el +++ b/modules/ui-navigation.el @@ -160,7 +160,9 @@ This function won't work with more than one split window." ;; UNDO KILL BUFFER (defun cj/undo-kill-buffer (arg) - "Re-open the last buffer killed. With ARG, re-open the nth buffer." + "Re-open the last buffer killed. +With numeric prefix ARG, re-open the ARGth most-recently-killed file +\(1-based, so no prefix re-opens the most recent)." (interactive "p") (require 'recentf) (unless recentf-mode @@ -178,8 +180,7 @@ This function won't work with more than one split window." buffer-files-list) (when recently-killed-list (find-file - (if arg (nth arg recently-killed-list) - (car recently-killed-list)))))) + (nth (1- arg) recently-killed-list))))) (keymap-global-set "M-S-z" #'cj/undo-kill-buffer) ;; was M-Z, overrides zap-to-char ;; ---------------------------- Undo Layout Changes ---------------------------- |
