aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/simple.el42
1 files changed, 11 insertions, 31 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 91a99a7a3e0..345db41ac9f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -760,7 +760,8 @@ See also `minibuffer-history-case-insensitive-variables'."
760 (unless (zerop n) 760 (unless (zerop n)
761 (if (and (zerop minibuffer-history-position) 761 (if (and (zerop minibuffer-history-position)
762 (null minibuffer-text-before-history)) 762 (null minibuffer-text-before-history))
763 (setq minibuffer-text-before-history (field-string (point-max)))) 763 (setq minibuffer-text-before-history
764 (minibuffer-contents-no-properties))
764 (let ((history (symbol-value minibuffer-history-variable)) 765 (let ((history (symbol-value minibuffer-history-variable))
765 (case-fold-search 766 (case-fold-search
766 (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped 767 (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped
@@ -797,9 +798,9 @@ See also `minibuffer-history-case-insensitive-variables'."
797 (setq n (+ n (if (< n 0) 1 -1))))) 798 (setq n (+ n (if (< n 0) 1 -1)))))
798 (setq minibuffer-history-position pos) 799 (setq minibuffer-history-position pos)
799 (goto-char (point-max)) 800 (goto-char (point-max))
800 (delete-field) 801 (delete-minibuffer-contents)
801 (insert match-string) 802 (insert match-string)
802 (goto-char (+ (field-beginning) match-offset)))) 803 (goto-char (+ (minibuffer-prompt-end) match-offset)))))
803 (if (or (eq (car (car command-history)) 'previous-matching-history-element) 804 (if (or (eq (car (car command-history)) 'previous-matching-history-element)
804 (eq (car (car command-history)) 'next-matching-history-element)) 805 (eq (car (car command-history)) 'next-matching-history-element))
805 (setq command-history (cdr command-history)))) 806 (setq command-history (cdr command-history))))
@@ -838,7 +839,8 @@ makes the search case-sensitive."
838 elt minibuffer-returned-to-present) 839 elt minibuffer-returned-to-present)
839 (if (and (zerop minibuffer-history-position) 840 (if (and (zerop minibuffer-history-position)
840 (null minibuffer-text-before-history)) 841 (null minibuffer-text-before-history))
841 (setq minibuffer-text-before-history (field-string (point-max)))) 842 (setq minibuffer-text-before-history
843 (minibuffer-contents-no-properties)))
842 (if (< narg minimum) 844 (if (< narg minimum)
843 (if minibuffer-default 845 (if minibuffer-default
844 (error "End of history; no next item") 846 (error "End of history; no next item")
@@ -847,13 +849,13 @@ makes the search case-sensitive."
847 (error "Beginning of history; no preceding item")) 849 (error "Beginning of history; no preceding item"))
848 (unless (or (eq last-command 'next-history-element) 850 (unless (or (eq last-command 'next-history-element)
849 (eq last-command 'previous-history-element)) 851 (eq last-command 'previous-history-element))
850 (let ((prompt-end (field-beginning (point-max)))) 852 (let ((prompt-end (minibuffer-prompt-end)))
851 (set (make-local-variable 'minibuffer-temporary-goal-position) 853 (set (make-local-variable 'minibuffer-temporary-goal-position)
852 (cond ((<= (point) prompt-end) prompt-end) 854 (cond ((<= (point) prompt-end) prompt-end)
853 ((eobp) nil) 855 ((eobp) nil)
854 (t (point)))))) 856 (t (point))))))
855 (goto-char (point-max)) 857 (goto-char (point-max))
856 (delete-field) 858 (delete-minibuffer-contents)
857 (setq minibuffer-history-position narg) 859 (setq minibuffer-history-position narg)
858 (cond ((= narg -1) 860 (cond ((= narg -1)
859 (setq elt minibuffer-default)) 861 (setq elt minibuffer-default))
@@ -884,7 +886,7 @@ by the new completion."
884 (let ((point-at-start (point))) 886 (let ((point-at-start (point)))
885 (next-matching-history-element 887 (next-matching-history-element
886 (concat 888 (concat
887 "^" (regexp-quote (buffer-substring (field-beginning) (point)))) 889 "^" (regexp-quote (buffer-substring (minibuffer-prompt-end) (point))))
888 n) 890 n)
889 ;; next-matching-history-element always puts us at (point-min). 891 ;; next-matching-history-element always puts us at (point-min).
890 ;; Move to the position we were at before changing the buffer contents. 892 ;; Move to the position we were at before changing the buffer contents.
@@ -899,35 +901,13 @@ by the new completion."
899 (interactive "p") 901 (interactive "p")
900 (next-complete-history-element (- n))) 902 (next-complete-history-element (- n)))
901 903
902;; These two functions are for compatibility with the old subrs of the 904;; For compatibility with the old subr of the same name.
903;; same name.
904
905(defun minibuffer-prompt-width () 905(defun minibuffer-prompt-width ()
906 "Return the display width of the minibuffer prompt. 906 "Return the display width of the minibuffer prompt.
907Return 0 if current buffer is not a mini-buffer." 907Return 0 if current buffer is not a mini-buffer."
908 ;; Return the width of everything before the field at the end of 908 ;; Return the width of everything before the field at the end of
909 ;; the buffer; this should be 0 for normal buffers. 909 ;; the buffer; this should be 0 for normal buffers.
910 (1- (field-beginning (point-max)))) 910 (1- (minibuffer-prompt-end)))
911
912(defun minibuffer-prompt-end ()
913 "Return the buffer position of the end of the minibuffer prompt.
914Return (point-min) if current buffer is not a mini-buffer."
915 (field-beginning (point-max)))
916
917(defun minibuffer-contents ()
918 "Return the user input in a minbuffer as a string.
919The current buffer must be a minibuffer."
920 (field-string (point-max)))
921
922(defun minibuffer-contents-no-properties ()
923 "Return the user input in a minbuffer as a string, without text-properties.
924The current buffer must be a minibuffer."
925 (field-string-no-properties (point-max)))
926
927(defun delete-minibuffer-contents ()
928 "Delete all user input in a minibuffer.
929The current buffer must be a minibuffer."
930 (delete-field (point-max)))
931 911
932;Put this on C-x u, so we can force that rather than C-_ into startup msg 912;Put this on C-x u, so we can force that rather than C-_ into startup msg
933(defalias 'advertised-undo 'undo) 913(defalias 'advertised-undo 'undo)