aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorMiles Bader2004-12-14 07:34:55 +0000
committerMiles Bader2004-12-14 07:34:55 +0000
commitdce59e79ab8a6ecc869ceda44d579b8b1e8e10d5 (patch)
treec3da6c32ac0401833eb29b6a4be9cf93febf248e /lisp/replace.el
parent56cc8ca9b68886dc4aae4c8ef44ad5e62b59db49 (diff)
parent734c576596678065b39591128d88609bc6fc5aad (diff)
downloademacs-dce59e79ab8a6ecc869ceda44d579b8b1e8e10d5.tar.gz
emacs-dce59e79ab8a6ecc869ceda44d579b8b1e8e10d5.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-78
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-719 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-732 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-733 Update from CVS: man/calc.texi: Fix some TeX definitions. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-734 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-75 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-76 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-77 Update from CVS
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el58
1 files changed, 41 insertions, 17 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 8a5c0a9680c..646f693cd7f 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1214,7 +1214,7 @@ but coerced to the correct value of INTEGERS."
1214 1214
1215(defun replace-match-maybe-edit (newtext fixedcase literal noedit match-data) 1215(defun replace-match-maybe-edit (newtext fixedcase literal noedit match-data)
1216 "Make a replacement with `replace-match', editing `\\?'. 1216 "Make a replacement with `replace-match', editing `\\?'.
1217NEXTEXT, FIXEDCASE, LITERAL are just passed on. If NOEDIT is true, no 1217NEWTEXT, FIXEDCASE, LITERAL are just passed on. If NOEDIT is true, no
1218check for `\\?' is made to save time. MATCH-DATA is used for the 1218check for `\\?' is made to save time. MATCH-DATA is used for the
1219replacement. In case editing is done, it is changed to use markers. 1219replacement. In case editing is done, it is changed to use markers.
1220 1220
@@ -1281,6 +1281,8 @@ make, or the user didn't cancel the call."
1281 ;; (match-data); otherwise it is t if a match is possible at point. 1281 ;; (match-data); otherwise it is t if a match is possible at point.
1282 (match-again t) 1282 (match-again t)
1283 1283
1284 (isearch-string isearch-string)
1285 (isearch-regexp isearch-regexp)
1284 (message 1286 (message
1285 (if query-flag 1287 (if query-flag
1286 (substitute-command-keys 1288 (substitute-command-keys
@@ -1313,6 +1315,10 @@ make, or the user didn't cancel the call."
1313 (if regexp-flag from-string 1315 (if regexp-flag from-string
1314 (regexp-quote from-string)) 1316 (regexp-quote from-string))
1315 "\\b"))) 1317 "\\b")))
1318 (if (eq query-replace-highlight 'isearch)
1319 (setq isearch-string search-string
1320 isearch-regexp regexp-flag))
1321
1316 (push-mark) 1322 (push-mark)
1317 (undo-boundary) 1323 (undo-boundary)
1318 (unwind-protect 1324 (unwind-protect
@@ -1380,7 +1386,7 @@ make, or the user didn't cancel the call."
1380 (if (not query-flag) 1386 (if (not query-flag)
1381 (let ((inhibit-read-only 1387 (let ((inhibit-read-only
1382 query-replace-skip-read-only)) 1388 query-replace-skip-read-only))
1383 (unless noedit 1389 (unless (or literal noedit)
1384 (replace-highlight (nth 0 real-match-data) 1390 (replace-highlight (nth 0 real-match-data)
1385 (nth 1 real-match-data))) 1391 (nth 1 real-match-data)))
1386 (setq noedit 1392 (setq noedit
@@ -1528,7 +1534,14 @@ make, or the user didn't cancel the call."
1528 (setq unread-command-events 1534 (setq unread-command-events
1529 (append (listify-key-sequence key) 1535 (append (listify-key-sequence key)
1530 unread-command-events)) 1536 unread-command-events))
1531 (setq done t)))) 1537 (setq done t)))
1538 (when (eq query-replace-highlight 'isearch)
1539 ;; Force isearch rehighlighting
1540 (if (not (memq def '(skip backup)))
1541 (setq isearch-lazy-highlight-last-string nil))
1542 ;; Restore isearch data in case of isearching during edit
1543 (setq isearch-string search-string
1544 isearch-regexp regexp-flag)))
1532 ;; Record previous position for ^ when we move on. 1545 ;; Record previous position for ^ when we move on.
1533 ;; Change markers to numbers in the match data 1546 ;; Change markers to numbers in the match data
1534 ;; since lots of markers slow down editing. 1547 ;; since lots of markers slow down editing.
@@ -1563,27 +1576,38 @@ make, or the user didn't cancel the call."
1563 (if (= replace-count 1) "" "s"))) 1576 (if (= replace-count 1) "" "s")))
1564 (and keep-going stack))) 1577 (and keep-going stack)))
1565 1578
1566(defcustom query-replace-highlight t 1579(defcustom query-replace-highlight
1567 "*Non-nil means to highlight words during query replacement." 1580 (if (and search-highlight isearch-lazy-highlight) 'isearch t)
1568 :type 'boolean 1581 "*Non-nil means to highlight words during query replacement.
1582If `isearch', use isearch highlighting for query replacement."
1583 :type '(choice (const :tag "Highlight" t)
1584 (const :tag "No highlighting" nil)
1585 (const :tag "Isearch highlighting" 'isearch))
1569 :group 'matching) 1586 :group 'matching)
1570 1587
1571(defvar replace-overlay nil) 1588(defvar replace-overlay nil)
1572 1589
1573(defun replace-dehighlight () 1590(defun replace-dehighlight ()
1574 (and replace-overlay 1591 (cond ((eq query-replace-highlight 'isearch)
1575 (progn 1592 (isearch-dehighlight t)
1576 (delete-overlay replace-overlay) 1593 (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup)
1577 (setq replace-overlay nil)))) 1594 (setq isearch-lazy-highlight-last-string nil))
1595 (query-replace-highlight
1596 (when replace-overlay
1597 (delete-overlay replace-overlay)
1598 (setq replace-overlay nil)))))
1578 1599
1579(defun replace-highlight (start end) 1600(defun replace-highlight (start end)
1580 (and query-replace-highlight 1601 (cond ((eq query-replace-highlight 'isearch)
1581 (if replace-overlay 1602 (isearch-highlight start end)
1582 (move-overlay replace-overlay start end (current-buffer)) 1603 (isearch-lazy-highlight-new-loop))
1583 (setq replace-overlay (make-overlay start end)) 1604 (query-replace-highlight
1584 (overlay-put replace-overlay 'face 1605 (if replace-overlay
1585 (if (facep 'query-replace) 1606 (move-overlay replace-overlay start end (current-buffer))
1586 'query-replace 'region))))) 1607 (setq replace-overlay (make-overlay start end))
1608 (overlay-put replace-overlay 'face
1609 (if (facep 'query-replace)
1610 'query-replace 'region))))))
1587 1611
1588;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 1612;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4
1589;;; replace.el ends here 1613;;; replace.el ends here