From a8e0e1202809c9de3c4ef7d8ffbbd5433965b06d Mon Sep 17 00:00:00 2001 From: alex-eg Date: Fri, 12 Aug 2022 12:46:58 +0300 Subject: [PATCH] Advice string-replace to use region instead of TM --- emacs/.emacs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/emacs/.emacs b/emacs/.emacs index 0c44591..7369992 100755 --- a/emacs/.emacs +++ b/emacs/.emacs @@ -194,3 +194,23 @@ (let ((beg (if region (region-beginning) beg)) (end (if region (region-end) end))) (pulse-momentary-highlight-region beg end 'region)))) + +(define-advice perform-replace (:around (original-fun + from-string replacements + query-flag regexp-flag + delimited-flag + &optional repeat-count + map start end + backward + region-noncontiguous-p) + activate-region) + (let ((beg (region-beginning)) + (end (region-end))) + (pulse-momentary-highlight-region beg end 'region) + (apply original-fun from-string replacements + query-flag regexp-flag + delimited-flag + repeat-count + map beg end + backward + region-noncontiguous-p)))