[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 1c410fc2b8 101/301: Fix iedit-number-occurrences wit
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 1c410fc2b8 101/301: Fix iedit-number-occurrences with conjointed occurrences problem |
Date: |
Mon, 10 Jan 2022 22:58:54 -0500 (EST) |
branch: elpa/iedit
commit 1c410fc2b871cb1dc8a45457f9c8b7bb1a8ac8c4
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Fix iedit-number-occurrences with conjointed occurrences problem
Call ieit-move-conjointed-overlays
---
iedit-lib.el | 50 +++++++++++++++++++++++++-------------------------
iedit-rect.el | 4 ++--
iedit.el | 4 ++--
3 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 227483b407..9fa00694b5 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-08-09 17:17:42 Victor Ren>
+;; Time-stamp: <2012-08-10 09:26:34 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -278,8 +278,8 @@ there are."
(lambda (left right)
(< (overlay-start left) (overlay-start right)))))) ;; todo test
this function
-(defun iedit-clearup ()
- "Clear up occurrence overlay, invisible overlay and local variables."
+(defun iedit-cleanup ()
+ "Clean up occurrence overlay, invisible overlay and local variables."
;; (when iedit-buffering
;; (iedit-stop-buffering))
;; (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
@@ -539,13 +539,10 @@ This function depends on the order of
iedit-occurrences-overlays. TODO"
;;;; functions for overlay keymap
(defun iedit-apply-on-occurrences (function &rest args)
"Call function for each occurrence."
- (let* ((ov (car iedit-occurrences-overlays))
- (beg (overlay-start ov))
- (end (overlay-end ov)))
- (let ((inhibit-modification-hooks t))
+ (let ((inhibit-modification-hooks t))
(save-excursion
(dolist (occurrence iedit-occurrences-overlays)
- (apply function (overlay-start occurrence) (overlay-end occurrence)
args))))))
+ (apply function (overlay-start occurrence) (overlay-end occurrence)
args)))))
(defun iedit-upcase-occurrences ()
"Covert occurrences to upper case."
@@ -625,17 +622,17 @@ be applied to other occurrences when buffering is off."
"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))
- (inhibit-modification-hooks t))
+ (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
+ (offset (- (point) beg)) ;; delete-region moves cursor
+ (inhibit-modification-hooks t))
(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
+ ;; 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)
@@ -688,12 +685,13 @@ After modification, conjointed overlays may be
overlapped."
(1- (+ (length iedit-occurrences-overlays) start-at)))))
"d "))
-(defun iedit-number-occurrences (start-at &optional format)
+(defun iedit-number-occurrences (start-at &optional format-string)
"Insert numbers in front of the occurrences.
START-AT, if non-nil, should be a number from which to begin
counting. FORMAT, if non-nil, should be a format string to pass
-to `format' along with the line count. When called interactively
-with a prefix argument, prompt for START-AT and FORMAT."
+to `format-string' along with the line count. When called
+interactively with a prefix argument, prompt for START-AT and
+FORMAT."
(interactive
(if current-prefix-arg
(let* ((start-at (read-number "Number to count from: " 1)))
@@ -702,15 +700,17 @@ with a prefix argument, prompt for START-AT and FORMAT."
(iedit-default-occurence-number-format
start-at))))
(list 1 nil)))
- (unless format
- (setq format (iedit-default-occurence-number-format start-at)))
- (let ((iedit-number-occurrence-counter start-at))
- (iedit-apply-on-occurrences
- (lambda (beg _end format-string)
- (goto-char beg)
- (insert (format format-string iedit-number-occurrence-counter))
- (setq iedit-number-occurrence-counter
- (1+ iedit-number-occurrence-counter))) format)))
+ (unless format-string
+ (setq format-string (iedit-default-occurence-number-format start-at)))
+ (let ((iedit-number-occurrence-counter start-at)
+ (inhibit-modification-hooks t))
+ (save-excursion
+ (dolist (occurrence iedit-occurrences-overlays)
+ (goto-char (overlay-start occurrence))
+ (insert (format format-string iedit-number-occurrence-counter))
+ (iedit-move-conjointed-overlays occurrence)
+ (setq iedit-number-occurrence-counter
+ (1+ iedit-number-occurrence-counter))))))
;;; help functions
diff --git a/iedit-rect.el b/iedit-rect.el
index 068d07ffd4..8c6bfca8f4 100644
--- a/iedit-rect.el
+++ b/iedit-rect.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-08-09 17:17:25 Victor Ren>
+;; Time-stamp: <2012-08-10 10:00:55 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -134,7 +134,7 @@ Save the current occurrence string locally and globally.
Save
the initial string globally."
(when iedit-buffering
(iedit-stop-buffering))
- (iedit-clearup)
+ (iedit-cleanup)
(setq iedit-rectangle-mode nil)
(force-mode-line-update)
(remove-hook 'kbd-macro-termination-hook 'iedit-rectangle-done t)
diff --git a/iedit.el b/iedit.el
index f0a7533779..fee2c4af43 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-08-09 17:08:52 Victor Ren>
+;; Time-stamp: <2012-08-10 10:00:31 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -314,7 +314,7 @@ the initial string globally."
(setq iedit-last-initial-string-global iedit-initial-string-local)
(setq iedit-case-sensitive-global iedit-case-sensitive-local)
- (iedit-clearup)
+ (iedit-cleanup)
(setq iedit-mode nil)
(force-mode-line-update)
- [nongnu] elpa/iedit 19f35aa1a0 172/301: Change the default key binding for `iedit-rectangle-mode' to c-x-r-ret, (continued)
- [nongnu] elpa/iedit 19f35aa1a0 172/301: Change the default key binding for `iedit-rectangle-mode' to c-x-r-ret, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4864e17126 010/301: Merge remote-tracking branch 'tsdh/master', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit fc71952cf9 014/301: Boolean `t', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit df6c2ad919 017/301: fix search to use regexp-quote when needed, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 30971294b2 071/301: Remove a limitation of empty occurrence string, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit df9e958703 082/301: Add more short-cut to iedit on function, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 06fac017b4 087/301: explain what "quite different" means in rectangle context in README, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 1d32922c04 089/301: Run after-change-functions hook for every occurrence, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c935255053 083/301: minor change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d29bf65e5e 096/301: Do not update mode line when buffering modification, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 1c410fc2b8 101/301: Fix iedit-number-occurrences with conjointed occurrences problem,
ELPA Syncer <=
- [nongnu] elpa/iedit 73a5884b4c 126/301: Merge branch 'master' of github.com:victorhge/iedit, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit b4c736225f 114/301: Merge pull request #18 from lewang/lewang-use-real-face, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 8ff86b768d 115/301: Replace "(set-mark nil)" with (setq mark-active nil)", ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9a1b776f22 103/301: Remove todo for conjointed overlays, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 21a60f2ea3 113/301: Add toogle key option, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e4d67bdb06 120/301: Separate iedit-mode-from-isearch, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 466ab11996 119/301: Add APIs for adding occurrence overlay, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3cf5e8f806 111/301: Minor update README.org to reflect modulized change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a089103fa0 110/301: Fix typoes, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 66ca4f9595 125/301: Merge pull request #21 from lewang/fix-overlay-at-eob, ELPA Syncer, 2022/01/10