aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1995-02-12 08:27:38 +0000
committerRichard M. Stallman <[email protected]>1995-02-12 08:27:38 +0000
commit0818b15e4a570f3f072bbcae249a7be1b55991b5 (patch)
treea9db1c25b536d2ab3314d649e42133d2724f4a00 /lisp
parent4c0317b1c2de90d16c9dcf03df18afdd0a43b0c8 (diff)
(next-history-element): Do nothing if n is 0.
Handle errors properly when history list is empty.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el36
1 files changed, 20 insertions, 16 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index c958736834..df5c655b3c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -559,22 +559,26 @@ If N is negative, find the previous or Nth previous match."
(defun next-history-element (n)
"Insert the next element of the minibuffer history into the minibuffer."
(interactive "p")
- (let ((narg (min (max 1 (- minibuffer-history-position n))
- (length (symbol-value minibuffer-history-variable)))))
- (if (= minibuffer-history-position narg)
- (error (if (= minibuffer-history-position 1)
- "End of history; no next item"
- "Beginning of history; no preceding item"))
- (erase-buffer)
- (setq minibuffer-history-position narg)
- (let ((elt (nth (1- minibuffer-history-position)
- (symbol-value minibuffer-history-variable))))
- (insert
- (if minibuffer-history-sexp-flag
- (let ((print-level nil))
- (prin1-to-string elt))
- elt)))
- (goto-char (point-min)))))
+ (or (zerop n)
+ (let ((narg (min (max 1 (- minibuffer-history-position n))
+ (length (symbol-value minibuffer-history-variable)))))
+ (if (or (zerop narg)
+ (= minibuffer-history-position narg))
+ (error (if (if (zerop narg)
+ (> n 0)
+ (= minibuffer-history-position 1))
+ "End of history; no next item"
+ "Beginning of history; no preceding item"))
+ (erase-buffer)
+ (setq minibuffer-history-position narg)
+ (let ((elt (nth (1- minibuffer-history-position)
+ (symbol-value minibuffer-history-variable))))
+ (insert
+ (if minibuffer-history-sexp-flag
+ (let ((print-level nil))
+ (prin1-to-string elt))
+ elt)))
+ (goto-char (point-min))))))
(defun previous-history-element (n)
"Inserts the previous element of the minibuffer history into the minibuffer."