[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 039c0e23ab 023/301: Postpone iedit-done after comman
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 039c0e23ab 023/301: Postpone iedit-done after commands are excuted. |
Date: |
Mon, 10 Jan 2022 22:58:46 -0500 (EST) |
branch: elpa/iedit
commit 039c0e23ab6578aa3c6353d62542a4632b77cc49
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Postpone iedit-done after commands are excuted.
---
iedit.el | 58 +++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 21 deletions(-)
diff --git a/iedit.el b/iedit.el
index b52bf23201..1d9c6c09bf 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-01-24 21:40:20 Victor Ren>
+;; Time-stamp: <2012-01-24 23:30:14 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region replace simultaneous
;; Version: 0.91
@@ -142,7 +142,7 @@ unmatched lines are hided.")
iedit mode is turned off last time.")
(defvar iedit-forward-success t
- "This is buffer local variable which indicate the moving
+ "This is buffer local variable which indicates the moving
forward or backward successful")
(defvar iedit-before-modification-beg 0
@@ -155,6 +155,15 @@ before a change is made.")
(defvar iedit-before-modification-string ""
"This is buffer local variable which is the buffer substring that is going
to be changed.")
+;; `iedit-occurrence-update' gets called twice when change==0 and occurrence
+;; is zero-width
+;; -- for front and back insertion.
+(defvar iedit-last-overlay nil
+ "This is buffer local variable which records processed overlay so they don't
get processed multiple times. See code.")
+
+(defvar iedit-aborting nil
+ "This is buffer local variable which indicates iedit-mode is aborting.")
+
(make-variable-buffer-local 'iedit-occurrences-overlays)
(make-variable-buffer-local 'iedit-unmatched-lines-invisible)
(make-variable-buffer-local 'iedit-case-sensitive)
@@ -163,6 +172,8 @@ before a change is made.")
(make-variable-buffer-local 'iedit-before-modification-beg)
(make-variable-buffer-local 'iedit-before-modification-end)
(make-variable-buffer-local 'iedit-before-modification-string)
+(make-variable-buffer-local 'iedit-last-overlay)
+(make-variable-buffer-local 'iedit-aborting)
(defconst iedit-occurrence-overlay-name 'iedit-occurrence-overlay-name)
(defconst iedit-invisible-overlay-name 'iedit-invisible-overlay-name)
@@ -210,9 +221,9 @@ This is like `describe-bindings', but displays only Iedit
keys."
(interactive)
(let (same-window-buffer-names same-window-regexps)
(with-help-window "*Help*"
- (with-current-buffer standard-output
- (princ "Iedit Mode Bindings:\n")
- (princ (substitute-command-keys "\\{iedit-mode-map}"))))))
+ (with-current-buffer standard-output
+ (princ "Iedit Mode Bindings:\n")
+ (princ (substitute-command-keys
"\\{iedit-mode-map}"))))))
(defun iedit-describe-key ()
"Display documentation of the function invoked by iedit key."
@@ -343,6 +354,19 @@ Commands:
(concat (substring occurrence-exp 0 50) "...")
occurrence-exp)))))
+(defun iedit-reset-last-overlay ()
+ "`post-command-hook' function to reset iedit-last-overlay and also remove
itself from post-command-hook."
+ (remove-hook 'post-command-hook 'iedit-reset-last-overlay t)
+ (setq iedit-last-overlay nil))
+
+(defun iedit-reset-aborting ()
+ "Turning iedit-mode off and reset iedit-aborting. `iedit-done'
+is postponed after the command is executed for avoiding
+iedit-occurrence-update is called for a removed overlay."
+ (iedit-done)
+ (remove-hook 'post-command-hook 'iedit-reset-aborting t)
+ (setq iedit-aborting nil))
+
(defun iedit-rectangle (beg end)
"Start an iedit for the region as a rectangle"
(setq iedit-mode (propertize " Iedit-RECT" 'face 'font-lock-warning-face))
@@ -424,30 +448,22 @@ occurrences if the user starts typing."
(overlay-put unmatched-lines-overlay 'intangible t)
unmatched-lines-overlay))
-;; `iedit-occurrence-update' gets called twice when change==0 and occurrence
-;; is zero-width
-;; -- for front and back insertion.
-(defvar iedit-last-overlay nil
- "records processed overlay so they don't get processed multiple times. See
code.")
-(defun iedit-post-command-func ()
- (remove-hook 'post-command-hook 'iedit-post-command-func t)
- (setq iedit-last-overlay nil))
-
(defun iedit-occurrence-update (occurrence after beg end &optional change)
"Update all occurrences.
This modification hook is triggered when a user edits any
occurrence and is responsible for updating all other occurrences.
Current supported edits are insertion, yank, deletion and replacement.
If this modification is going out of the occurrence, it will
-exit iedit mode."
- (when (not undo-in-progress) ; undo will do all the update
+exit iedti mode."
+ (when (and (not iedit-aborting )
+ (not undo-in-progress)) ; undo will do all the update
;; before modification
(if (null after)
(if (or (< beg (overlay-start occurrence))
(> end (overlay-end occurrence)))
- (let ((inhibit-modification-hooks t))
- (iedit-done)) ;; todo: it is a problem to remove the overlays
- (progn (setq iedit-before-modification-beg beg)
+ (progn (setq iedit-aborting t) ; abort iedit-mode
+ (add-hook 'post-command-hook
'iedit-reset-aborting nil t))
+ (progn (setq iedit-before-modification-beg beg)
(setq iedit-before-modification-end end)
(unless (eq beg end)
(setq iedit-before-modification-string
@@ -459,7 +475,7 @@ exit iedit mode."
(not (string= iedit-before-modification-string
(buffer-substring-no-properties beg end))))
(setq iedit-last-overlay occurrence)
- (add-hook 'post-command-hook 'iedit-post-command-func nil t)
+ (add-hook 'post-command-hook 'iedit-reset-last-overlay nil t)
(let ((inhibit-modification-hooks t)
(offset (- beg (overlay-start occurrence)))
(value (buffer-substring beg end)))
@@ -530,7 +546,7 @@ exit iedit mode."
;; (not (< beg (overlay-start occurrence)))
;; (not (eq occurrence iedit-last-overlay)))
;; (setq iedit-last-overlay occurrence)
-;; (add-hook 'post-command-hook 'iedit-post-command-func nil t)
+;; (add-hook 'post-command-hook 'iedit-reset-last-overlay nil t)
;; (let ((replacement-str (buffer-substring-no-properties beg end))
;; (index (- beg (overlay-start occurrence)))
;; (inhibit-modification-hooks t))
- [nongnu] elpa/iedit 8e87f353fe 006/301: add me as a contributor, (continued)
- [nongnu] elpa/iedit 8e87f353fe 006/301: add me as a contributor, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 59ce7fa759 091/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 307262b25a 093/301: (add-hook 'change-major-mode-hook 'iedit-done nil t), ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d2a6e16977 055/301: Update commentary with rectangle support, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 76eeb87b95 102/301: Add feekback message for iedit-restrict-function, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 29869ebed0 118/301: Add buffer local variable iedit-occurrence-keymap, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ec765ee0c4 018/301: implement interactive string-rectangle mode with universal argument and region selected, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d4b9fd53ce 019/301: don't call hooks when there is only text properites change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7ed8e04557 021/301: Optmize iedit-hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e6f558539e 025/301: fix org-mode text-property compatibility (use insert-and-inherit), ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 039c0e23ab 023/301: Postpone iedit-done after commands are excuted.,
ELPA Syncer <=
- [nongnu] elpa/iedit c5a0d4de84 028/301: fix zero-width rectangle insertion, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 13ecba138a 026/301: Merge branch 'upstream-master', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 1d070b7d36 029/301: move init code for iedit-mode-map inside defvar, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a75c44645a 031/301: fix bug with autopair and iedit-rect, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 20c1075948 032/301: remove conditions on setting `iedit-before-modification-string'., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c4091203ea 033/301: Merge pull request #3 from lewang/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit b81b9d6025 034/301: Clean code., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 17ce97381b 035/301: Clean up code, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9b3aaa8f21 037/301: Fix occurrence from history does not exist problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit b9ebb768b7 190/301: Merge pull request #60 from danrharms/issue-59-hotfix, ELPA Syncer, 2022/01/10