[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit f09b675c67 249/301: Add an option 'iedit-auto-narrow
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit f09b675c67 249/301: Add an option 'iedit-auto-narrow' |
Date: |
Mon, 10 Jan 2022 22:59:07 -0500 (EST) |
branch: elpa/iedit
commit f09b675c6741d9d836182dc138894671b0842665
Author: victor <victorhge@gmail.com>
Commit: Victor <victorhge@gmail.com>
Add an option 'iedit-auto-narrow'
If no-nil, the buffer is narrowed temporairily if iedit-mode is enabled on
current defun.
---
iedit-tests.el | 7 +++++--
iedit.el | 45 +++++++++++++++++++++++++++++++++++----------
2 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/iedit-tests.el b/iedit-tests.el
index cc65378710..6b90e20078 100644
--- a/iedit-tests.el
+++ b/iedit-tests.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2018-09-19 11:11:07 Victor Ren>
+;; Time-stamp: <2018-11-14 17:48:26 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Version: 0.9.9.9
;; X-URL: https://www.emacswiki.org/emacs/Iedit
@@ -613,11 +613,14 @@ arfoo
(emacs-lisp-mode)
(goto-char 5)
(iedit-mode)
+ (setq iedit-auto-narrow t)
(iedit-restrict-function)
(should (= 1 (length iedit-occurrences-overlays)))
+ (should (equal (buffer-narrowed-p) iedit-is-narrowed))
(iedit-mode)
(goto-char 13)
- (iedit-mode-toggle-on-function)
+ (setq iedit-auto-narrow nil)
+ (call-interactively 'iedit-mode-toggle-on-function)
(should (= 4 (length iedit-occurrences-overlays)))
(iedit-mode)
(iedit-mode)
diff --git a/iedit.el b/iedit.el
index 444c8f520a..8612abfcc4 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010, 2011, 2012 Victor Ren
-;; Time-stamp: <2018-11-09 14:17:05 Victor Ren>
+;; Time-stamp: <2018-11-14 17:49:13 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.9.9.9
@@ -111,6 +111,16 @@ isearch-mode-map, esc-map and help-map."
(defvar iedit-mode nil) ;; Name of the minor mode
+(defcustom iedit-auto-narrow nil
+ "If no-nil, the buffer is narrowed temporairily if iedit-mode
+is enabled on current defun."
+ :type 'boolean
+ :group 'iedit)
+
+(defvar iedit-is-narrowed nil
+ "This is buffer local variable which indicates if the buffer is
+ narrowed by iedit temporarily.")
+
(defvar iedit-use-symbol-boundaries t
"If no-nil, matches have to start and end at symbol boundaries. Otherwise,
matches starts and end at word boundaries.")
@@ -182,6 +192,7 @@ This should be set before Iedit is loaded."
(make-variable-buffer-local 'iedit-initial-string-local)
(make-variable-buffer-local 'iedit-initial-region)
(make-variable-buffer-local 'iedit-default-occurrence-local)
+(make-variable-buffer-local 'iedit-is-narrowed)
(or (assq 'iedit-mode minor-mode-alist)
(nconc minor-mode-alist
@@ -393,7 +404,10 @@ Keymap used within overlays:
(deactivate-mark t)
(mark-defun)
(setq beg (region-beginning))
- (setq end (region-end))))
+ (setq end (region-end)))
+ (when (and iedit-auto-narrow (not (buffer-narrowed-p)))
+ (narrow-to-region beg end)
+ (setq iedit-is-narrowed t)))
((and (= 1 (prefix-numeric-value arg))
(not (iedit-region-active)))
(let ((region (bounds-of-thing-at-point 'symbol)))
@@ -562,6 +576,9 @@ the initial string globally."
(iedit-cleanup)
+ (when iedit-is-narrowed
+ (widen)
+ (setq iedit-is-narrowed nil))
(setq iedit-initial-string-local nil)
(setq iedit-mode nil)
(force-mode-line-update)
@@ -573,10 +590,12 @@ the initial string globally."
(defun iedit-mode-on-action (&optional arg)
"Turn off Iedit mode or restrict it in a region if region is active."
- (if (iedit-region-active)
- (iedit-restrict-region (region-beginning) (region-end) arg)
- (iedit-done)))
-
+ (cond ((iedit-region-active)
+ (iedit-restrict-region (region-beginning) (region-end) arg))
+ ((and arg
+ (= 0 (prefix-numeric-value arg)))
+ (iedit-restrict-function nil))
+ (t (iedit-done))))
;;;###autoload
(defun iedit-mode-toggle-on-function ()
@@ -636,10 +655,16 @@ the initial string globally."
(interactive "P")
(let (beg end)
(save-excursion
+ (deactivate-mark t)
(mark-defun)
(setq beg (region-beginning))
(setq end (region-end)))
- (iedit-restrict-region beg end arg))
+ (iedit-restrict-region beg end arg)
+ (when (and (not arg)
+ iedit-auto-narrow
+ (not (buffer-narrowed-p)))
+ (narrow-to-region beg end)
+ (setq iedit-is-narrowed t)))
(message "Restricted in current function, %d matches."
(length iedit-occurrences-overlays)))
@@ -729,9 +754,9 @@ prefix, bring the top of the region back down one
occurrence."
(goto-char pos)
(force-mode-line-update))))
-(defun iedit-restrict-region (beg end &optional inclusive)
+(defun iedit-restrict-region (beg end &optional exclusive)
"Restricting Iedit mode in a region."
- (if (null (iedit-find-overlay beg end 'iedit-occurrence-overlay-name
inclusive))
+ (if (null (iedit-find-overlay beg end 'iedit-occurrence-overlay-name
exclusive))
(iedit-done)
(when iedit-buffering
(iedit-stop-buffering))
@@ -739,7 +764,7 @@ prefix, bring the top of the region back down one
occurrence."
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
(iedit-show-all)
- (iedit-cleanup-occurrences-overlays beg end inclusive)
+ (iedit-cleanup-occurrences-overlays beg end exclusive)
(if iedit-unmatched-lines-invisible
(iedit-hide-unmatched-lines iedit-occurrence-context-lines))
(force-mode-line-update)))
- [nongnu] elpa/iedit d2f08e8862 163/301: Provide functions to narrow around current-line, (continued)
- [nongnu] elpa/iedit d2f08e8862 163/301: Provide functions to narrow around current-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 27dbbdda0b 162/301: Split iedit-occurrence-update into two functions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9a40f6fa36 205/301: check if mc present, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 97ad9d0600 254/301: removed downcasing the from-string in iedit-lib.el/iedit-replace-occurrences to allow case sensitivity., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7a3725cd04 267/301: Small optimizations, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 42654ba7ed 266/301: iedit-rect.el: Don't set iedit-initial-string-local, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d335d6842a 183/301: Check if the default keybinding of iedit-mode is taken, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e575cbf569 256/301: Allow adding a incremented number in each occurence, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 796ee5298d 237/301: fix the key conflict with yas-minor-mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit e1decb37e5 245/301: Fix verion numbers, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit f09b675c67 249/301: Add an option 'iedit-auto-narrow',
ELPA Syncer <=
- [nongnu] elpa/iedit 44601e01fa 269/301: fix an issue with electric pair, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3f9eed229e 232/301: Allow custom mode-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 9c08a48c88 281/301: Remove the workaround for slow c-before-change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 01767ddca3 258/301: Fix a failed testcase in batch mode, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7e507b370b 255/301: Set the FIXEDCASE argument of replace-match in iedit-replace-occurrences to T to allow preserving case., ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 745ea6f812 239/301: Rename iedit-toggle-unmatched-lines-visible to iedit-show/hide-unmatched-lines, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit dfed75064e 285/301: Save and restore `line-move-ignore-invisible', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit c448864424 216/301: Remove iedit-unmatched-lines-invisible-default, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5fdf89edc9 238/301: Fix switch to mc mode problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit de54411d0e 220/301: Detect markup tag only if region inactive, ELPA Syncer, 2022/01/10