[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit c8dac6bee8 020/301: exit iedit mode when change is n
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit c8dac6bee8 020/301: exit iedit mode when change is not inside of occurrence. |
Date: |
Mon, 10 Jan 2022 22:58:46 -0500 (EST) |
branch: elpa/iedit
commit c8dac6bee82e976a1fc2e148c46b90e10c18f9ac
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
exit iedit mode when change is not inside of occurrence.
---
iedit.el | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 86 insertions(+), 17 deletions(-)
diff --git a/iedit.el b/iedit.el
index 70bb2f7fe6..a1759457c2 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-01-20 11:33:43 Victor Ren>
+;; Time-stamp: <2012-01-21 11:52:29 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region replace simultaneous
;; Version: 0.91
@@ -145,16 +145,24 @@ iedit mode is turned off last time.")
"This is buffer local variable which indicate the moving
forward or backward successful")
+(defvar iedit-before-modification-beg 0
+ "This is buffer local variable which is the argment `end' of hook function
+before a change is made.")
+
(defvar iedit-before-modification-end 0
"This is buffer local variable which is the argment `end' of hook function
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.")
(make-variable-buffer-local 'iedit-occurrences-overlays)
(make-variable-buffer-local 'iedit-unmatched-lines-invisible)
(make-variable-buffer-local 'iedit-case-sensitive)
(make-variable-buffer-local 'iedit-last-occurrence-in-history)
(make-variable-buffer-local 'iedit-forward-success)
+(make-variable-buffer-local 'iedit-before-modification-beg)
(make-variable-buffer-local 'iedit-before-modification-end)
+(make-variable-buffer-local 'iedit-before-modification-string)
(defconst iedit-occurrence-overlay-name 'iedit-occurrence-overlay-name)
(defconst iedit-invisible-overlay-name 'iedit-invisible-overlay-name)
@@ -341,7 +349,7 @@ Commands:
(let ((ov (car iedit-occurrences-overlays)))
(if ov
(setq iedit-last-occurrence-in-history
- (buffer-substring (overlay-start ov) (overlay-end ov)))))
+ (buffer-substring-no-properties (overlay-start ov) (overlay-end
ov)))))
(remove-overlays (point-min) (point-max) iedit-occurrence-overlay-name t)
(remove-overlays (point-min) (point-max) iedit-invisible-overlay-name t)
(setq iedit-occurrences-overlays nil)
@@ -375,28 +383,89 @@ occurrences if the user starts typing."
(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."
- (when (not undo-in-progress) ; undo will do all the work
- (if (null after) ; before modification
- (setq iedit-before-modification-end end)
- ;; exclude text properites change, only continue for insertion or
deletion
- (when (or (not (eq iedit-before-modification-end end)))
+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
+ ;; before modification
+ (if (null after)
+ (if (or (< beg (overlay-start occurrence))
+ (> end (overlay-end occurrence)))
+ (iedit-done) ;;
+ (progn (setq iedit-before-modification-beg beg)
+ (setq iedit-before-modification-end end)
+ (unless (eq beg end)
+ (setq iedit-before-modification-string
+ (buffer-substring-no-properties beg end)))))
+ ;; after modification
+ (when (or (eq 0 change) ;; insertion
+ (eq beg end) ;; deletion
+ (not (string= iedit-before-modification-string
+ (buffer-substring-no-properties beg end))))
(let ((inhibit-modification-hooks t)
- (offset (- beg (overlay-start occurrence))))
+ (offset (- beg (overlay-start occurrence)))
+ (value (buffer-substring beg end)))
(save-excursion
- ;; insertion
+ ;; insertion or yank
(if (eq 0 change)
- (let ((value (buffer-substring beg end)))
- (dolist (like-occurrence (remove occurrence
iedit-occurrences-overlays))
- (progn
- (goto-char (+ (overlay-start like-occurrence) offset))
- (insert value))))
+ (dolist (like-occurrence (remove occurrence
iedit-occurrences-overlays))
+ (progn
+ (goto-char (+ (overlay-start like-occurrence) offset))
+ (insert value)))
;; deletion
(dolist (like-occurrence (remove occurrence
iedit-occurrences-overlays))
(let* ((beginning (+ (overlay-start like-occurrence) offset))
(ending (+ beginning change)))
- (delete-region beginning ending))))))))))
+ (delete-region beginning ending)
+ (unless (eq beg end) ;; replacement
+ (goto-char beginning)
+ (insert value)))))))))))
+;; (elp-instrument-list '(insert delete-region goto-char
iedit-occurrence-update buffer-substring-no-properties string=
re-search-forward replace-match))
+
+;; slowest verion:
+;; (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."
+;; (when (and after (not undo-in-progress)) ; undo will do all the work
+;; (let ((value (buffer-substring-no-properties
+;; (overlay-start occurrence) (overlay-end occurrence)))
+;; (inhibit-modification-hooks t))
+;; (save-excursion
+;; (dolist (like-occurrence iedit-occurrences-overlays)
+;; (if (not (eq like-occurrence occurrence))
+;; (progn
+;; (goto-char (overlay-start like-occurrence))
+;; (delete-region (overlay-start like-occurrence)
+;; (overlay-end like-occurrence))
+;; (insert value))))))))
+
+;; ;; todo \\_<
+;; (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."
+;; (when (not undo-in-progress) ; undo will do all the work
+;; (if (null after)
+;; (if (or (< beg (overlay-start occurrence))
+;; (> end (overlay-end occurrence)))
+;; (iedit-done)
+;; (setq iedit-before-modification-string
+;; (buffer-substring-no-properties
+;; (overlay-start occurrence) (overlay-end occurrence))))
+;; (let ((value (buffer-substring-no-properties
+;; (overlay-start occurrence) (overlay-end occurrence)))
+;; (inhibit-modification-hooks t))
+;; (save-excursion
+;; (goto-char (overlay-end occurrence))
+;; (while (re-search-forward iedit-before-modification-string nil t)
+;; (replace-match value nil nil))
+;; (goto-char (point-min))
+;; (while (re-search-forward iedit-before-modification-string
(overlay-start occurrence) t)
+;; (replace-match value nil nil)))))))
(defun iedit-next-occurrence ()
"Move forward to the next occurrence in the `iedit'.
- [nongnu] elpa/iedit e9a94852d8 001/301: updates, (continued)
- [nongnu] elpa/iedit e9a94852d8 001/301: updates, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 69d6c03e06 009/301: Fix syntax error, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9a891d7abf 002/301: updates, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ec6785b0d2 008/301: host on git, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f808bf1ce9 012/301: Merge from lewang/master and update comments, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 02946e07b6 013/301: Update contributors and spell check, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit af6d0ef70b 007/301: host on github, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 17e8fca7e6 011/301: Merge from tsdh/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6d96992291 015/301: Remove duplicated comments, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 011e8d354c 016/301: Performance optimization of iedit-occurrence-update, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c8dac6bee8 020/301: exit iedit mode when change is not inside of occurrence.,
ELPA Syncer <=
- [nongnu] elpa/iedit 768d89b60c 022/301: Merge remote-tracking branch 'lewang/master', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 0edc86ff41 024/301: Fix the last occurrence problem when it is a complete symbol., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit dd7d2f95f8 027/301: fix org-mode text-property compatibility (use insert-and-inherit), ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d5d4027a33 030/301: fix `iedit-toggle-unmatched-lines-visible' for rectangles, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 652087d63c 036/301: fix warning: the function `make-sparse-key-map' is not known to be, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit da47784c8d 038/301: Add iedit mode easy access keys, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c53a885fe5 040/301: Add bufferring modification functionalities, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9bc57d2a30 041/301: make iedit-skipped-modification-once buffer local, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e99e65fccb 044/301: Fix current point move problem when call iedit-replace-occurrences., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4e31d50327 052/301: Add a prefix arg handling to iedit-toggle-unmatched-lines-visible, ELPA Syncer, 2022/01/10