[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 14e4483a5e 286/288: Add ability to use lax whitespace
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 14e4483a5e 286/288: Add ability to use lax whitespace (#119) |
Date: |
Thu, 6 Jan 2022 03:59:01 -0500 (EST) |
branch: elpa/anzu
commit 14e4483a5e708097870b22ac56ea693ec1d893bf
Author: okamsn <28612288+okamsn@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Add ability to use lax whitespace (#119)
* Support non contiguous regions like rectangle region
* Fix literal replacements with lax whitespace.
* Use ‘search-replace-regexp’ in Anzu.
Co-authored-by: Shohei YOSHIDA <syohex@gmail.com>
Co-authored-by: okamsn <>
---
anzu.el | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/anzu.el b/anzu.el
index 28abbc5f9b..4601873648 100644
--- a/anzu.el
+++ b/anzu.el
@@ -387,12 +387,24 @@
thereis (and (>= beg b overlay-beg) (<= end e overlay-end)))
(and (>= beg overlay-beg) (<= end overlay-end))))
+(defun anzu--convert-for-lax-whitespace (str use-regexp)
+ (if use-regexp
+ (if replace-regexp-lax-whitespace
+ (replace-regexp-in-string "\\s-+" search-whitespace-regexp str
+ nil t)
+ str)
+ (if replace-lax-whitespace
+ (replace-regexp-in-string "\\s-+"
+ search-whitespace-regexp
+ (regexp-quote str)
+ nil t)
+ (regexp-quote str))))
+
;; Return highlighted count
(defun anzu--count-and-highlight-matched (buf str replace-beg replace-end
use-regexp overlay-limit
case-sensitive)
(anzu--cleanup-markers)
- (when (not use-regexp)
- (setq str (regexp-quote str)))
+ (setq str (anzu--convert-for-lax-whitespace str use-regexp))
(if (not (anzu--validate-regexp str))
anzu--cached-count
(with-current-buffer buf
@@ -592,7 +604,9 @@
(defsubst anzu--replaced-literal-string (ov replaced from)
(let ((str (buffer-substring-no-properties
(overlay-start ov) (overlay-end ov))))
- (when (string-match (regexp-quote str) from)
+ ;; Needed to do `(string-match from str)' instead of `(string-match str
from)',
+ ;; because lax whitespace means `from' can be a regexp.
+ (when (string-match from str)
(replace-match replaced (not case-fold-search) t str))))
(defun anzu--append-replaced-string (content buf beg end use-regexp
overlay-limit from)
@@ -600,13 +614,14 @@
(unless (string= content anzu--last-replace-input)
(setq anzu--last-replace-input content)
(with-current-buffer buf
- (let ((case-fold-search (anzu--case-fold-search)))
+ (let ((case-fold-search (anzu--case-fold-search))
+ (pattern (anzu--convert-for-lax-whitespace from use-regexp)))
(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)
+ (anzu--replaced-literal-string ov content pattern)
(prog1 (anzu--evaluate-occurrence ov content replacements
- (not case-fold-search)
from)
+ (not case-fold-search)
pattern)
(cl-incf replacements)))))
(overlay-put ov 'after-string (anzu--propertize-to-string
replace-evaled)))))))))
- [nongnu] elpa/anzu 11544ea75c 242/288: Consider user's case-fold-search, (continued)
- [nongnu] elpa/anzu 11544ea75c 242/288: Consider user's case-fold-search, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 42996934e2 239/288: Change syntax for bindings, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu dad14fa96c 244/288: Use h5 header for interfaces, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 324c3e2db4 245/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 3328619fec 251/288: Update Changes and bump up version, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 5cf1c7c16e 238/288: Merge pull request #72 from syohex/isearch-query-replace-api, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu a1860f4c53 267/288: update url, copyright, and maintainer name, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 896b2be2eb 281/288: Wordsmith the documentation re *-thing functions (#111), ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 33e4f13429 287/288: migrate tests from circleci to github actions, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 13dadaed10 284/288: update circleci to new docker images, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 14e4483a5e 286/288: Add ability to use lax whitespace (#119),
ELPA Syncer <=
- [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, 2022/01/06