# HG changeset patch # User Miles Bader # Date 970594354 0 # Node ID f80262435e6cd0f019724f8cf44d94aaa04e9e31 # Parent d40f5543b08b0b0387e1a6556dc36be9319b508c (minibuffer-temporary-goal-position): New variable. (next-history-element): Try to keep the position of point in the input string constant. diff -r d40f5543b08b -r f80262435e6c lisp/simple.el --- a/lisp/simple.el Tue Oct 03 16:13:36 2000 +0000 +++ b/lisp/simple.el Tue Oct 03 17:32:34 2000 +0000 @@ -778,6 +778,8 @@ (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 @@ (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 @@ (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."