]> git.eshelyaron.com Git - emacs.git/commitdiff
* replace.el (query-replace-highlight): Add new value `isearch'
authorJuri Linkov <juri@jurta.org>
Sun, 12 Dec 2004 22:33:28 +0000 (22:33 +0000)
committerJuri Linkov <juri@jurta.org>
Sun, 12 Dec 2004 22:33:28 +0000 (22:33 +0000)
that allows query replacement to use isearch highlighting.
Change type from `boolean' to `choice'.  Doc fix.
(replace-highlight, replace-dehighlight, perform-replace):
Use isearch highlighting if query-replace-highlight eq `isearch'.

lisp/ChangeLog
lisp/replace.el

index e1335731707e5f7e4e883ddb2caa47788f079f20..d75943f408dc6c4523a69a55451a4466b0ebe193 100644 (file)
@@ -1,3 +1,36 @@
+2004-12-12  Juri Linkov  <juri@jurta.org>
+
+       * isearch.el (isearch-edit-string): Set 7th arg of
+       `read-from-minibuffer' to `t' to inherit the current input
+       method (whose name is indicated by [IM] in the minibuffer prompt)
+       from the current buffer to the minibuffer.
+       (isearch-lazy-highlight-update): Put body to `with-local-quit'
+       to allow C-g quitting for lazy highlighting looping inside the
+       search with nested repetition operators.  Add overlay to the list
+       before setting its face and other properties to avoid the case of
+       code quitting after placing the new overlay but before it's
+       recorded on the list.  Select the window where isearch was
+       activated, to highlight matches in the right window when isearch
+       switches the current window to the minibuffer.
+
+       * international/isearch-x.el
+       (isearch-process-search-multibyte-characters):
+       Use `isearch-message' as initial input for `read-string' instead
+       of adding it to the minibuffer prompt.  After reading a string
+       remove the initial value of `isearch-message' from the string.
+
+       * replace.el (replace-match-maybe-edit): Doc fix.
+       (perform-replace): Don't call `replace-highlight' when automatic
+       replacement is requested in literal mode, since it is intended
+       only to highlight words during entering a new replacement string
+       for \? in non-literal mode.
+
+       * replace.el (query-replace-highlight): Add new value `isearch'
+       that allows query replacement to use isearch highlighting.
+       Change type from `boolean' to `choice'.  Doc fix.
+       (replace-highlight, replace-dehighlight, perform-replace):
+       Use isearch highlighting if query-replace-highlight eq `isearch'.
+
 2004-12-11  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/checkdoc.el (checkdoc-continue, checkdoc-comments)
index 933a0004ce20a9bbc9f6e26e5e01d45057a06ebd..646f693cd7f236da94392df19c30d9386e0ae77f 100644 (file)
@@ -1281,6 +1281,8 @@ make, or the user didn't cancel the call."
        ;; (match-data); otherwise it is t if a match is possible at point.
        (match-again t)
 
+       (isearch-string isearch-string)
+       (isearch-regexp isearch-regexp)
        (message
         (if query-flag
             (substitute-command-keys
@@ -1313,6 +1315,10 @@ make, or the user didn't cancel the call."
                                    (if regexp-flag from-string
                                      (regexp-quote from-string))
                                    "\\b")))
+    (if (eq query-replace-highlight 'isearch)
+       (setq isearch-string search-string
+             isearch-regexp regexp-flag))
+
     (push-mark)
     (undo-boundary)
     (unwind-protect
@@ -1528,7 +1534,14 @@ make, or the user didn't cancel the call."
                         (setq unread-command-events
                               (append (listify-key-sequence key)
                                       unread-command-events))
-                        (setq done t))))
+                        (setq done t)))
+                 (when (eq query-replace-highlight 'isearch)
+                   ;; Force isearch rehighlighting
+                   (if (not (memq def '(skip backup)))
+                       (setq isearch-lazy-highlight-last-string nil))
+                   ;; Restore isearch data in case of isearching during edit
+                   (setq isearch-string search-string
+                         isearch-regexp regexp-flag)))
                ;; Record previous position for ^ when we move on.
                ;; Change markers to numbers in the match data
                ;; since lots of markers slow down editing.
@@ -1563,27 +1576,38 @@ make, or the user didn't cancel the call."
                 (if (= replace-count 1) "" "s")))
     (and keep-going stack)))
 
-(defcustom query-replace-highlight t
-  "*Non-nil means to highlight words during query replacement."
-  :type 'boolean
+(defcustom query-replace-highlight
+  (if (and search-highlight isearch-lazy-highlight) 'isearch t)
+  "*Non-nil means to highlight words during query replacement.
+If `isearch', use isearch highlighting for query replacement."
+  :type '(choice (const :tag "Highlight" t)
+                 (const :tag "No highlighting" nil)
+                 (const :tag "Isearch highlighting" 'isearch))
   :group 'matching)
 
 (defvar replace-overlay nil)
 
 (defun replace-dehighlight ()
-  (and replace-overlay
-       (progn
-        (delete-overlay replace-overlay)
-        (setq replace-overlay nil))))
+  (cond ((eq query-replace-highlight 'isearch)
+        (isearch-dehighlight t)
+        (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup)
+        (setq isearch-lazy-highlight-last-string nil))
+       (query-replace-highlight
+        (when replace-overlay
+          (delete-overlay replace-overlay)
+          (setq replace-overlay nil)))))
 
 (defun replace-highlight (start end)
-  (and query-replace-highlight
-       (if replace-overlay
-          (move-overlay replace-overlay start end (current-buffer))
-        (setq replace-overlay (make-overlay start end))
-        (overlay-put replace-overlay 'face
-                     (if (facep 'query-replace)
-                         'query-replace 'region)))))
+  (cond ((eq query-replace-highlight 'isearch)
+        (isearch-highlight start end)
+        (isearch-lazy-highlight-new-loop))
+       (query-replace-highlight
+        (if replace-overlay
+            (move-overlay replace-overlay start end (current-buffer))
+          (setq replace-overlay (make-overlay start end))
+          (overlay-put replace-overlay 'face
+                       (if (facep 'query-replace)
+                           'query-replace 'region))))))
 
 ;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4
 ;;; replace.el ends here