summaryrefslogtreecommitdiff
path: root/lisp/menu-bar.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-11-29 21:20:33 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-11-29 21:20:33 +0000
commit71d6d631aed6a36fe5a0445e26b667485b6c15da (patch)
treea9a6d922c570e7c6c71b809b86689a78346f70e2 /lisp/menu-bar.el
parent468659cd365f9bae7d6eeacda568800cb1f49e37 (diff)
downloademacs-71d6d631aed6a36fe5a0445e26b667485b6c15da.tar.gz
* 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.
Diffstat (limited to 'lisp/menu-bar.el')
-rw-r--r--lisp/menu-bar.el30
1 files changed, 15 insertions, 15 deletions
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."