[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
recursive-edit in Isearch
From: |
Juri Linkov |
Subject: |
recursive-edit in Isearch |
Date: |
Sun, 09 Nov 2008 22:54:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
Commentary in isearch.el:
;; For programmed use of isearch-mode, e.g. calling (isearch-forward),
;; isearch-mode behaves modally and does not return until the search
;; is completed. It uses a recursive-edit to behave this way.
This causes a few problems. The call to `exit-recursive-edit' in
`isearch-done' terminates the execution of the calling Lisp function,
so that `isearch-clean-overlays' in `isearch-exit' located after
`isearch-done' will never get executed. What is worse is that the rest
of code after `isearch-done' in the commands `isearch-query-replace' and
`isearch-highlight-regexp' doesn't get executed, so these commands fail
when called programmatically via (isearch-forward) which is used when
searching file names in Dired.
Unless there is a better solution, I propose the following patch to fix
these problems in `isearch-query-replace' and `isearch-highlight-regexp'.
It binds `isearch-recursive-edit' to nil, thus preventing `isearch-done'
from calling `exit-recursive-edit' that terminates the execution of
these commands. `exit-recursive-edit' gets called explicitly at the end
of these commands.
Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.331
diff -c -r1.331 isearch.el
*** lisp/isearch.el 19 Oct 2008 22:33:17 -0000 1.331
--- lisp/isearch.el 9 Nov 2008 20:50:37 -0000
***************
*** 1347,1354 ****
(let ((case-fold-search isearch-case-fold-search)
;; set `search-upper-case' to nil to not call
;; `isearch-no-upper-case-p' in `perform-replace'
! (search-upper-case nil))
! (isearch-done)
(isearch-clean-overlays)
(if (and isearch-other-end
(< isearch-other-end (point))
--- 1347,1359 ----
(let ((case-fold-search isearch-case-fold-search)
;; set `search-upper-case' to nil to not call
;; `isearch-no-upper-case-p' in `perform-replace'
! (search-upper-case nil)
! ;; Set `isearch-recursive-edit' to nil to prevent calling
! ;; `exit-recursive-edit' in `isearch-done' that terminates
! ;; the execution of this command when it is non-nil.
! ;; We call `exit-recursive-edit' explicitly at the end below.
! (isearch-recursive-edit nil))
! (isearch-done nil t)
(isearch-clean-overlays)
(if (and isearch-other-end
(< isearch-other-end (point))
***************
*** 1369,1375 ****
isearch-regexp)
t isearch-regexp (or delimited isearch-word) nil nil
(if (and transient-mark-mode mark-active) (region-beginning))
! (if (and transient-mark-mode mark-active) (region-end)))))
(defun isearch-query-replace-regexp (&optional delimited)
"Start `query-replace-regexp' with string to replace from last search
string.
--- 1374,1381 ----
isearch-regexp)
t isearch-regexp (or delimited isearch-word) nil nil
(if (and transient-mark-mode mark-active) (region-beginning))
! (if (and transient-mark-mode mark-active) (region-end))))
! (and isearch-recursive-edit (exit-recursive-edit)))
(defun isearch-query-replace-regexp (&optional delimited)
"Start `query-replace-regexp' with string to replace from last search
string.
***************
*** 1401,1408 ****
argument from the last search regexp or a quoted search string,
and reads its face argument using `hi-lock-read-face-name'."
(interactive)
! (isearch-done)
! (isearch-clean-overlays)
(require 'hi-lock nil t)
(let ((string (cond (isearch-regexp isearch-string)
((if (and (eq isearch-case-fold-search t)
--- 1411,1424 ----
argument from the last search regexp or a quoted search string,
and reads its face argument using `hi-lock-read-face-name'."
(interactive)
! (let (
! ;; Set `isearch-recursive-edit' to nil to prevent calling
! ;; `exit-recursive-edit' in `isearch-done' that terminates
! ;; the execution of this command when it is non-nil.
! ;; We call `exit-recursive-edit' explicitly at the end below.
! (isearch-recursive-edit nil))
! (isearch-done nil t)
! (isearch-clean-overlays))
(require 'hi-lock nil t)
(let ((string (cond (isearch-regexp isearch-string)
((if (and (eq isearch-case-fold-search t)
***************
*** 1420,1426 ****
(regexp-quote s))))
isearch-string ""))
(t (regexp-quote isearch-string)))))
! (hi-lock-face-buffer string (hi-lock-read-face-name))))
(defun isearch-delete-char ()
--- 1436,1443 ----
(regexp-quote s))))
isearch-string ""))
(t (regexp-quote isearch-string)))))
! (hi-lock-face-buffer string (hi-lock-read-face-name)))
! (and isearch-recursive-edit (exit-recursive-edit)))
(defun isearch-delete-char ()
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: Isearch in dired, (continued)
Re: Isearch in dired, Chong Yidong, 2008/11/09