[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 8219304d9c 051/301: Fix problem when iedit-stop-buff
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 8219304d9c 051/301: Fix problem when iedit-stop-buffering is called when current point is at any occurrence. |
Date: |
Mon, 10 Jan 2022 22:58:49 -0500 (EST) |
branch: elpa/iedit
commit 8219304d9c9b9aa23de3f8dd45ff2d6b0234e35b
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Fix problem when iedit-stop-buffering is called when current point is at
any occurrence.
---
iedit.el | 61 +++++++++++++++++++++++++++++++++----------------------------
1 file changed, 33 insertions(+), 28 deletions(-)
diff --git a/iedit.el b/iedit.el
index 969fb737f8..036400b2b6 100644
--- a/iedit.el
+++ b/iedit.el
@@ -1,8 +1,8 @@
-;;; iedit.el --- Edit multiple regions simultaneously.
+;;; iedit.el --- Edit multiple regions in one buffer simultaneously.
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-02-07 00:04:38 Victor Ren>
+;; Time-stamp: <2012-02-07 15:11:26 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region replace simultaneous
;; Version: 0.93
@@ -738,7 +738,11 @@ be applied to other occurrences when buffering is off."
(interactive "*")
(if iedit-buffering
(iedit-stop-buffering)
- (iedit-start-buffering)))
+ (iedit-start-buffering))
+ (message (concat "Iedit-mode buffering "
+ (if iedit-buffering
+ "started."
+ "stopped."))))
(defun iedit-start-buffering ()
"Start buffering."
@@ -750,36 +754,37 @@ be applied to other occurrences when buffering is off."
(message "Iedit-mode buffering."))
(defun iedit-stop-buffering ()
- "Stop buffering and apply the modification to other occurrences."
- (let* ((inhibit-modification-hooks t)
- (ov (iedit-find-current-occurrence-overlay))
- (beg (overlay-start ov))
- (end (overlay-end ov))
- (modified-string (buffer-substring-no-properties beg end))
- (offset (- (point) beg))) ;; delete-region moves cursor
- (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
- (delete-region beg end)
- (goto-char beg)
- (insert-and-inherit iedit-before-modification-string)
- (setq buffer-undo-list iedit-before-modification-undo-list)
- (dolist (occurrence iedit-occurrences-overlays) ; todo:extract as a
function
- (let ((beginning (overlay-start occurrence))
- (ending (overlay-end occurrence)))
- (delete-region beginning ending)
- (unless (eq beg end) ;; replacement
- (goto-char beginning)
- (insert-and-inherit modified-string)))))
- (goto-char (+ (overlay-start ov) offset))))
+ "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)))
+ (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
+ (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
+ (delete-region beg end)
+ (goto-char beg)
+ (insert-and-inherit iedit-before-modification-string)
+ (setq buffer-undo-list iedit-before-modification-undo-list)
+ (dolist (occurrence iedit-occurrences-overlays) ; todo:extract as
a function
+ (let ((beginning (overlay-start occurrence))
+ (ending (overlay-end occurrence)))
+ (delete-region beginning ending)
+ (unless (eq beg end) ;; replacement
+ (goto-char beginning)
+ (insert-and-inherit modified-string)))))
+ (goto-char (+ (overlay-start ov) offset))))))
(setq iedit-buffering nil)
(setq iedit-mode (propertize
(concat " Iedit:" (number-to-string (length
iedit-occurrences-overlays)))
'face 'font-lock-warning-face))
(force-mode-line-update)
- (setq iedit-before-modification-undo-list nil)
- (message "Iedit-mode buffering stopped."))
+ (setq iedit-before-modification-undo-list nil))
(defvar iedit-number-line-counter 1
"Occurrence number for 'iedit-number-occurrences")
- [nongnu] elpa/iedit f36e6fcf0d 143/301: Move iedit-apply-global-modification to iedit, (continued)
- [nongnu] elpa/iedit f36e6fcf0d 143/301: Move iedit-apply-global-modification to iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8d58171240 145/301: bugfix for iedit-hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a55fcae6d0 175/301: Bind <tab> to iedit-next-occurrence, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 232cd0e5ec 146/301: tweak to use isearch case sensitivity, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5883f9af54 211/301: Avoid overriding user's key bindings, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 95e7731a91 147/301: bugfix for when there are no occurrences, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 19abf6e871 247/301: Update URLs to emacswiki, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ed52608a0d 268/301: Fix conjoined occurrences issues, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 890a11657c 226/301: Merge pull request #66 from pstray/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a5ce38a9c3 123/301: fix deleting char at end of overlay with mirror at EOB, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8219304d9c 051/301: Fix problem when iedit-stop-buffering is called when current point is at any occurrence.,
ELPA Syncer <=
- [nongnu] elpa/iedit d872cb77e5 058/301: Update comments for restricting, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 75552aa1c8 090/301: Rename, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 33d1b24e04 080/301: Fix compatible with Emacs 22 problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ad8fd96f86 215/301: Add support for markup tags, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5b14cc9fca 241/301: Add a demo gif and update document, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 03b647be8b 234/301: Expand or collapse mutiple lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 88101571fe 288/301: Make it an option to save occurrence in the kill ring, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ca844b40f4 265/301: Fix package URLs in commentaries, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3a892bac38 277/301: Enhance a test case to compile iedit under clean environment, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f79846e639 275/301: Fix issue #117, ELPA Syncer, 2022/01/10