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

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

[nongnu] elpa/iedit 1c410fc2b8 101/301: Fix iedit-number-occurrences wit


From: ELPA Syncer
Subject: [nongnu] elpa/iedit 1c410fc2b8 101/301: Fix iedit-number-occurrences with conjointed occurrences problem
Date: Mon, 10 Jan 2022 22:58:54 -0500 (EST)

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

    Fix iedit-number-occurrences with conjointed occurrences problem
    Call ieit-move-conjointed-overlays
---
 iedit-lib.el  | 50 +++++++++++++++++++++++++-------------------------
 iedit-rect.el |  4 ++--
 iedit.el      |  4 ++--
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/iedit-lib.el b/iedit-lib.el
index 227483b407..9fa00694b5 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-08-09 17:17:42 Victor Ren>
+;; Time-stamp: <2012-08-10 09:26:34 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.97
@@ -278,8 +278,8 @@ there are."
           (lambda (left right)
             (< (overlay-start left) (overlay-start right)))))) ;; todo test 
this function
 
-(defun iedit-clearup ()
-  "Clear up occurrence overlay, invisible overlay and local variables."
+(defun iedit-cleanup ()
+  "Clean up occurrence overlay, invisible overlay and local variables."
   ;; (when iedit-buffering
   ;;     (iedit-stop-buffering))
   ;; (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
@@ -539,13 +539,10 @@ This function depends on the order of 
iedit-occurrences-overlays. TODO"
 ;;;; functions for overlay keymap
 (defun iedit-apply-on-occurrences (function &rest args)
   "Call function for each occurrence."
-  (let* ((ov (car iedit-occurrences-overlays))
-         (beg (overlay-start ov))
-         (end (overlay-end ov)))
-    (let ((inhibit-modification-hooks t))
+  (let ((inhibit-modification-hooks t))
       (save-excursion
         (dolist (occurrence iedit-occurrences-overlays)
-          (apply function (overlay-start occurrence) (overlay-end occurrence) 
args))))))
+          (apply function (overlay-start occurrence) (overlay-end occurrence) 
args)))))
 
 (defun iedit-upcase-occurrences ()
   "Covert occurrences to upper case."
@@ -625,17 +622,17 @@ be applied to other occurrences when buffering is off."
   "Stop buffering and apply the modification to other occurrences.
 If current point is not at any occurrence, the buffered
 modification is not going to be applied to other occurrences."
-  (let ((ov (iedit-find-current-occurrence-overlay))
-        (inhibit-modification-hooks t))
+  (let ((ov (iedit-find-current-occurrence-overlay)))
     (when ov
       (let* ((beg (overlay-start ov))
              (end (overlay-end ov))
              (modified-string (buffer-substring-no-properties beg end))
-             (offset (- (point) beg))) ;; delete-region moves cursor
+             (offset (- (point) beg)) ;; delete-region moves cursor
+             (inhibit-modification-hooks t))
         (when (not (string= iedit-before-modification-string modified-string))
           (save-excursion
-            ;; Rollback the current modification and buffer-undo-list. This is 
to
-            ;; avoid the inconsistency if user undoes modifications
+            ;; Rollback the current modification and buffer-undo-list. This is
+            ;; to avoid the inconsistency if user undoes modifications
             (delete-region beg end)
             (goto-char beg)
             (insert-and-inherit iedit-before-modification-string)
@@ -688,12 +685,13 @@ After modification, conjointed overlays may be 
overlapped."
                     (1- (+ (length iedit-occurrences-overlays) start-at)))))
           "d "))
 
-(defun iedit-number-occurrences (start-at &optional format)
+(defun iedit-number-occurrences (start-at &optional format-string)
   "Insert numbers in front of the occurrences.
 START-AT, if non-nil, should be a number from which to begin
 counting.  FORMAT, if non-nil, should be a format string to pass
-to `format' along with the line count.  When called interactively
-with a prefix argument, prompt for START-AT and FORMAT."
+to `format-string' along with the line count.  When called
+interactively with a prefix argument, prompt for START-AT and
+FORMAT."
   (interactive
    (if current-prefix-arg
        (let* ((start-at (read-number "Number to count from: " 1)))
@@ -702,15 +700,17 @@ with a prefix argument, prompt for START-AT and FORMAT."
                             (iedit-default-occurence-number-format
                              start-at))))
      (list  1 nil)))
-  (unless format
-    (setq format (iedit-default-occurence-number-format start-at)))
-  (let ((iedit-number-occurrence-counter start-at))
-    (iedit-apply-on-occurrences
-     (lambda (beg _end format-string)
-       (goto-char beg)
-       (insert (format format-string iedit-number-occurrence-counter))
-       (setq iedit-number-occurrence-counter
-             (1+ iedit-number-occurrence-counter))) format)))
+  (unless format-string
+    (setq format-string (iedit-default-occurence-number-format start-at)))
+  (let ((iedit-number-occurrence-counter start-at)
+        (inhibit-modification-hooks t))
+    (save-excursion
+      (dolist (occurrence iedit-occurrences-overlays)
+        (goto-char (overlay-start occurrence))
+        (insert (format format-string iedit-number-occurrence-counter))
+        (iedit-move-conjointed-overlays occurrence)
+        (setq iedit-number-occurrence-counter
+              (1+ iedit-number-occurrence-counter))))))
 
 
 ;;; help functions
diff --git a/iedit-rect.el b/iedit-rect.el
index 068d07ffd4..8c6bfca8f4 100644
--- a/iedit-rect.el
+++ b/iedit-rect.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-08-09 17:17:25 Victor Ren>
+;; Time-stamp: <2012-08-10 10:00:55 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.97
@@ -134,7 +134,7 @@ Save the current occurrence string locally and globally.  
Save
 the initial string globally."
   (when iedit-buffering
       (iedit-stop-buffering))
-  (iedit-clearup)
+  (iedit-cleanup)
   (setq iedit-rectangle-mode nil)
   (force-mode-line-update)
   (remove-hook 'kbd-macro-termination-hook 'iedit-rectangle-done t)
diff --git a/iedit.el b/iedit.el
index f0a7533779..fee2c4af43 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-08-09 17:08:52 Victor Ren>
+;; Time-stamp: <2012-08-10 10:00:31 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.97
@@ -314,7 +314,7 @@ the initial string globally."
   (setq iedit-last-initial-string-global iedit-initial-string-local)
   (setq iedit-case-sensitive-global iedit-case-sensitive-local)
 
-  (iedit-clearup)
+  (iedit-cleanup)
 
   (setq iedit-mode nil)
   (force-mode-line-update)



reply via email to

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