[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 61689f6ba4 057/301: Add arg handle for iedit-mode to
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 61689f6ba4 057/301: Add arg handle for iedit-mode to exclude some occurrences. |
Date: |
Mon, 10 Jan 2022 22:58:50 -0500 (EST) |
branch: elpa/iedit
commit 61689f6ba457d5a60fcea59a60676d630e5158b6
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Add arg handle for iedit-mode to exclude some occurrences.
---
iedit.el | 63 ++++++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 44 insertions(+), 19 deletions(-)
diff --git a/iedit.el b/iedit.el
index 11e984f1bf..bcf0b92fd0 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-02-20 02:14:47 Victor Ren>
+;; Time-stamp: <2012-02-20 13:46:59 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region replace simultaneous
;; Version: 0.94
@@ -150,6 +150,7 @@ forward or backward successful")
(defvar iedit-before-modification-undo-list nil
"This is buffer local variable which is the buffer undo list before
modification.")
+
;; `iedit-occurrence-update' gets called twice when change==0 and occurrence
;; is zero-width (beg==end)
;; -- for front and back insertion.
@@ -229,6 +230,7 @@ they exit Iedit mode before displaying global help."
(let (same-window-buffer-names same-window-regexps)
(iedit-help-for-help-internal)))
+;; todo: this function does not work
(defun iedit-describe-bindings ()
"Show a list of all keys defined in Iedit mode, and their definitions.
This is like `describe-bindings', but displays only Iedit keys."
@@ -337,10 +339,10 @@ Commands:
(interactive "P")
(if iedit-mode
(if (and transient-mark-mode mark-active (not (equal (mark) (point))))
- ;; Restrict iedit-mode in this region todo: rethink the
implementation
- (let* ((beg (region-beginning))
- (end (region-end)))
- (if (null (iedit-find-overlay-in-region beg end
'iedit-occurrence-overlay-name))
+ ;; Restrict iedit-mode
+ (let ((beg (region-beginning))
+ (end (region-end)))
+ (if (null (iedit-find-overlay beg end
'iedit-occurrence-overlay-name arg))
(iedit-done)
(when iedit-buffering
(iedit-stop-buffering))
@@ -348,9 +350,12 @@ Commands:
(if (null iedit-last-occurrence-in-history)
(iedit-done)
(deactivate-mark)
- (remove-overlays (point-min) (point-max)
iedit-occurrence-overlay-name t)
(iedit-show-all)
- (iedit-refresh iedit-last-occurrence-in-history beg end)
+ (iedit-cleanup-occurrences-overlays beg end arg)
+ (setq iedit-mode (propertize
+ (concat " Iedit:" (number-to-string (length
iedit-occurrences-overlays)))
+ 'face 'font-lock-warning-face))
+ (force-mode-line-update)
(iedit-first-occurrence))))
(iedit-done))
(let (occurrence complete-symbol rect-string)
@@ -454,7 +459,7 @@ Commands:
(if iedit-buffering
(iedit-stop-buffering))
(setq iedit-last-occurrence-in-history (iedit-current-occurrence-string))
- (remove-overlays (point-min) (point-max) iedit-occurrence-overlay-name t)
+ (remove-overlays nil nil iedit-occurrence-overlay-name t)
(iedit-show-all)
(setq iedit-occurrences-overlays nil)
(setq iedit-aborting nil)
@@ -621,11 +626,12 @@ the buffer."
(defun iedit-last-occurrence ()
"Move to the last occurrence."
(interactive)
- (setq pos (previous-single-char-property-change (point-max)
'iedit-occurrence-overlay-name))
- (if (not (get-char-property (- (point-max) 1)
'iedit-occurrence-overlay-name))
- (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name)))
- (setq iedit-forward-success t)
- (message "Located the last occurrence."))
+ (let ((pos (previous-single-char-property-change (point-max)
'iedit-occurrence-overlay-name)))
+ (if (not (get-char-property (- (point-max) 1)
'iedit-occurrence-overlay-name))
+ (setq pos (previous-single-char-property-change pos
'iedit-occurrence-overlay-name)))
+ (setq iedit-forward-success t)
+ (goto-char pos)
+ (message "Located the last occurrence.")))
(defun iedit-toggle-unmatched-lines-visible (&optional arg)
"Toggle whether to display unmatched lines.
@@ -646,7 +652,7 @@ value of `iedit-occurrence-context-lines' is used for this
time."
(unless (and iedit-unmatched-lines-invisible
(= arg iedit-occurrence-context-lines))
(when iedit-unmatched-lines-invisible
- (remove-overlays (point-min) (point-max) iedit-invisible-overlay-name
t))
+ (remove-overlays nil nil iedit-invisible-overlay-name t))
(setq iedit-occurrence-context-lines arg)
(setq iedit-unmatched-lines-invisible t)
(iedit-hide-unmatched-lines iedit-occurrence-context-lines))))
@@ -654,7 +660,7 @@ value of `iedit-occurrence-context-lines' is used for this
time."
(defun iedit-show-all()
"Show hided lines."
(setq line-move-ignore-invisible nil)
- (remove-overlays (point-min) (point-max) iedit-invisible-overlay-name t)
+ (remove-overlays nil nil iedit-invisible-overlay-name t)
(remove-from-invisibility-spec '(iedit-invisible-overlay-name . t)))
(defun iedit-hide-unmatched-lines (context-lines)
@@ -734,7 +740,7 @@ value of `iedit-occurrence-context-lines' is used for this
time."
(iedit-stop-buffering))
(setq iedit-last-occurrence-in-history (iedit-current-occurrence-string))
(when iedit-last-occurrence-in-history
- (remove-overlays (point-min) (point-max) iedit-occurrence-overlay-name t)
+ (remove-overlays nil nil iedit-occurrence-overlay-name t)
(iedit-show-all)
(iedit-refresh iedit-last-occurrence-in-history (point-min) (point-max))))
@@ -842,10 +848,10 @@ The behavior is the same as `kill-rectangle' in rect
mode."
(defun iedit-find-current-occurrence-overlay ()
"Return the current occurrence overlay at point or point - 1.
This function is supposed to be called in overlay local-map."
- (or (iedit-find-overlay (point) 'iedit-occurrence-overlay-name)
- (iedit-find-overlay (1- (point)) 'iedit-occurrence-overlay-name)))
+ (or (iedit-find-overlay-at-point (point) 'iedit-occurrence-overlay-name)
+ (iedit-find-overlay-at-point (1- (point))
'iedit-occurrence-overlay-name)))
-(defun iedit-find-overlay (point property)
+(defun iedit-find-overlay-at-point (point property)
"Return the overlay with PROPERTY at POINT."
(let ((overlays (overlays-at point))
found)
@@ -868,6 +874,13 @@ Return nil if occurrence string is empty string."
(regexp-quote (buffer-substring-no-properties beg end))
nil)))
+(defun iedit-find-overlay (beg end property &optional exclusive)
+ "Return a overlay with property in region, or out of the region if EXCLUSIVE
is not nil."
+ (if exclusive
+ (or (iedit-find-overlay-in-region (point-min) beg property)
+ (iedit-find-overlay-in-region end (point-max) property))
+ (iedit-find-overlay-in-region beg end property)))
+
(defun iedit-find-overlay-in-region (beg end property)
"Return a overlay with property in region."
(let ((overlays (overlays-in beg end))
@@ -881,6 +894,18 @@ Return nil if occurrence string is empty string."
(setq overlays (cdr overlays)))))
found))
+(defun iedit-cleanup-occurrences-overlays (beg end &optional inclusive)
+ "Remove overlays deleted from `iedit-occurrences-overlays'."
+ (if inclusive
+ (remove-overlays beg end iedit-occurrence-overlay-name t)
+ (remove-overlays (point-min) beg iedit-occurrence-overlay-name t)
+ (remove-overlays end (point-max) iedit-occurrence-overlay-name t))
+ (let (overlays)
+ (dolist (overlay iedit-occurrences-overlays)
+ (if (overlay-buffer overlay)
+ (push overlay overlays)))
+ (setq iedit-occurrences-overlays (nreverse overlays))))
+
(defun iedit-printable (string)
"Return a omitted substring that is not longer than 50.
STRING is already `regexp-quote'ed"
- [nongnu] elpa/iedit c11ecd9080 273/301: Update copyright notice, (continued)
- [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
- [nongnu] elpa/iedit 3d71392852 276/301: Fix as well issue #118, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f7184f81d6 284/301: Clean up some lines of unnecessary code, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 2e1fd5b1b2 295/301: fix a byte compile issue, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 012de2e8d8 293/301: A few rephase in doc, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6bb8d63a97 297/301: Fix several typo errors, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 345431294a 294/301: Unify prefix augument handling, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 61689f6ba4 057/301: Add arg handle for iedit-mode to exclude some occurrences.,
ELPA Syncer <=
- [nongnu] elpa/iedit 7479d4c947 079/301: Merge branch 'topic/multi-interface', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6cc86d58e6 086/301: Merge pull request #6 from gorakhargosh/master, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4cf803d9cb 092/301: Skip the first occurrence for occur-edit-mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c5ab2c593d 094/301: Avoid to restore Iedit mode when restoring desktop, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 95eb44ee30 117/301: Add new function iedit-add-next-occurrence-overlay, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit b94c75e8c6 107/301: Move iedit-help-keymap to iedit.el, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 84896f8be0 104/301: *** empty log message ***, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 962fcdb6cd 124/301: Fix failed test cases, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 6d16d92a5a 112/301: replace iedit-occurrence-face with real face, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 57beb10db5 141/301: Remove all the dependency to the order of iedit-occurrences-overlays, ELPA Syncer, 2022/01/10