[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 8b620efacb 262/301: Replace `inhibit-modification-ho
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 8b620efacb 262/301: Replace `inhibit-modification-hooks' with `iedit-updating' |
Date: |
Mon, 10 Jan 2022 22:59:08 -0500 (EST) |
branch: elpa/iedit
commit 8b620efacbfa7f8808c4738e86ab1f0ef4610ed7
Author: Victor <victorhge@gmail.com>
Commit: Victor <victorhge@gmail.com>
Replace `inhibit-modification-hooks' with `iedit-updating'
Both of them provent calling change hooks recursively. But
`inhibit-modification-hooks' prevent `after-change-functions' also.
Some package might depends on it.
---
iedit-lib.el | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index a367101357..372d0f9f7b 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2020-07-21 11:54:31 Victor Ren>
+;; Time-stamp: <2020-07-21 15:03:28 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.9.9.9
@@ -179,6 +179,12 @@ occurrence.")
(defvar iedit-after-change-list nil
"Used to store the modifications in the command being run.")
+(defvar iedit-updating nil
+ "Used to prevent recursive calling change hooks.
+It replaces `inhibit-modification-hooks' which prevents calling
+`after-change-functions'.")
+
+(make-variable-buffer-local 'iedit-updating)
(make-variable-buffer-local 'iedit-after-change-list)
(make-variable-buffer-local 'iedit-occurrences-overlays)
(make-variable-buffer-local 'iedit-read-only-occurrences-overlays)
@@ -480,7 +486,7 @@ replacement. If this modification is going out of the
occurrence, it will abort Iedit mode."
(if undo-in-progress
;; If the "undo" change make occurrences different, it is going to mess
up
- ;; occurrences. So a check will be done after undo command is executed.
+ ;; occurrences. So a length check will be done after undo command is
executed.
(when (not iedit-post-undo-hook-installed)
(add-hook 'post-command-hook 'iedit-post-undo nil t)
(setq iedit-post-undo-hook-installed t))
@@ -499,11 +505,11 @@ occurrence, it will abort Iedit mode."
;; called. Two calls will make
`iedit-skip-modification-once' true.
(setq iedit-skip-modification-once (not
iedit-skip-modification-once)))
;; after modification
- (when (not iedit-buffering)
- (if iedit-skip-modification-once
- ;; Skip the first hook
- (setq iedit-skip-modification-once nil)
- (setq iedit-skip-modification-once t)
+ (if iedit-skip-modification-once
+ ;; Skip the first hook
+ (setq iedit-skip-modification-once nil)
+ (setq iedit-skip-modification-once t)
+ (when (and (not iedit-buffering) (not iedit-updating))
(when (or (eq 0 change) ;; insertion
(eq beg end) ;; deletion
(not (string= iedit-before-modification-string ;;
replacement
@@ -545,7 +551,7 @@ part to apply it to all the other occurrences."
(defun iedit-update-occurrences-3 (occurrence beg end &optional change)
"The third part of updateing occurrences.
Apply the change to all the other occurrences. "
- (let ((inhibit-modification-hooks t)
+ (let ((iedit-updating t)
(offset (- beg (overlay-start occurrence)))
(value (buffer-substring-no-properties beg end)))
(save-excursion
@@ -556,17 +562,7 @@ Apply the change to all the other occurrences. "
(when change (delete-region beginning (+
beginning change))) ;; delete
(when (/= beg end) ;; insert
(goto-char beginning)
- (insert-and-inherit value))
- ;; todo: reconsider this change Quick fix for multi-occur
- ;; occur-edit-mode: multi-occur depend on
after-change-functions
- ;; to update original buffer. Since inhibit-modification-hooks
- ;; is set to non-nil, after-change-functions hooks are not
going
- ;; to be called for the changes of other occurrences. So run
- ;; the hook here.
- (run-hook-with-args 'after-change-functions
- beginning
- ending
- change))
+ (insert-and-inherit value)))
(iedit-move-conjoined-overlays another-occurrence))))))
(defun iedit-next-occurrence ()
@@ -756,7 +752,7 @@ value of `iedit-occurrence-context-lines' is used for this
time."
(defun iedit-apply-on-occurrences (function &rest args)
"Call function for each occurrence."
- (let ((inhibit-modification-hooks t))
+ (let ((iedit-updating t))
(save-excursion
(dolist (occurrence iedit-occurrences-overlays)
(apply function (overlay-start occurrence) (overlay-end occurrence)
args)))))
@@ -779,7 +775,7 @@ Called with a prefix arg, allow editing the format string
used, which
default to `iedit-increment-format-string'."
(interactive "*P")
(iedit-barf-if-buffering)
- (let ((inhibit-modification-hooks t)
+ (let ((iedit-updating t)
(fmt-str (if arg
(read-string
(format "Format incremented numbers (default '%s'): "
@@ -876,7 +872,7 @@ modification is not going to be applied to other
occurrences."
(end (overlay-end ov))
(modified-string (buffer-substring-no-properties beg end))
(offset (- (point) beg)) ;; delete-region moves cursor
- (inhibit-modification-hooks t))
+ (iedit-updating t))
(when (not (string= iedit-before-buffering-string modified-string))
(save-excursion
;; Rollback the current modification and buffer-undo-list. This is
@@ -951,7 +947,7 @@ FORMAT."
(unless format-string
(setq format-string (iedit-default-occurrence-number-format start-at)))
(let ((iedit-number-occurrence-counter start-at)
- (inhibit-modification-hooks t))
+ (iedit-updating t))
(save-excursion
(goto-char (iedit-first-occurrence))
(while (/= (point) (point-max))
- [nongnu] elpa/iedit f566ade5e4 264/301: Workaround for slow `c-before-change', (continued)
- [nongnu] elpa/iedit f566ade5e4 264/301: Workaround for slow `c-before-change', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 64c3505d04 235/301: correct spelling mistake, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 2f0c484817 283/301: Move iedit-buffering related to `iedit-lib', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7e277119fc 221/301: Fix doc string for markup tag, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 50b7da10ac 251/301: Add option `iedit-auto-buffering`, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3211c2ee6c 228/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 93b642f0a8 286/301: A few small fixes, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 02b4a6553e 243/301: Add the index of the current occurrence on mode-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 06e600aae2 222/301: Fix: use return value of iedit-default-occurrence-mode-local, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit abcc27a9f0 231/301: Add Installation instruction, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8b620efacb 262/301: Replace `inhibit-modification-hooks' with `iedit-updating',
ELPA Syncer <=
- [nongnu] elpa/iedit 6d2694356c 253/301: Move "declare-function" invocations outside of "when" statement., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f6682186f0 242/301: Replace eval-after-load with require check, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 14376a97e0 223/301: Ignore error in `iedit-mark-sgml-pair', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9fd1b43170 229/301: Fix failed test cases for Emacs 25.1, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 658c10a249 244/301: fix issue of iedit-restrict-function doesn't update mode-line text correctly, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 06f1f50939 224/301: Merge pull request #65 from pstray/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c11ecd9080 273/301: Update copyright notice, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e5b51ac0af 278/301: Move hooks setup to iedit-lib to reduce code duplication, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c00a8ba805 272/301: Add a new feature - preserve case, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4ef9bf6323 287/301: prefix-arg for `iedit-next-occurrence` and `iedit-prev-occurrence`, ELPA Syncer, 2022/01/10