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

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

[nongnu] elpa/iedit 2f0c484817 283/301: Move iedit-buffering related to


From: ELPA Syncer
Subject: [nongnu] elpa/iedit 2f0c484817 283/301: Move iedit-buffering related to `iedit-lib'
Date: Mon, 10 Jan 2022 22:59:10 -0500 (EST)

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

    Move iedit-buffering related to `iedit-lib'
---
 iedit-lib.el | 47 ++++++++++++++++++++++++++++-------------------
 iedit.el     | 49 ++++++++++++++++---------------------------------
 2 files changed, 44 insertions(+), 52 deletions(-)

diff --git a/iedit-lib.el b/iedit-lib.el
index 1c388e49a7..f89f6e47f4 100755
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
 
 ;; Copyright (C) 2010 - 2019, 2020 Victor Ren
 
-;; Time-stamp: <2021-01-13 22:27:53 Victor Ren>
+;; Time-stamp: <2021-01-14 23:56:53 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.9.9.9
@@ -432,6 +432,11 @@ there are."
 
 (defun iedit-lib-start (mode-exit-func)
   "Initialize the hooks."
+  (when iedit-auto-buffering
+       (iedit-start-buffering))
+  ;; Enforce skip modification once, errors may happen to cause this to be
+  ;; unset.
+  (setq iedit-skip-modification-once t)
   (setq iedit-lib-quit-func mode-exit-func)
   (add-hook 'post-command-hook 'iedit-update-occurrences-2 nil t)
   (add-hook 'before-revert-hook iedit-lib-quit-func nil t)
@@ -441,11 +446,8 @@ there are."
 
 (defun iedit-lib-cleanup ()
   "Clean up occurrence overlay, invisible overlay and local variables."
+  (iedit-cleanup-occurrences-overlays)
   (remove-hook 'post-command-hook 'iedit-update-occurrences-2 t)
-  (remove-overlays nil nil iedit-occurrence-overlay-name t)
-  ;; Close overlays opened by `isearch-range-invisible'
-  (isearch-clean-overlays)
-  (iedit-show-all)
   (remove-hook 'before-revert-hook iedit-lib-quit-func t)
   (remove-hook 'kbd-macro-termination-hook iedit-lib-quit-func t)
   (remove-hook 'change-major-mode-hook iedit-lib-quit-func t)
@@ -1023,8 +1025,8 @@ modification is not going to be applied to other 
occurrences."
                                      (upcase modified-string))
                                     (cap-initial
                                      (if (= 0 offset)
-                                          (capitalize modified-string)
-                                       modified-string))
+                          (capitalize modified-string)
+                                               modified-string))
                                     (t modified-string))))
                 (iedit-move-conjoined-overlays occurrence))))
           (goto-char (+ (overlay-start ov) offset))))))
@@ -1139,18 +1141,25 @@ Return nil if occurrence string is empty string."
           (setq overlays (cdr overlays)))))
     found))
 
-(defun iedit-cleanup-occurrences-overlays (beg end &optional inclusive)
-  "Remove deleted overlays from list `iedit-occurrences-overlays'."
-  (if inclusive
-      (remove-overlays beg end iedit-occurrence-overlay-name t)
-    (remove-overlays (point-min) beg iedit-occurrence-overlay-name t)
-    (remove-overlays end (point-max) iedit-occurrence-overlay-name t))
-  (let (overlays)
-    (dolist (overlay iedit-occurrences-overlays)
-      (if (overlay-buffer overlay)
-          (push overlay overlays)))
-    (setq iedit-occurrences-overlays overlays)
-    (iedit-update-index)))
+(defun iedit-cleanup-occurrences-overlays (&optional beg end inclusive)
+  "Remove overlays from list `iedit-occurrences-overlays'."
+  (when iedit-buffering
+    (iedit-stop-buffering))
+  ;; Close overlays opened by `isearch-range-invisible'
+  (isearch-clean-overlays)
+  (iedit-show-all)
+  (if (null beg)
+         (remove-overlays nil nil iedit-occurrence-overlay-name t)
+       (if inclusive
+               (remove-overlays beg end iedit-occurrence-overlay-name t)
+      (remove-overlays (point-min) beg iedit-occurrence-overlay-name t)
+      (remove-overlays end (point-max) iedit-occurrence-overlay-name t))
+       (let (overlays)
+      (dolist (overlay iedit-occurrences-overlays)
+               (if (overlay-buffer overlay)
+                       (push overlay overlays)))
+      (setq iedit-occurrences-overlays overlays)
+      (iedit-update-index))))
 
 (defun iedit-printable (string)
   "Return a omitted substring that is not longer than 50.
diff --git a/iedit.el b/iedit.el
index edc1a8e212..641fb91dfc 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010 - 2019, 2020 Victor Ren
 
-;; Time-stamp: <2021-01-13 22:39:04 Victor Ren>
+;; Time-stamp: <2021-01-14 23:52:39 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous refactoring
 ;; Version: 0.9.9.9
@@ -466,9 +466,6 @@ Keymap used within overlays:
 
 (defun iedit-start (occurrence-regexp beg end)
   "Start Iedit mode for the `occurrence-regexp' in the current buffer."
-  ;; enforce skip modification once, errors may happen to cause this to be
-  ;; unset.
-  (setq iedit-skip-modification-once t)
   (setq iedit-initial-region (list beg end))
   (let ((counter 0))
     (if (eq iedit-occurrence-type-local 'markup-tag)
@@ -482,8 +479,6 @@ Keymap used within overlays:
              counter
              (iedit-printable occurrence-regexp))
     (setq iedit-mode t))
-  (when iedit-auto-buffering
-       (iedit-start-buffering))
   (iedit-lib-start 'iedit-done)
   (run-hooks 'iedit-mode-hook))
 
@@ -570,8 +565,6 @@ Return the tag if succeeded, nil if failed."
   "Exit Iedit mode.
 Save the current occurrence string locally and globally.  Save
 the initial string globally."
-  (when iedit-buffering
-      (iedit-stop-buffering))
   (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
   (setq iedit-occurrence-type-global iedit-occurrence-type-local)
   (setq iedit-last-occurrence-global iedit-last-occurrence-local)
@@ -763,12 +756,9 @@ prefix, bring the top of the region back down one 
occurrence."
   "Restricting Iedit mode in a region."
   (if (null (iedit-find-overlay beg end 'iedit-occurrence-overlay-name 
exclusive))
       (iedit-done)
-    (when iedit-buffering
-      (iedit-stop-buffering))
     (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
     (setq mark-active nil)
     (run-hooks 'deactivate-mark-hook)
-    (iedit-show-all)
     (iedit-cleanup-occurrences-overlays beg end exclusive)
     (if iedit-hiding
         (iedit-hide-context-lines iedit-occurrence-context-lines))
@@ -778,12 +768,9 @@ prefix, bring the top of the region back down one 
occurrence."
   "Toggle case-sensitive matching occurrences. "
   (interactive)
   (setq iedit-case-sensitive (not iedit-case-sensitive))
-  (if iedit-buffering
-      (iedit-stop-buffering))
   (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
   (when iedit-last-occurrence-local
-    (remove-overlays nil nil iedit-occurrence-overlay-name t)
-    (iedit-show-all)
+       (iedit-cleanup-occurrences-overlays)
     (let* ((occurrence-regexp (iedit-regexp-quote iedit-last-occurrence-local))
            (begin (car iedit-initial-region))
            (end (cadr iedit-initial-region))
@@ -803,25 +790,21 @@ prefix, bring the top of the region back down one 
occurrence."
         (if iedit-search-invisible
             nil
                  (or search-invisible 'open)))
-  (if iedit-buffering
-      (iedit-stop-buffering))
   (let ((occurrence-string (iedit-current-occurrence-string)))
-  (when occurrence-string
-    (remove-overlays nil nil iedit-occurrence-overlay-name t)
-    (iedit-show-all)
-       (isearch-clean-overlays)
-    (let* ((occurrence-regexp (iedit-regexp-quote occurrence-string))
-           (begin (car iedit-initial-region))
-           (end (cadr iedit-initial-region))
-           (counter (iedit-make-occurrences-overlays occurrence-regexp begin 
end)))
-      (message "iedit %s. %d matches for \"%s\""
-               (if iedit-search-invisible
-                   "matching invisible"
-                 "matching visible")
-               counter
-               (iedit-printable occurrence-regexp))
-         (setq iedit-last-occurrence-local occurrence-string)
-      (force-mode-line-update)))))
+       (when occurrence-string
+         (iedit-cleanup-occurrences-overlays)
+      (let* ((occurrence-regexp (iedit-regexp-quote occurrence-string))
+                        (begin (car iedit-initial-region))
+                        (end (cadr iedit-initial-region))
+                        (counter (iedit-make-occurrences-overlays 
occurrence-regexp begin end)))
+               (message "iedit %s. %d matches for \"%s\""
+                                (if iedit-search-invisible
+                                        "matching invisible"
+                   "matching visible")
+                                counter
+                                (iedit-printable occurrence-regexp))
+               (setq iedit-last-occurrence-local occurrence-string)
+               (force-mode-line-update)))))
 
 (provide 'iedit)
 



reply via email to

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