Mercurial > emacs
comparison lisp/simple.el @ 39597:d92e65cccff6
(previous-matching-history-element, next-history-element)
next-complete-history-element): Use `minibuffer-' functions instead of
calling `field-' functions directly.
(minibuffer-prompt-end, minibuffer-contents):
(minibuffer-contents-no-properties, delete-minibuffer-contents):
Functions removed (now subrs).
(minibuffer-prompt-width): Use `minibuffer-prompt-end'.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 05 Oct 2001 12:28:31 +0000 |
parents | c5d6010e15ee |
children | 309d26eb8616 |
comparison
equal
deleted
inserted
replaced
39596:fc100d4d02bc | 39597:d92e65cccff6 |
---|---|
758 regexp) | 758 regexp) |
759 (prefix-numeric-value current-prefix-arg)))) | 759 (prefix-numeric-value current-prefix-arg)))) |
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 |
767 ;; On some systems, ignore case for file names. | 768 ;; On some systems, ignore case for file names. |
768 (if (memq minibuffer-history-variable | 769 (if (memq minibuffer-history-variable |
795 (match-beginning 1)))) | 796 (match-beginning 1)))) |
796 (when match-offset | 797 (when match-offset |
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)))) |
806 | 807 |
807 (defun next-matching-history-element (regexp n) | 808 (defun next-matching-history-element (regexp n) |
836 (let ((narg (- minibuffer-history-position n)) | 837 (let ((narg (- minibuffer-history-position n)) |
837 (minimum (if minibuffer-default -1 0)) | 838 (minimum (if minibuffer-default -1 0)) |
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") |
845 (error "End of history; no default available"))) | 847 (error "End of history; no default available"))) |
846 (if (> narg (length (symbol-value minibuffer-history-variable))) | 848 (if (> narg (length (symbol-value minibuffer-history-variable))) |
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)) |
860 ((= narg 0) | 862 ((= narg 0) |
861 (setq elt (or minibuffer-text-before-history "")) | 863 (setq elt (or minibuffer-text-before-history "")) |
882 by the new completion." | 884 by the new completion." |
883 (interactive "p") | 885 (interactive "p") |
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. |
891 ;; This is still sensical, because the text before point has not changed. | 893 ;; This is still sensical, because the text before point has not changed. |
892 (goto-char point-at-start))) | 894 (goto-char point-at-start))) |
897 The contents of the minibuffer after the point are deleted, and replaced | 899 The contents of the minibuffer after the point are deleted, and replaced |
898 by the new completion." | 900 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. |
907 Return 0 if current buffer is not a mini-buffer." | 907 Return 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. | |
914 Return (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. | |
919 The 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. | |
924 The 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. | |
929 The 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) |
934 | 914 |
935 (defun undo (&optional arg) | 915 (defun undo (&optional arg) |