From: Artur Malabarba Date: Sun, 29 Nov 2015 21:20:33 +0000 (+0000) Subject: * lisp/menu-bar.el: Use folding in searches X-Git-Tag: emacs-25.0.90~594 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=71d6d631aed6a36fe5a0445e26b667485b6c15da;p=emacs.git * lisp/menu-bar.el: Use folding in searches (nonincremental-search-forward): Use `isearch-search-fun-default' to determine the search function. (nonincremental-search-backward) (nonincremental-repeat-search-forward) (nonincremental-repeat-search-backward): Use it. --- diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index b2146bed3bd..defd8db6c0d 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -218,7 +218,7 @@ (cond ((and (eq menu-bar-last-search-type 'string) search-ring) - (search-forward (car search-ring))) + (nonincremental-search-forward)) ((and (eq menu-bar-last-search-type 'regexp) regexp-search-ring) (re-search-forward (car regexp-search-ring))) @@ -231,30 +231,30 @@ (cond ((and (eq menu-bar-last-search-type 'string) search-ring) - (search-backward (car search-ring))) + (nonincremental-search-backward)) ((and (eq menu-bar-last-search-type 'regexp) regexp-search-ring) (re-search-backward (car regexp-search-ring))) (t (error "No previous search")))) -(defun nonincremental-search-forward (string) +(defun nonincremental-search-forward (&optional string backward) "Read a string and search for it nonincrementally." (interactive "sSearch for string: ") (setq menu-bar-last-search-type 'string) - (if (equal string "") - (search-forward (car search-ring)) - (isearch-update-ring string nil) - (search-forward string))) - -(defun nonincremental-search-backward (string) + ;; Ideally, this whole command would be equivalent to `C-s RET'. + (let ((isearch-forward (not backward)) + (isearch-regexp-function search-default-regexp-mode) + (isearch-regexp nil)) + (if (or (equal string "") (not string)) + (funcall (isearch-search-fun-default) (car search-ring)) + (isearch-update-ring string nil) + (funcall (isearch-search-fun-default) string)))) + +(defun nonincremental-search-backward (&optional string) "Read a string and search backward for it nonincrementally." - (interactive "sSearch for string: ") - (setq menu-bar-last-search-type 'string) - (if (equal string "") - (search-backward (car search-ring)) - (isearch-update-ring string nil) - (search-backward string))) + (interactive "sSearch backwards for string: ") + (nonincremental-search-forward string 'backward)) (defun nonincremental-re-search-forward (string) "Read a regular expression and search for it nonincrementally."