[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu e782725f80 162/288: Support case sensitive highlighti
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu e782725f80 162/288: Support case sensitive highlighting |
Date: |
Thu, 6 Jan 2022 03:58:49 -0500 (EST) |
branch: elpa/anzu
commit e782725f80c79778690d5a0f4ba9ed0afff13e27
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Support case sensitive highlighting
---
anzu.el | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/anzu.el b/anzu.el
index 8b078e5dd9..de77b864fa 100644
--- a/anzu.el
+++ b/anzu.el
@@ -308,9 +308,8 @@
(set-marker m beg buf)
(push m anzu--replaced-markers)))
-(defun anzu--add-overlay (regexp beg end)
+(defun anzu--add-overlay (beg end)
(let ((ov (make-overlay beg end)))
- (overlay-put ov 'from-regexp regexp)
(overlay-put ov 'from-string (buffer-substring-no-properties beg end))
(overlay-put ov 'face 'anzu-replace-highlight)
(overlay-put ov 'anzu-replace t)))
@@ -349,7 +348,7 @@
(when (and (>= beg overlay-beg) (<= end overlay-end) (not
finish))
(cl-incf overlayed)
(anzu--set-marker beg buf)
- (anzu--add-overlay str beg end))))
+ (anzu--add-overlay beg end))))
(setq anzu--cached-count count)
overlayed))))))
@@ -443,9 +442,8 @@
((and (consp compiled) (stringp (car compiled)))
(car compiled)))))
-(defun anzu--evaluate-occurrence (ov to-regexp replacements)
- (let ((from-regexp (overlay-get ov 'from-regexp))
- (from-string (overlay-get ov 'from-string))
+(defun anzu--evaluate-occurrence (ov to-regexp replacements fixed-case
from-regexp)
+ (let ((from-string (overlay-get ov 'from-string))
(compiled (anzu--compile-replace-text to-regexp)))
(with-temp-buffer
(insert from-string)
@@ -454,8 +452,8 @@
(or (ignore-errors
(if (consp compiled)
(replace-match (funcall (car compiled) (cdr compiled)
- replacements) t)
- (replace-match compiled t))
+ replacements) fixed-case)
+ (replace-match compiled fixed-case))
(buffer-substring (point-min) (point-max)))
"")))))
@@ -472,19 +470,27 @@
(let ((separator (or anzu-replace-to-string-separator "")))
(propertize (concat separator str) 'face 'anzu-replace-to)))
-(defun anzu--append-replaced-string (buf beg end use-regexp overlay-limit)
+(defsubst anzu--replaced-literal-string (ov replaced from)
+ (let ((str (buffer-substring-no-properties
+ (overlay-start ov) (overlay-end ov))))
+ (when (string-match str from)
+ (replace-match replaced (not case-fold-search) nil str))))
+
+(defun anzu--append-replaced-string (buf beg end use-regexp overlay-limit from)
(let ((content (minibuffer-contents))
(replacements 0))
(unless (string= content anzu--last-replace-input)
(setq anzu--last-replace-input content)
(with-current-buffer buf
- (dolist (ov (anzu--overlays-in-range beg (min end overlay-limit)))
- (let ((replace-evaled (and use-regexp (anzu--evaluate-occurrence
- ov content replacements))))
- (if replace-evaled
- (cl-incf replacements)
- (setq replace-evaled content))
- (overlay-put ov 'after-string (anzu--propertize-to-string
replace-evaled))))))))
+ (let ((case-fold-search (anzu--case-fold-search from)))
+ (dolist (ov (anzu--overlays-in-range beg (min end overlay-limit)))
+ (let ((replace-evaled
+ (if (not use-regexp)
+ (anzu--replaced-literal-string ov content from)
+ (prog1 (anzu--evaluate-occurrence ov content replacements
+ (not case-fold-search)
from)
+ (cl-incf replacements)))))
+ (overlay-put ov 'after-string (anzu--propertize-to-string
replace-evaled)))))))))
(defsubst anzu--outside-overlay-limit (orig-beg orig-limit)
(save-excursion
@@ -512,7 +518,7 @@
(with-selected-window (or
(active-minibuffer-window)
(minibuffer-window))
(anzu--append-replaced-string
- curbuf beg end use-regexp overlay-limit))))))
+ curbuf beg end use-regexp overlay-limit
from))))))
(prog1 (read-from-minibuffer to-prompt
nil nil nil
query-replace-from-history-variable nil
t)
- [nongnu] elpa/anzu 14e4483a5e 286/288: Add ability to use lax whitespace (#119), (continued)
- [nongnu] elpa/anzu 14e4483a5e 286/288: Add ability to use lax whitespace (#119), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 420f0c6894 137/288: Merge pull request #29 from bbatsov/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu cb70e6c611 145/288: Fix wrong counting total matched number when used default input, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b600df38cb 144/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ec0d1f5485 147/288: Merge pull request #33 from syohex/fix-replace-command-bugs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ab561fe896 151/288: Use symbol-value instead of eval-when-compile + defvar, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 439e904931 155/288: Enable case-sensitive replacement for at cursor commands, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 686b264468 158/288: Refactoring: better getting migemo variable, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu e664721a7f 157/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 137fc52ca2 159/288: Merge pull request #37 from syohex/improve-for-migemo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu e782725f80 162/288: Support case sensitive highlighting,
ELPA Syncer <=
- [nongnu] elpa/anzu cf3370967b 170/288: Refactoring for evil-anzu, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 53db7f64b7 177/288: Reduce condition check, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu cb20bdcbfe 167/288: Merge pull request #40 from syohex/improve-replace-command, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b723c16507 172/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu db819bfb06 184/288: Merge pull request #47 from syohex/fix-46, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 4d81f2f0cd 192/288: Fix order of conditions in cond, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f41db6225d 194/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 07b7802d9d 212/288: Fix literal replace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b11642d49c 207/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 88a7059601 236/288: Implement isearch-query-replace- like commands, ELPA Syncer, 2022/01/06