diff options
| author | Gerd Moellmann | 1999-10-17 12:50:04 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-10-17 12:50:04 +0000 |
| commit | a4d1159b771676489354fdcab4f50d06bd5f4622 (patch) | |
| tree | ee23f2c41764aea1cb248b9547ccd9433d00760f | |
| parent | ff69e0120fd6492df31777b820a3f6077efe848b (diff) | |
| download | emacs-a4d1159b771676489354fdcab4f50d06bd5f4622.tar.gz emacs-a4d1159b771676489354fdcab4f50d06bd5f4622.zip | |
Doc fixes.
(previous-matching-history-element, next-history-element):
Change to work correctly even if the point is in the prompt.
(choose-completion-string): Likewise.
(minibuffer-prompt-width): New function (compatibility with old subr).
(line-move): Supply new ESCAPE-FROM-EDGE argument to
constrain-to-field.
(line-move): Use constrain-to-field to avoid
moving into a prompt.
(previous-complete-history-element): Clarify doc string.
(next-complete-history-element): Likewise.
Use field-beginning instead of point-min.
(next-matching-history-element): Use field-beginning and
erase-field instead of point-min and erase-buffer.
(previous-matching-history-element): Get the
minibuffer input with field-string instead of buffer-string.
(choose-completion-string): Likewise.
(next-history-element): Likewise.
Erase the minibuffer input with erase-field, not erase-buffer.
Use field-beginning to find the beginning of the input.
| -rw-r--r-- | lisp/simple.el | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 15fe04b4c7e..6bdd8a4bc89 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -723,7 +723,7 @@ See also `minibuffer-history-case-insensitive-variables'." | |||
| 723 | (prefix-numeric-value current-prefix-arg)))) | 723 | (prefix-numeric-value current-prefix-arg)))) |
| 724 | (if (and (zerop minibuffer-history-position) | 724 | (if (and (zerop minibuffer-history-position) |
| 725 | (null minibuffer-text-before-history)) | 725 | (null minibuffer-text-before-history)) |
| 726 | (setq minibuffer-text-before-history (buffer-string))) | 726 | (setq minibuffer-text-before-history (field-string (point-max)))) |
| 727 | (let ((history (symbol-value minibuffer-history-variable)) | 727 | (let ((history (symbol-value minibuffer-history-variable)) |
| 728 | (case-fold-search | 728 | (case-fold-search |
| 729 | (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped | 729 | (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped |
| @@ -751,13 +751,14 @@ See also `minibuffer-history-case-insensitive-variables'." | |||
| 751 | (nth (1- pos) history))) | 751 | (nth (1- pos) history))) |
| 752 | (setq n (+ n (if (< n 0) 1 -1))))) | 752 | (setq n (+ n (if (< n 0) 1 -1))))) |
| 753 | (setq minibuffer-history-position pos) | 753 | (setq minibuffer-history-position pos) |
| 754 | (erase-buffer) | 754 | (goto-char (point-max)) |
| 755 | (erase-field) | ||
| 755 | (let ((elt (nth (1- pos) history))) | 756 | (let ((elt (nth (1- pos) history))) |
| 756 | (insert (if (eq minibuffer-history-sexp-flag (minibuffer-depth)) | 757 | (insert (if (eq minibuffer-history-sexp-flag (minibuffer-depth)) |
| 757 | (let ((print-level nil)) | 758 | (let ((print-level nil)) |
| 758 | (prin1-to-string elt)) | 759 | (prin1-to-string elt)) |
| 759 | elt))) | 760 | elt))) |
| 760 | (goto-char (point-min))) | 761 | (goto-char (field-beginning))) |
| 761 | (if (or (eq (car (car command-history)) 'previous-matching-history-element) | 762 | (if (or (eq (car (car command-history)) 'previous-matching-history-element) |
| 762 | (eq (car (car command-history)) 'next-matching-history-element)) | 763 | (eq (car (car command-history)) 'next-matching-history-element)) |
| 763 | (setq command-history (cdr command-history)))) | 764 | (setq command-history (cdr command-history)))) |
| @@ -792,14 +793,15 @@ An uppercase letter in REGEXP makes the search case-sensitive." | |||
| 792 | elt minibuffer-returned-to-present) | 793 | elt minibuffer-returned-to-present) |
| 793 | (if (and (zerop minibuffer-history-position) | 794 | (if (and (zerop minibuffer-history-position) |
| 794 | (null minibuffer-text-before-history)) | 795 | (null minibuffer-text-before-history)) |
| 795 | (setq minibuffer-text-before-history (buffer-string))) | 796 | (setq minibuffer-text-before-history (field-string (point-max)))) |
| 796 | (if (< narg minimum) | 797 | (if (< narg minimum) |
| 797 | (if minibuffer-default | 798 | (if minibuffer-default |
| 798 | (error "End of history; no next item") | 799 | (error "End of history; no next item") |
| 799 | (error "End of history; no default available"))) | 800 | (error "End of history; no default available"))) |
| 800 | (if (> narg (length (symbol-value minibuffer-history-variable))) | 801 | (if (> narg (length (symbol-value minibuffer-history-variable))) |
| 801 | (error "Beginning of history; no preceding item")) | 802 | (error "Beginning of history; no preceding item")) |
| 802 | (erase-buffer) | 803 | (goto-char (point-max)) |
| 804 | (erase-field) | ||
| 803 | (setq minibuffer-history-position narg) | 805 | (setq minibuffer-history-position narg) |
| 804 | (cond ((= narg -1) | 806 | (cond ((= narg -1) |
| 805 | (setq elt minibuffer-default)) | 807 | (setq elt minibuffer-default)) |
| @@ -815,7 +817,7 @@ An uppercase letter in REGEXP makes the search case-sensitive." | |||
| 815 | (let ((print-level nil)) | 817 | (let ((print-level nil)) |
| 816 | (prin1-to-string elt)) | 818 | (prin1-to-string elt)) |
| 817 | elt)) | 819 | elt)) |
| 818 | (goto-char (minibuffer-prompt-end))))) | 820 | (goto-char (field-beginning))))) |
| 819 | 821 | ||
| 820 | (defun previous-history-element (n) | 822 | (defun previous-history-element (n) |
| 821 | "Inserts the previous element of the minibuffer history into the minibuffer." | 823 | "Inserts the previous element of the minibuffer history into the minibuffer." |
| @@ -823,11 +825,15 @@ An uppercase letter in REGEXP makes the search case-sensitive." | |||
| 823 | (next-history-element (- n))) | 825 | (next-history-element (- n))) |
| 824 | 826 | ||
| 825 | (defun next-complete-history-element (n) | 827 | (defun next-complete-history-element (n) |
| 826 | "Get next element of history which is a completion of minibuffer contents." | 828 | "Get next history element which completes the minibuffer before the point. |
| 829 | The contents of the minibuffer after the point are deleted, and replaced | ||
| 830 | by the new completion." | ||
| 827 | (interactive "p") | 831 | (interactive "p") |
| 828 | (let ((point-at-start (point))) | 832 | (let ((point-at-start (point))) |
| 829 | (next-matching-history-element | 833 | (next-matching-history-element |
| 830 | (concat "^" (regexp-quote (buffer-substring (point-min) (point)))) n) | 834 | (concat |
| 835 | "^" (regexp-quote (buffer-substring (field-beginning) (point)))) | ||
| 836 | n) | ||
| 831 | ;; next-matching-history-element always puts us at (point-min). | 837 | ;; next-matching-history-element always puts us at (point-min). |
| 832 | ;; Move to the position we were at before changing the buffer contents. | 838 | ;; Move to the position we were at before changing the buffer contents. |
| 833 | ;; This is still sensical, because the text before point has not changed. | 839 | ;; This is still sensical, because the text before point has not changed. |
| @@ -835,9 +841,31 @@ An uppercase letter in REGEXP makes the search case-sensitive." | |||
| 835 | 841 | ||
| 836 | (defun previous-complete-history-element (n) | 842 | (defun previous-complete-history-element (n) |
| 837 | "\ | 843 | "\ |
| 838 | Get previous element of history which is a completion of minibuffer contents." | 844 | Get previous history element which completes the minibuffer before the point. |
| 845 | The contents of the minibuffer after the point are deleted, and replaced | ||
| 846 | by the new completion." | ||
| 839 | (interactive "p") | 847 | (interactive "p") |
| 840 | (next-complete-history-element (- n))) | 848 | (next-complete-history-element (- n))) |
| 849 | |||
| 850 | ;; These two functions are for compatibility with the old subrs of the | ||
| 851 | ;; same name. | ||
| 852 | |||
| 853 | (defun minibuffer-prompt-width () | ||
| 854 | "Return the display width of the minibuffer prompt. | ||
| 855 | Return 0 if current buffer is not a mini-buffer." | ||
| 856 | ;; Return the width of everything before the field at the end of | ||
| 857 | ;; the buffer; this should be 0 for normal buffers. | ||
| 858 | (1- (field-beginning (point-max)))) | ||
| 859 | |||
| 860 | (defun minibuffer-prompt-end () | ||
| 861 | "Return the buffer position of the end of the minibuffer prompt. | ||
| 862 | Return 0 if current buffer is not a mini-buffer." | ||
| 863 | ;; Return the width of everything before the field at the end of | ||
| 864 | ;; the buffer; this should be 0 for normal buffers. | ||
| 865 | ;; XXX This definition doesn't seem very useful; why does one care | ||
| 866 | ;; about the last character of the prompt? The beginning of the | ||
| 867 | ;; user-text seems more useful (e.g., this value + 1). | ||
| 868 | (1- (field-beginning (point-max)))) | ||
| 841 | 869 | ||
| 842 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg | 870 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg |
| 843 | (defalias 'advertised-undo 'undo) | 871 | (defalias 'advertised-undo 'undo) |
| @@ -2403,7 +2431,7 @@ Outline mode sets this." | |||
| 2403 | ;; with intangibility and point-motion hooks enabled this time. | 2431 | ;; with intangibility and point-motion hooks enabled this time. |
| 2404 | (goto-char opoint) | 2432 | (goto-char opoint) |
| 2405 | (setq inhibit-point-motion-hooks nil) | 2433 | (setq inhibit-point-motion-hooks nil) |
| 2406 | (goto-char new) | 2434 | (goto-char (constrain-to-field new opoint t t)) |
| 2407 | ;; If intangibility processing moved us to a different line, | 2435 | ;; If intangibility processing moved us to a different line, |
| 2408 | ;; readjust the horizontal position within the line we ended up at. | 2436 | ;; readjust the horizontal position within the line we ended up at. |
| 2409 | (when (or (< (point) line-beg) (> (point) line-end)) | 2437 | (when (or (< (point) line-beg) (> (point) line-end)) |
| @@ -2418,7 +2446,7 @@ Outline mode sets this." | |||
| 2418 | (setq new (point))) | 2446 | (setq new (point))) |
| 2419 | (goto-char (point-min)) | 2447 | (goto-char (point-min)) |
| 2420 | (setq inhibit-point-motion-hooks nil) | 2448 | (setq inhibit-point-motion-hooks nil) |
| 2421 | (goto-char new) | 2449 | (goto-char (constrain-to-field new opoint t t)) |
| 2422 | ))) | 2450 | ))) |
| 2423 | nil) | 2451 | nil) |
| 2424 | 2452 | ||
| @@ -3816,7 +3844,7 @@ With prefix argument N, move N items (negative N means move backward)." | |||
| 3816 | ;; If this is reading a file name, and the file name chosen | 3844 | ;; If this is reading a file name, and the file name chosen |
| 3817 | ;; is a directory, don't exit the minibuffer. | 3845 | ;; is a directory, don't exit the minibuffer. |
| 3818 | (if (and (eq minibuffer-completion-table 'read-file-name-internal) | 3846 | (if (and (eq minibuffer-completion-table 'read-file-name-internal) |
| 3819 | (file-directory-p (buffer-string))) | 3847 | (file-directory-p (field-string (point-max)))) |
| 3820 | (select-window (active-minibuffer-window)) | 3848 | (select-window (active-minibuffer-window)) |
| 3821 | (exit-minibuffer)))))) | 3849 | (exit-minibuffer)))))) |
| 3822 | 3850 | ||