mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-24 05:47:36 +00:00
(previous-matching-history-element):
Position point on match. Handle N == 0 correctly. Miscellaneous cleanup.
This commit is contained in:
parent
e7c9eef9a6
commit
e276a14ac5
2 changed files with 43 additions and 35 deletions
|
|
@ -1,4 +1,7 @@
|
|||
2000-10-25 Miles Bader <miles@lsi.nec.co.jp>
|
||||
2000-10-26 Miles Bader <miles@lsi.nec.co.jp>
|
||||
|
||||
* simple.el (previous-matching-history-element): Position point on
|
||||
match. Handle N == 0 correctly. Miscellaneous cleanup.
|
||||
|
||||
* comint.el (comint-mode): Locally set `next-line-add-newlines' to nil.
|
||||
(comint-mode-map): Reverse order of `comint-write-output' and
|
||||
|
|
|
|||
|
|
@ -715,44 +715,49 @@ See also `minibuffer-history-case-insensitive-variables'."
|
|||
(error "No previous history search regexp"))
|
||||
regexp)
|
||||
(prefix-numeric-value current-prefix-arg))))
|
||||
(if (and (zerop minibuffer-history-position)
|
||||
(null minibuffer-text-before-history))
|
||||
(setq minibuffer-text-before-history (field-string (point-max))))
|
||||
(let ((history (symbol-value minibuffer-history-variable))
|
||||
(case-fold-search
|
||||
(if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped
|
||||
;; On some systems, ignore case for file names.
|
||||
(if (memq minibuffer-history-variable
|
||||
minibuffer-history-case-insensitive-variables)
|
||||
t
|
||||
;; Respect the user's setting for case-fold-search:
|
||||
case-fold-search)
|
||||
nil))
|
||||
prevpos
|
||||
(pos minibuffer-history-position))
|
||||
(while (/= n 0)
|
||||
(setq prevpos pos)
|
||||
(setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history)))
|
||||
(if (= pos prevpos)
|
||||
(unless (zerop n)
|
||||
(if (and (zerop minibuffer-history-position)
|
||||
(null minibuffer-text-before-history))
|
||||
(setq minibuffer-text-before-history (field-string (point-max))))
|
||||
(let ((history (symbol-value minibuffer-history-variable))
|
||||
(case-fold-search
|
||||
(if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped
|
||||
;; On some systems, ignore case for file names.
|
||||
(if (memq minibuffer-history-variable
|
||||
minibuffer-history-case-insensitive-variables)
|
||||
t
|
||||
;; Respect the user's setting for case-fold-search:
|
||||
case-fold-search)
|
||||
nil))
|
||||
prevpos
|
||||
match-string
|
||||
match-offset
|
||||
(pos minibuffer-history-position))
|
||||
(while (/= n 0)
|
||||
(setq prevpos pos)
|
||||
(setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history)))
|
||||
(when (= pos prevpos)
|
||||
(error (if (= pos 1)
|
||||
"No later matching history item"
|
||||
"No earlier matching history item")))
|
||||
(if (string-match regexp
|
||||
(if (eq minibuffer-history-sexp-flag
|
||||
(minibuffer-depth))
|
||||
(let ((print-level nil))
|
||||
(prin1-to-string (nth (1- pos) history)))
|
||||
(nth (1- pos) history)))
|
||||
(setq n (+ n (if (< n 0) 1 -1)))))
|
||||
(setq minibuffer-history-position pos)
|
||||
(goto-char (point-max))
|
||||
(delete-field)
|
||||
(let ((elt (nth (1- pos) history)))
|
||||
(insert (if (eq minibuffer-history-sexp-flag (minibuffer-depth))
|
||||
(setq match-string
|
||||
(if (eq minibuffer-history-sexp-flag (minibuffer-depth))
|
||||
(let ((print-level nil))
|
||||
(prin1-to-string elt))
|
||||
elt)))
|
||||
(goto-char (field-beginning)))
|
||||
(prin1-to-string (nth (1- pos) history)))
|
||||
(nth (1- pos) history)))
|
||||
(setq match-offset
|
||||
(if (< n 0)
|
||||
(and (string-match regexp match-string)
|
||||
(match-end 0))
|
||||
(and (string-match (concat ".*\\(" regexp "\\)") match-string)
|
||||
(match-beginning 1))))
|
||||
(when match-offset
|
||||
(setq n (+ n (if (< n 0) 1 -1)))))
|
||||
(setq minibuffer-history-position pos)
|
||||
(goto-char (point-max))
|
||||
(delete-field)
|
||||
(insert match-string)
|
||||
(goto-char (+ (field-beginning) match-offset))))
|
||||
(if (or (eq (car (car command-history)) 'previous-matching-history-element)
|
||||
(eq (car (car command-history)) 'next-matching-history-element))
|
||||
(setq command-history (cdr command-history))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue