aboutsummaryrefslogtreecommitdiff
path: root/modules/ui-navigation.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-12 11:32:53 -0500
committerCraig Jennings <c@cjennings.net>2026-06-12 11:32:53 -0500
commita67d4fabe242f5ea36e8a4e1401e3317a92f0ec7 (patch)
treea4a7995931d7e3e2f3c4392e55cf53debf0384c0 /modules/ui-navigation.el
parent950c98c39edb42c5bb65f8ddb1f815e61b8814dc (diff)
downloaddotemacs-a67d4fabe242f5ea36e8a4e1401e3317a92f0ec7.tar.gz
dotemacs-a67d4fabe242f5ea36e8a4e1401e3317a92f0ec7.zip
fix(ui-navigation): error clearly when undo-kill prefix exceeds the list
An out-of-range numeric prefix made (nth (1- arg) ...) return nil, and find-file on nil signaled a wrong-type-argument. Guard the index and raise a user-error naming how many killed files are available. A new test covers the out-of-range path.
Diffstat (limited to 'modules/ui-navigation.el')
-rw-r--r--modules/ui-navigation.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/ui-navigation.el b/modules/ui-navigation.el
index f0d2ef52..f2181d97 100644
--- a/modules/ui-navigation.el
+++ b/modules/ui-navigation.el
@@ -179,8 +179,11 @@ With numeric prefix ARG, re-open the ARGth most-recently-killed file
(delq buf-file recently-killed-list)))
buffer-files-list)
(when recently-killed-list
- (find-file
- (nth (1- arg) recently-killed-list)))))
+ (let ((file (nth (1- arg) recently-killed-list)))
+ (if file
+ (find-file file)
+ (user-error "Only %d killed file(s) to choose from"
+ (length recently-killed-list)))))))
(keymap-global-set "M-S-z" #'cj/undo-kill-buffer) ;; was M-Z, overrides zap-to-char
;; ---------------------------- Undo Layout Changes ----------------------------