emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/iedit 4864e17126 010/301: Merge remote-tracking branch 'ts


From: ELPA Syncer
Subject: [nongnu] elpa/iedit 4864e17126 010/301: Merge remote-tracking branch 'tsdh/master'
Date: Mon, 10 Jan 2022 22:58:45 -0500 (EST)

branch: elpa/iedit
commit 4864e17126bd952995ecec55fa056b1351a1efc5
Merge: 69d6c03e06 8e87f353fe
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>

    Merge remote-tracking branch 'tsdh/master'
---
 iedit.el | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/iedit.el b/iedit.el
index f8a9074b6b..360f738fd5 100644
--- a/iedit.el
+++ b/iedit.el
@@ -4,6 +4,7 @@
 
 ;; Time-stamp: <2012-01-14 23:12:48 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
+;; Contributors: Tassilo Horn <tassilo@member.fsf.org>
 ;; Keywords: occurrence region replace simultaneous
 ;; Version: 0.90
 ;; X-URL: http://www.emacswiki.org/emacs/iedit.el
@@ -30,7 +31,7 @@
 ;; This package provides a more intuitive way of replace-string operation:
 ;;
 ;; - Select the occurrence in the buffer
-;;   In Transient Mark mode, just mark a region, the content of the 
+;;   In Transient Mark mode, just mark a region, the content of the
 ;;   region will be used as the occurrence. (if Transient Mark mode is 
disabled,
 ;;   using C-u C-x C-x or C-SPC C-SPC to activate it just for this one time).
 ;;
@@ -90,6 +91,14 @@
   :type 'boolean
   :group 'iedit)
 
+(defcustom iedit-only-at-word-boundaries t
+  "If no-nil, matches have to start and end at work boundaries.
+  For example, when invoking iedit-mode on the \"in\" in the
+  sentence \"The king in the castle...\", the \"king\" is not
+  edited."
+  :type 'boolean
+  :group 'iedit)
+
 (defcustom iedit-unmatched-lines-invisible-default nil
   "If no-nil, hide lines that do not cover any occurrences by
 default."
@@ -108,7 +117,7 @@ default."
 
 (or (assq 'iedit-mode minor-mode-alist)
     (nconc minor-mode-alist
-           (list '(iedit-mode iedit-mode))))
+          (list '(iedit-mode iedit-mode))))
 
 (defvar iedit-occurrences-overlays nil
   "The occurrences slot contains a list of overlays used to
@@ -262,8 +271,8 @@ Commands:
       (deactivate-mark)
       (iedit-start occurrence))))
 
-(defun iedit-start (occurrence-exp)
-  "Start an iedit for the occurrence-exp in the current buffer."
+(defun iedit-start (occurrence)
+  "Start an iedit for the occurrence in the current buffer."
   (setq        iedit-mode " Iedit")
   (setq iedit-occurrences-overlays nil)
   (setq iedit-unmatched-lines-invisible 
iedit-unmatched-lines-invisible-default)
@@ -274,18 +283,21 @@ Commands:
   (add-hook 'kbd-macro-termination-hook 'iedit-done)
   ;; Find and record each occurrence's markers and add the overlay to the 
occurrences
   (let ((counter 0)
-        (case-fold-search (not iedit-case-sensitive)))
+        (case-fold-search (not iedit-case-sensitive))
+       (occurrence-exp (regexp-quote occurrence)))
   (save-excursion
+    (when iedit-only-at-word-boundaries
+      (setq occurrence-exp (concat "\\<" occurrence-exp "\\>")))
     (goto-char (point-min))
-    (while (search-forward occurrence-exp nil t)
+    (while (re-search-forward occurrence-exp nil t)
       (push (iedit-make-occurrence-overlay (match-beginning 0) (match-end 0))
             iedit-occurrences-overlays)
       (setq counter (1+ counter)))      ; at less 1
       (setq iedit-occurrences-overlays (nreverse iedit-occurrences-overlays))
       (if iedit-unmatched-lines-invisible
           (iedit-hide-unmatched-lines))
-      (message "%d matches for \"%s\"" 
-               counter 
+      (message "%d matches for \"%s\""
+               counter
                (if (> (length occurrence-exp) 50)
                    (concat (substring occurrence-exp 0 50) "...")
                  occurrence-exp)))))
@@ -314,8 +326,8 @@ Commands:
 (defun iedit-done ()
   "Exit iedit mode."
   (let ((ov (car iedit-occurrences-overlays)))
-    (if ov 
-        (setq iedit-last-occurrence-in-history 
+    (if ov
+        (setq iedit-last-occurrence-in-history
               (buffer-substring (overlay-start ov) (overlay-end ov)))))
   (remove-overlays (point-min) (point-max) iedit-occurrence-overlay-name t)
   (remove-overlays (point-min) (point-max) iedit-invisible-overlay-name t)
@@ -375,13 +387,13 @@ beginning of the buffer."
     (when in-occurrence
       (setq pos  (next-single-char-property-change pos 
'iedit-occurrence-overlay-name)))
     (setq pos (next-single-char-property-change pos 
'iedit-occurrence-overlay-name))
-    
+
     (if (/= pos (point-max))
         (setq iedit-forward-success t)
       (if (and iedit-forward-success in-occurrence)
           (progn (message "This is the last occurrence.")
                  (setq iedit-forward-success nil))
-        (progn 
+        (progn
           (if (get-char-property (point-min) 'iedit-occurrence-overlay-name)
               (setq pos (point-min))
             (setq pos (next-single-char-property-change (point-min) 
'iedit-occurrence-overlay-name)))
@@ -404,12 +416,12 @@ the buffer."
     ;; At the start of the first occurrence
     (if (or (and (eq pos (point-min))
                  (not (get-char-property (point-min) 
'iedit-occurrence-overlay-name)))
-            (and (eq (point) (point-min)) 
+            (and (eq (point) (point-min))
                  in-occurrence))
         (if (and iedit-forward-success in-occurrence)
             (progn (message "This is the first occurrence.")
                    (setq iedit-forward-success nil))
-          (progn 
+          (progn
             (setq pos (previous-single-char-property-change (point-max) 
'iedit-occurrence-overlay-name))
             (if (not (get-char-property (- (point-max) 1) 
'iedit-occurrence-overlay-name))
                 (setq pos (previous-single-char-property-change pos 
'iedit-occurrence-overlay-name)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]