Function: next-matching-history-element

next-matching-history-element is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(next-matching-history-element REGEXP N)

Documentation

Find the next history element that matches REGEXP.

(The next history element refers to a more recent action.)
With prefix argument N, search for Nth next match. If N is negative, find the previous or Nth previous match. Normally, history elements are matched case-insensitively if case-fold-search is non-nil, but an uppercase letter in REGEXP makes the search case-sensitive.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun next-matching-history-element (regexp n)
  "Find the next history element that matches REGEXP.
\(The next history element refers to a more recent action.)
With prefix argument N, search for Nth next match.
If N is negative, find the previous or Nth previous match.
Normally, history elements are matched case-insensitively if
`case-fold-search' is non-nil, but an uppercase letter in REGEXP
makes the search case-sensitive."
  (interactive
   (let* ((enable-recursive-minibuffers t)
	  (regexp (read-from-minibuffer "Next element matching (regexp): "
					nil
					minibuffer-local-map
					nil
					'minibuffer-history-search-history
                                        (car minibuffer-history-search-history))))
     ;; Use the last regexp specified, by default, if input is empty.
     (list (if (string= regexp "")
	       (if minibuffer-history-search-history
		   (car minibuffer-history-search-history)
		 (user-error "No previous history search regexp"))
	     regexp)
	   (prefix-numeric-value current-prefix-arg))))
  (previous-matching-history-element regexp (- n)))