[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit 466ab11996 119/301: Add APIs for adding occurrence o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit 466ab11996 119/301: Add APIs for adding occurrence overlay |
Date: |
Mon, 10 Jan 2022 22:58:55 -0500 (EST) |
branch: elpa/iedit
commit 466ab119964b984299064436e226a0cf372bd473
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Add APIs for adding occurrence overlay
---
iedit-lib.el | 53 ++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 36 insertions(+), 17 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 73f8889256..2d487d2857 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-09-05 09:46:44 Victor Ren>
+;; Time-stamp: <2012-09-06 11:07:10 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -33,7 +33,7 @@
;;; todo:
;; - Update comments for APIs
;; - Add more easy access keys for whole occurrence
-;; - More APIs: extend occurrences, add-next, add previous, add region
+;; - More APIs: extend occurrences,
;;; Code:
@@ -168,7 +168,8 @@ is not applied to other occurrences when it is true.")
"Default keymap used within occurrence overlays.")
(defvar iedit-occurrence-keymap 'iedit-occurrence-keymap-default
- "Keymap used within occurrence overlays")
+ "Keymap used within occurrence overlays.
+It should be set before occurrence overlay is created.")
(make-local-variable 'iedit-occurrence-context-lines)
(defun iedit-help-for-occurrences ()
@@ -207,19 +208,37 @@ Return the number of occurrences."
(iedit-hide-unmatched-lines iedit-occurrence-context-lines))))
counter))
-(defun iedit-add-next-occurrence-overlay (occurrence-exp)
+(defun iedit-add-next-occurrence-overlay (occurrence-exp &optional point)
"Create next occurrence overlay for `occurrence-exp'."
+ (iedit-add-occurrence-overlay occurrence-exp point t))
+
+(defun iedit-add-previous-occurrence-overlay (occurrence-exp &optional point)
+ "Create previous occurrence overlay for `occurrence-exp'."
+ (iedit-add-occurrence-overlay occurrence-exp point nil))
+
+(defun iedit-add-occurrence-overlay (occurrence-exp point forward)
+ "Create next or previous occurrence overlay for `occurrence-exp'."
+ (or point
+ (setq point (point)))
(let ((case-fold-search (not iedit-case-sensitive-local)))
- (when (re-search-forward occurrence-exp nil t)
- (push (iedit-make-occurrence-overlay (match-beginning 0)
- (match-end 0))
- iedit-occurrences-overlays)
- (sort iedit-occurrences-overlays
- (lambda (left right)
- (< (overlay-start left) (overlay-start right))))
- (message "Add one match for \"%s\"" (iedit-printable occurrence-exp))
- (if iedit-unmatched-lines-invisible
- (iedit-hide-unmatched-lines iedit-occurrence-context-lines)))))
+ (save-excursion
+ (goto-char point)
+ (if (not (if forward
+ (re-search-forward occurrence-exp nil t)
+ (re-search-backward occurrence-exp nil t)))
+ (message "No matches.")
+ (if (or (iedit-find-overlay-at-point (match-beginning 0)
'iedit-occurrence-overlay-name)
+ (iedit-find-overlay-at-point (match-end 0)
'iedit-occurrence-overlay-name))
+ (error "Conflict region."))
+ (push (iedit-make-occurrence-overlay (match-beginning 0)
+ (match-end 0))
+ iedit-occurrences-overlays)
+ (sort iedit-occurrences-overlays
+ (lambda (left right)
+ (< (overlay-start left) (overlay-start right))))
+ (message "Add one match for \"%s\"" (iedit-printable occurrence-exp))
+ (if iedit-unmatched-lines-invisible
+ (iedit-hide-unmatched-lines iedit-occurrence-context-lines))))))
(defun iedit-add-region-as-occurrence (beg end)
"Add region as an occurrence.
@@ -229,14 +248,14 @@ there are."
(error "No region"))
(if (null iedit-occurrences-overlays)
(push
- (iedit-make-occurrence-overlay beg end iedit-occurrence-keymap-default)
+ (iedit-make-occurrence-overlay beg end)
iedit-occurrences-overlays)
(or (= (- end beg) (iedit-occurrence-string-length))
(error "Wrong region."))
(if (or (iedit-find-overlay-at-point beg 'iedit-occurrence-overlay-name)
(iedit-find-overlay-at-point end 'iedit-occurrence-overlay-name))
(error "Conflict region."))
- (push (iedit-make-occurrence-overlay beg end
iedit-occurrence-keymap-default)
+ (push (iedit-make-occurrence-overlay beg end)
iedit-occurrences-overlays)
(sort iedit-occurrences-overlays
(lambda (left right)
@@ -483,7 +502,7 @@ value of `iedit-occurrence-context-lines' is used for this
time."
(defun iedit-hide-unmatched-lines (context-lines)
"Hide unmatched lines using invisible overlay.
-This function depends on the order of iedit-occurrences-overlays. TODO"
+This function depends on the order of `iedit-occurrences-overlays'. TODO"
(let ((prev-occurrence-end 1)
(unmatched-lines nil))
(save-excursion
- [nongnu] elpa/iedit 1d32922c04 089/301: Run after-change-functions hook for every occurrence, (continued)
- [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, 2022/01/10
- [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 <=
- [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
- [nongnu] elpa/iedit 541eab7b6b 108/301: Add document for iedit-rectangle-mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4b1416f83f 131/301: refactor out common test code in "test-util", ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit ceb729863b 153/301: Update iedit-lib.el, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit b3ebd84769 137/301: Merge pull request #29 from jorgenschaefer/elpa-package, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 27de77eda5 133/301: add test to ensure padding of EOL happens to make up rectangle, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7a35f3bd06 157/301: Add overlay priority option, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c274e6423b 200/301: Quit iedit mode if the number of occurrence is zero, ELPA Syncer, 2022/01/10