[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit e4d67bdb06 120/301: Separate iedit-mode-from-isearch
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit e4d67bdb06 120/301: Separate iedit-mode-from-isearch |
Date: |
Mon, 10 Jan 2022 22:58:56 -0500 (EST) |
branch: elpa/iedit
commit e4d67bdb06d8e49820adbb8759430853375d9aa9
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>
Separate iedit-mode-from-isearch
Remove iedit-case-sensitive-local and iedit-case-sensistive-global
Do not start Iedit mode if matches are not the same length
Define default key bindings when `iedit-toogle-key-default' is defined.
If `iedit-toogle-key-default' is nil, default key bindings are not going to
be defined.
---
iedit-lib.el | 24 +++++++++-----------
iedit.el | 72 +++++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 54 insertions(+), 42 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 2d487d2857..5af1785733 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-09-06 11:07:10 Victor Ren>
+;; Time-stamp: <2012-09-07 16:28:18 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.97
@@ -75,14 +75,10 @@ occurrence overlay is used to provide a different face
configurable via `iedit-occurrence-face'. The list is sorted by
the position of overlays.")
-(defvar iedit-case-sensitive-local iedit-case-sensitive-default
+(defvar iedit-case-sensitive iedit-case-sensitive-default
"This is buffer local variable.
If no-nil, matching is case sensitive.")
-(defvar iedit-case-sensitive-global iedit-case-sensitive-default
- "This is global variable.
-If no-nil, matching is case sensitive.")
-
(defvar iedit-unmatched-lines-invisible nil
"This is buffer local variable which indicates whether
unmatched lines are hided.")
@@ -125,7 +121,7 @@ is not applied to other occurrences when it is true.")
(make-variable-buffer-local 'iedit-occurrences-overlays)
(make-variable-buffer-local 'iedit-unmatched-lines-invisible)
-(make-variable-buffer-local 'iedit-case-sensitive-local)
+(make-local-variable 'iedit-case-sensitive)
(make-variable-buffer-local 'iedit-forward-success)
(make-variable-buffer-local 'iedit-before-modification-string)
(make-variable-buffer-local 'iedit-before-modification-undo-list)
@@ -170,7 +166,7 @@ is not applied to other occurrences when it is true.")
(defvar iedit-occurrence-keymap 'iedit-occurrence-keymap-default
"Keymap used within occurrence overlays.
It should be set before occurrence overlay is created.")
-(make-local-variable 'iedit-occurrence-context-lines)
+(make-local-variable 'iedit-occurrence-keymap)
(defun iedit-help-for-occurrences ()
"Display `iedit-occurrence-keymap-default'"
@@ -187,21 +183,21 @@ It should be set before occurrence overlay is created.")
(substitute-command-keys "\\[iedit-last-occurrence]")
":first/last "
)))
-(defun iedit-make-occurrences-overlays (occurrence-exp beg end)
- "Create occurrence overlays for `occurrence-exp' in a region.
+(defun iedit-make-occurrences-overlays (occurrence-regexp beg end)
+ "Create occurrence overlays for `occurrence-regexp' in a region.
Return the number of occurrences."
(setq iedit-aborting nil)
(setq iedit-occurrences-overlays nil)
;; Find and record each occurrence's markers and add the overlay to the
occurrences
(let ((counter 0)
- (case-fold-search (not iedit-case-sensitive-local)))
+ (case-fold-search (not iedit-case-sensitive)))
(save-excursion
(goto-char beg)
- (while (re-search-forward occurrence-exp end t)
+ (while (re-search-forward occurrence-regexp end t)
(push (iedit-make-occurrence-overlay (match-beginning 0) (match-end 0))
iedit-occurrences-overlays)
(setq counter (1+ counter)))
- (message "%d matches for \"%s\"" counter (iedit-printable
occurrence-exp))
+ (message "%d matches for \"%s\"" counter (iedit-printable
occurrence-regexp))
(when (/= 0 counter)
(setq iedit-occurrences-overlays (nreverse iedit-occurrences-overlays))
(if iedit-unmatched-lines-invisible
@@ -220,7 +216,7 @@ Return the number of occurrences."
"Create next or previous occurrence overlay for `occurrence-exp'."
(or point
(setq point (point)))
- (let ((case-fold-search (not iedit-case-sensitive-local)))
+ (let ((case-fold-search (not iedit-case-sensitive)))
(save-excursion
(goto-char point)
(if (not (if forward
diff --git a/iedit.el b/iedit.el
index 78873b0e27..0fb10e81e3 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2012-09-05 09:47:56 Victor Ren>
+;; Time-stamp: <2012-09-07 17:26:42 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.97
@@ -200,10 +200,11 @@ This is like `describe-bindings', but displays only Iedit
keys."
(describe-function 'iedit-mode)))
;;; Default key bindings:
-(define-key global-map iedit-toogle-key-default 'iedit-mode)
-(define-key isearch-mode-map iedit-toogle-key-default 'iedit-mode)
-(define-key esc-map iedit-toogle-key-default 'iedit-execute-last-modification)
-(define-key help-map iedit-toogle-key-default 'iedit-mode-toggle-on-function)
+(when iedit-toogle-key-default
+ (define-key global-map iedit-toogle-key-default 'iedit-mode)
+ (define-key isearch-mode-map iedit-toogle-key-default
'iedit-mode-from-isearch)
+ (define-key esc-map iedit-toogle-key-default
'iedit-execute-last-modification)
+ (define-key help-map iedit-toogle-key-default
'iedit-mode-toggle-on-function))
;; Avoid to restore Iedit mode when restoring desktop
(add-to-list 'desktop-minor-mode-handlers
@@ -273,9 +274,9 @@ If region active, Iedit mode is limited within the current
region.
With repeated universal prefix argument, the occurrence when
-Iedit mode is turned off last time (might be in other buffer) is used
-as occurrence. If region active, Iedit mode is limited within
-the current region.
+Iedit mode is turned off last time (might be in other buffer) is
+used as occurrence. If region active, Iedit mode is limited
+within the current region.
If Iedit mode is on and region is active, Iedit mode is
restricted in the region, e.g. the occurrences outside of the
@@ -316,10 +317,6 @@ Keymap used within overlays:
((iedit-region-active)
(setq occurrence (buffer-substring-no-properties
(mark) (point))))
- ((and isearch-mode (not (string= isearch-string "")))
- (setq occurrence (buffer-substring-no-properties
- (point) isearch-other-end))
- (isearch-exit))
((and iedit-current-symbol-default (current-word t))
(setq occurrence (current-word))
(when iedit-only-at-symbol-boundaries
@@ -337,30 +334,50 @@ Keymap used within overlays:
(setq iedit-only-complete-symbol-local complete-symbol)
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
- (setq iedit-case-sensitive-local iedit-case-sensitive-default)
- (iedit-start occurrence beg end))))
-
-(defun iedit-start (occurrence-exp beg end)
- "Start Iedit mode for the OCCURRENCE-EXP in the current buffer."
+ (iedit-start (iedit-regexp-quote occurrence) beg end))))
+
+(defun iedit-mode-from-isearch (regexp)
+ "Start Iedit mode using last search string as the regexp."
+ (interactive
+ (let ((regexp (cond
+ ((functionp isearch-word)
+ (funcall isearch-word isearch-string))
+ (isearch-word (word-search-regexp isearch-string))
+ (isearch-regexp isearch-string)
+ (t (regexp-quote isearch-string)))))
+ (list regexp)))
+ (isearch-exit)
+ (iedit-start regexp (point-min) (point-max))
+ ;; TODO: reconsider how to avoid the loop in iedit-same-length
+ (if (iedit-same-length)
+ nil
+ (iedit-done)
+ (message "Matches are not the same length.")))
+
+(defun iedit-start (occurrence-regexp beg end)
+ "Start Iedit mode for the `occurrence-regexp' in the current buffer."
(setq iedit-unmatched-lines-invisible
iedit-unmatched-lines-invisible-default)
- (setq iedit-initial-string-local occurrence-exp)
- (iedit-refresh occurrence-exp beg end)
+ (setq iedit-initial-string-local occurrence-regexp)
+ (iedit-start2 occurrence-regexp beg end)
(run-hooks 'iedit-mode-hook)
(add-hook 'kbd-macro-termination-hook 'iedit-done nil t)
(add-hook 'change-major-mode-hook 'iedit-done nil t)
(add-hook 'iedit-aborting-hook 'iedit-done nil t))
-(defun iedit-refresh (occurrence-exp beg end)
+(defun iedit-regexp-quote (exp)
+ "Return a regexp string."
+ (if iedit-only-complete-symbol-local
+ (concat "\\_<" (regexp-quote exp) "\\_>")
+ (regexp-quote exp)))
+
+(defun iedit-start2 (occurrence-regexp beg end)
"Refresh Iedit mode."
- (setq occurrence-exp (regexp-quote occurrence-exp))
(setq iedit-occurrence-keymap iedit-mode-occurrence-keymap)
- (when iedit-only-complete-symbol-local
- (setq occurrence-exp (concat "\\_<" occurrence-exp "\\_>")))
(setq iedit-mode
(propertize
(concat " Iedit:"
(number-to-string
- (iedit-make-occurrences-overlays occurrence-exp beg end)))
+ (iedit-make-occurrences-overlays occurrence-regexp beg end)))
'face
'font-lock-warning-face))
(force-mode-line-update))
@@ -374,7 +391,6 @@ the initial string globally."
(setq iedit-last-occurrence-local (iedit-current-occurrence-string))
(setq iedit-last-occurrence-global iedit-last-occurrence-local)
(setq iedit-last-initial-string-global iedit-initial-string-local)
- (setq iedit-case-sensitive-global iedit-case-sensitive-local)
(iedit-cleanup)
@@ -412,7 +428,7 @@ the initial string globally."
(error "No modification available"))
(let ((occurrence-exp (regexp-quote iedit-last-initial-string-global))
(replacement iedit-last-occurrence-global)
- (case-fold-search (not iedit-case-sensitive-global))
+ (case-fold-search (not iedit-case-sensitive))
beg end)
(when case-fold-search
(setq occurrence-exp (downcase occurrence-exp))
@@ -464,14 +480,14 @@ the initial string globally."
"Toggle case-sensitive matching occurrences.
Todo: how about region"
(interactive)
- (setq iedit-case-sensitive-local (not iedit-case-sensitive-local))
+ (setq iedit-case-sensitive (not iedit-case-sensitive))
(if iedit-buffering
(iedit-stop-buffering))
(setq iedit-last-occurrence-local (iedit-current-occurrence-string))
(when iedit-last-occurrence-local
(remove-overlays nil nil iedit-occurrence-overlay-name t)
(iedit-show-all)
- (iedit-refresh iedit-last-occurrence-local (point-min) (point-max))))
+ (iedit-start2 (iedit-regexp-quote iedit-last-occurrence-local) (point-min)
(point-max))))
(provide 'iedit)
- [nongnu] elpa/iedit 06fac017b4 087/301: explain what "quite different" means in rectangle context in README, (continued)
- [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, 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 <=
- [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
- [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