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

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

[nongnu] elpa/iedit 52c4865e5b 197/301: Add special prefix argument 1


From: ELPA Syncer
Subject: [nongnu] elpa/iedit 52c4865e5b 197/301: Add special prefix argument 1
Date: Mon, 10 Jan 2022 22:59:02 -0500 (EST)

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

    Add special prefix argument 1
    
    With digital prefix argument 1, Iedit mode is limited on the
    current symbol or the active region, which means just one
    instance is highlighted.  This behavior serves as a start point
    of incremental selection work flow.
---
 iedit-lib.el |  5 +++--
 iedit.el     | 36 +++++++++++++++++++++++++-----------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/iedit-lib.el b/iedit-lib.el
index 70b34ff869..8c0f70b7f0 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2016-05-24 10:36:51 Victor Ren>
+;; Time-stamp: <2016-06-08 10:44:42 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.97
@@ -888,7 +888,8 @@ it just means mark is active."
   (and (if iedit-transient-mark-sensitive
            transient-mark-mode
          t)
-       mark-active (not (equal (mark) (point)))))
+       mark-active
+       (not (equal (mark) (point)))))
 
 (defun iedit-barf-if-lib-active()
   "Signal error if Iedit lib is active."
diff --git a/iedit.el b/iedit.el
index bb9c93d712..3b722ddf49 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2016-05-30 09:51:08 Victor Ren>
+;; Time-stamp: <2016-06-08 10:58:11 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous refactoring
 ;; Version: 0.97
@@ -310,6 +310,11 @@ Iedit mode is turned off last time (might be in other 
buffer) is
 used as occurrence.  If region active, Iedit mode is limited
 within the current region.
 
+With digital prefix argument 1, Iedit mode is limited on the
+current symbol or the active region, which means just one
+instance is highlighted.  This behavior serves as a start point
+of incremental selection work flow.
+
 If Iedit mode is on and region is active, Iedit mode is
 restricted in the region, e.g. the occurrences outside of the
 region is excluded.
@@ -336,6 +341,7 @@ Keymap used within overlays:
                    (next-single-char-property-change 1 'read-only)
                  (point-min)))
           (end (point-max)))
+      ;; Get the occurrence
       (cond ((and arg
                   (= 4 (prefix-numeric-value arg))
                   iedit-last-occurrence-local)
@@ -354,15 +360,21 @@ Keymap used within overlays:
              (when iedit-only-at-symbol-boundaries
                (setq complete-symbol t)))
             (t (error "No candidate of the occurrence, cannot enable Iedit 
mode")))
+      ;; Get the scope
       (when arg
-        (if (= 0 (prefix-numeric-value arg))
-            (save-excursion
-              (mark-defun)
-              (setq beg (region-beginning))
-              (setq end (region-end)))
-          (when (iedit-region-active)
-            (setq beg (region-beginning))
-            (setq end (region-end)))))
+        (cond ((= 0 (prefix-numeric-value arg))
+               (save-excursion
+                 (mark-defun)
+                 (setq beg (region-beginning))
+                 (setq end (region-end))))
+              ((and (= 1 (prefix-numeric-value arg))
+                    (not (iedit-region-active)))
+               (let ((region (bounds-of-thing-at-point 'symbol)))
+                 (setq beg (car region))
+                 (setq end (cdr region))))
+              ((iedit-region-active)
+                (setq beg (region-beginning))
+                (setq end (region-end)))))
       (setq iedit-only-complete-symbol-local complete-symbol)
       (setq mark-active nil)
       (run-hooks 'deactivate-mark-hook)
@@ -591,7 +603,8 @@ prefix, bring the bottom of the region back up one 
occurrence."
       (progn (iedit-restrict-region
               (iedit-first-occurrence)
               (1- (iedit-last-occurrence)))
-             (goto-char (iedit-last-occurrence)))
+             (when iedit-mode
+               (goto-char (iedit-last-occurrence))))
   (iedit-expand-to-occurrence t)))
 
 (defun iedit-expand-up-to-occurrence (&optional arg)
@@ -603,7 +616,8 @@ prefix, bring the top of the region back down one 
occurrence."
       (progn (iedit-restrict-region
               (1+ (iedit-first-occurrence))
               (+ (iedit-occurrence-string-length) (iedit-last-occurrence)))
-             (goto-char (iedit-first-occurrence)))
+             (when iedit-mode
+               (goto-char (iedit-first-occurrence))))
     (iedit-expand-to-occurrence nil)))
 
 (defun iedit-expand-to-occurrence (forward)



reply via email to

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