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

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

[nongnu] elpa/iedit 90ef2d5ac9 064/301: Add digit prefix argment 0 to en


From: ELPA Syncer
Subject: [nongnu] elpa/iedit 90ef2d5ac9 064/301: Add digit prefix argment 0 to enable restricting match in a function
Date: Mon, 10 Jan 2022 22:58:51 -0500 (EST)

branch: elpa/iedit
commit 90ef2d5ac9ca10f28f175d11867eb2ea02ef33af
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>

    Add digit prefix argment 0 to enable restricting match in a function
---
 README   |  2 +-
 iedit.el | 37 +++++++++++++++++++++++++------------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/README b/README
index a23c9bbca6..deb129685e 100644
--- a/README
+++ b/README
@@ -8,7 +8,7 @@ Most common scenario of using this package is renaming 
refactoring
 during programming.  Several enhancements are done to make it easier:
  - The symbol under point can be selected as occurrence by one key and only 
complete
    symbols are matched
- - Restrict symbols in current defun only by one command
+ - Restricting symbols in current function matched could be done by one command
  - Remember the renaming refactoring and re-apply to other buffers later
 
 This package also provides rectangle support with visible rectangle
diff --git a/iedit.el b/iedit.el
index f297eae436..e15842d2b4 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-02-24 01:23:14 Victor Ren>
+;; Time-stamp: <2012-02-25 00:37:29 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region replace simultaneous
 ;; Version: 0.94
@@ -356,12 +356,13 @@ occurrences simultaneously.
 
 If Transient Mark mode is disabled or the region is not active,
 the current symbol (returns from `current-word') is used as the
-occurrence by default.  The occurrences of the current
-symbol, but not include occurrences that are part of other
-symbols, are highlighted.  This is good for renaming refactoring
-during programming.  If you still want to match all the
-occurrences, even though they are parts of other symbols, you may
-have to select the symbol first.
+occurrence by default.  The occurrences of the current symbol,
+but not include occurrences that are part of other symbols, are
+highlighted.  With digit prefix argument 0, only symbols in
+current function are matched.  This is good for renaming
+refactoring during programming.  If you still want to match all
+the occurrences, even though they are parts of other symbols, you
+may have to select the symbol first.
 
 You can also switch to iedit mode from isearch mode directly. The
 current search string is used as occurrence.  All occurrences of
@@ -402,7 +403,9 @@ Commands:
               (iedit-restrict-region beg end arg)
               (iedit-first-occurrence)))
         (iedit-done))
-    (let (occurrence complete-symbol rect-string)
+    (let (occurrence complete-symbol rect-string
+                     (beg (point-min))
+                     (end (point-max)))
       (cond ((and arg
                   (or (not transient-mark-mode) (not mark-active)
                       (equal (mark) (point))))
@@ -414,6 +417,16 @@ Commands:
                          iedit-last-initial-string-global)
                     (setq occurrence iedit-last-initial-string-global)
                     (setq complete-symbol iedit-only-complete-symbol-global))
+                   ((and (= 0 (prefix-numeric-value arg))
+                         iedit-current-symbol-default
+                         (current-word t))
+                    (setq occurrence  (current-word))
+                    (when iedit-only-at-symbol-boundaries
+                      (setq complete-symbol t))
+                    (save-excursion
+                      (mark-defun)
+                      (setq beg (region-beginning))
+                      (setq end (region-end))))
                    (t (error "No candidate of the occurrence, cannot enable 
iedit mode."))))
             ((and arg
                   transient-mark-mode mark-active (not (equal (mark) (point))))
@@ -438,15 +451,15 @@ Commands:
             (iedit-rectangle-start beg end))
         (deactivate-mark)
         (setq iedit-case-sensitive-local iedit-case-sensitive-default)
-        (iedit-start occurrence)))))
+        (iedit-start occurrence beg end)))))
 
-(defun iedit-start (occurrence-exp)
+(defun iedit-start (occurrence-exp beg end)
   "Start an iedit for the occurrence-exp in the current buffer."
   (setq iedit-unmatched-lines-invisible 
iedit-unmatched-lines-invisible-default)
   (setq iedit-aborting nil)
   (setq iedit-rectangle nil)
   (setq iedit-current-keymap iedit-occurrence-keymap)
-  (iedit-refresh occurrence-exp (point-min) (point-max))
+  (iedit-refresh occurrence-exp beg end)
   (run-hooks 'iedit-mode-hook)
   ;; (add-hook 'mouse-leave-buffer-hook 'iedit-done)
   (add-hook 'kbd-macro-termination-hook 'iedit-done))
@@ -1009,7 +1022,7 @@ Return nil if occurrence string is empty string."
   (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
   (deactivate-mark)
   (iedit-show-all)
-  (iedit-cleanup-occurrences-overlays beg end arg)
+  (iedit-cleanup-occurrences-overlays beg end inclusive)
   (if iedit-unmatched-lines-invisible
       (iedit-hide-unmatched-lines iedit-occurrence-context-lines))
   (setq iedit-mode (propertize



reply via email to

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