diff options
| author | Miles Bader | 2000-10-26 04:35:48 +0000 |
|---|---|---|
| committer | Miles Bader | 2000-10-26 04:35:48 +0000 |
| commit | e276a14ac53a1f5b9bb8ebb81de908e9dcbcbfcc (patch) | |
| tree | 3b848a151d6b76aada98dc26064eb40aab872f13 | |
| parent | e7c9eef9a66c9a7c1186b4add69a9ecc7af5700b (diff) | |
| download | emacs-e276a14ac53a1f5b9bb8ebb81de908e9dcbcbfcc.tar.gz emacs-e276a14ac53a1f5b9bb8ebb81de908e9dcbcbfcc.zip | |
(previous-matching-history-element):
Position point on match.
Handle N == 0 correctly.
Miscellaneous cleanup.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 73 |
2 files changed, 43 insertions, 35 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 07de8dbd57b..dd2c3907dc8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | 2000-10-25 Miles Bader <miles@lsi.nec.co.jp> | 1 | 2000-10-26 Miles Bader <miles@lsi.nec.co.jp> |
| 2 | |||
| 3 | * simple.el (previous-matching-history-element): Position point on | ||
| 4 | match. Handle N == 0 correctly. Miscellaneous cleanup. | ||
| 2 | 5 | ||
| 3 | * comint.el (comint-mode): Locally set `next-line-add-newlines' to nil. | 6 | * comint.el (comint-mode): Locally set `next-line-add-newlines' to nil. |
| 4 | (comint-mode-map): Reverse order of `comint-write-output' and | 7 | (comint-mode-map): Reverse order of `comint-write-output' and |
diff --git a/lisp/simple.el b/lisp/simple.el index 891928b3969..c95fd36c863 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -715,44 +715,49 @@ See also `minibuffer-history-case-insensitive-variables'." | |||
| 715 | (error "No previous history search regexp")) | 715 | (error "No previous history search regexp")) |
| 716 | regexp) | 716 | regexp) |
| 717 | (prefix-numeric-value current-prefix-arg)))) | 717 | (prefix-numeric-value current-prefix-arg)))) |
| 718 | (if (and (zerop minibuffer-history-position) | 718 | (unless (zerop n) |
| 719 | (null minibuffer-text-before-history)) | 719 | (if (and (zerop minibuffer-history-position) |
| 720 | (setq minibuffer-text-before-history (field-string (point-max)))) | 720 | (null minibuffer-text-before-history)) |
| 721 | (let ((history (symbol-value minibuffer-history-variable)) | 721 | (setq minibuffer-text-before-history (field-string (point-max)))) |
| 722 | (case-fold-search | 722 | (let ((history (symbol-value minibuffer-history-variable)) |
| 723 | (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped | 723 | (case-fold-search |
| 724 | ;; On some systems, ignore case for file names. | 724 | (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped |
| 725 | (if (memq minibuffer-history-variable | 725 | ;; On some systems, ignore case for file names. |
| 726 | minibuffer-history-case-insensitive-variables) | 726 | (if (memq minibuffer-history-variable |
| 727 | t | 727 | minibuffer-history-case-insensitive-variables) |
| 728 | ;; Respect the user's setting for case-fold-search: | 728 | t |
| 729 | case-fold-search) | 729 | ;; Respect the user's setting for case-fold-search: |
| 730 | nil)) | 730 | case-fold-search) |
| 731 | prevpos | 731 | nil)) |
| 732 | (pos minibuffer-history-position)) | 732 | prevpos |
| 733 | (while (/= n 0) | 733 | match-string |
| 734 | (setq prevpos pos) | 734 | match-offset |
| 735 | (setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history))) | 735 | (pos minibuffer-history-position)) |
| 736 | (if (= pos prevpos) | 736 | (while (/= n 0) |
| 737 | (setq prevpos pos) | ||
| 738 | (setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history))) | ||
| 739 | (when (= pos prevpos) | ||
| 737 | (error (if (= pos 1) | 740 | (error (if (= pos 1) |
| 738 | "No later matching history item" | 741 | "No later matching history item" |
| 739 | "No earlier matching history item"))) | 742 | "No earlier matching history item"))) |
| 740 | (if (string-match regexp | 743 | (setq match-string |
| 741 | (if (eq minibuffer-history-sexp-flag | 744 | (if (eq minibuffer-history-sexp-flag (minibuffer-depth)) |
| 742 | (minibuffer-depth)) | ||
| 743 | (let ((print-level nil)) | ||
| 744 | (prin1-to-string (nth (1- pos) history))) | ||
| 745 | (nth (1- pos) history))) | ||
| 746 | (setq n (+ n (if (< n 0) 1 -1))))) | ||
| 747 | (setq minibuffer-history-position pos) | ||
| 748 | (goto-char (point-max)) | ||
| 749 | (delete-field) | ||
| 750 | (let ((elt (nth (1- pos) history))) | ||
| 751 | (insert (if (eq minibuffer-history-sexp-flag (minibuffer-depth)) | ||
| 752 | (let ((print-level nil)) | 745 | (let ((print-level nil)) |
| 753 | (prin1-to-string elt)) | 746 | (prin1-to-string (nth (1- pos) history))) |
| 754 | elt))) | 747 | (nth (1- pos) history))) |
| 755 | (goto-char (field-beginning))) | 748 | (setq match-offset |
| 749 | (if (< n 0) | ||
| 750 | (and (string-match regexp match-string) | ||
| 751 | (match-end 0)) | ||
| 752 | (and (string-match (concat ".*\\(" regexp "\\)") match-string) | ||
| 753 | (match-beginning 1)))) | ||
| 754 | (when match-offset | ||
| 755 | (setq n (+ n (if (< n 0) 1 -1))))) | ||
| 756 | (setq minibuffer-history-position pos) | ||
| 757 | (goto-char (point-max)) | ||
| 758 | (delete-field) | ||
| 759 | (insert match-string) | ||
| 760 | (goto-char (+ (field-beginning) match-offset)))) | ||
| 756 | (if (or (eq (car (car command-history)) 'previous-matching-history-element) | 761 | (if (or (eq (car (car command-history)) 'previous-matching-history-element) |
| 757 | (eq (car (car command-history)) 'next-matching-history-element)) | 762 | (eq (car (car command-history)) 'next-matching-history-element)) |
| 758 | (setq command-history (cdr command-history)))) | 763 | (setq command-history (cdr command-history)))) |