From 8dc3ba7d01dc99b9be1de4b8989950199c45fe70 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 3 Oct 2000 17:32:34 +0000 Subject: [PATCH] (minibuffer-temporary-goal-position): New variable. (next-history-element): Try to keep the position of point in the input string constant. --- lisp/simple.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/simple.el b/lisp/simple.el index 82b2d52f5cb..c7032941235 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -778,6 +778,8 @@ An uppercase letter in REGEXP makes the search case-sensitive." (prefix-numeric-value current-prefix-arg)))) (previous-matching-history-element regexp (- n))) +(defvar minibuffer-temporary-goal-position nil) + (defun next-history-element (n) "Insert the next element of the minibuffer history into the minibuffer." (interactive "p") @@ -794,6 +796,13 @@ An uppercase letter in REGEXP makes the search case-sensitive." (error "End of history; no default available"))) (if (> narg (length (symbol-value minibuffer-history-variable))) (error "Beginning of history; no preceding item")) + (unless (or (eq last-command 'next-history-element) + (eq last-command 'previous-history-element)) + (let ((prompt-end (field-beginning (point-max)))) + (set (make-local-variable 'minibuffer-temporary-goal-position) + (cond ((<= (point) prompt-end) prompt-end) + ((eobp) nil) + (t (point)))))) (goto-char (point-max)) (delete-field) (setq minibuffer-history-position narg) @@ -811,7 +820,7 @@ An uppercase letter in REGEXP makes the search case-sensitive." (let ((print-level nil)) (prin1-to-string elt)) elt)) - (goto-char (field-beginning))))) + (goto-char (or minibuffer-temporary-goal-position (point-max)))))) (defun previous-history-element (n) "Inserts the previous element of the minibuffer history into the minibuffer." -- 2.39.2