branch: elpa/isl
commit 722b4e6bb99754be2413fa3229ea9471e169de16
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>
Fix jumping to iedit when narrowed to defun
---
isearch-light.el | 63 +++++++++++++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 24 deletions(-)
diff --git a/isearch-light.el b/isearch-light.el
index 9a8672badc0..9c6a6e4cfa5 100644
--- a/isearch-light.el
+++ b/isearch-light.el
@@ -72,6 +72,8 @@
(defvar isl--case-fold-choices-iterator nil)
(defvar isl-help-buffer-name "*isl help*")
(defvar isl--hidding nil)
+(defvar isl--point-min nil)
+(defvar isl--point-max nil)
(defvar isl-help-string
"* Isearch-light help\n
** Commands
@@ -484,26 +486,29 @@ the initial position i.e. the position before launching
`isl-search'."
(run-at-time
0.1 nil
(lambda ()
- (let ((case-fold-search (isl-set-case-fold-search regexp))
- result)
- (setq mark-active nil)
- (run-hooks 'deactivate-mark-hook)
- (when iedit-mode
- (iedit-lib-cleanup))
- (advice-add 'iedit-start :around #'isl--advice-iedit-start)
- (unwind-protect
- (progn
- (setq result
- (catch 'not-same-length
- (iedit-start regexp (point-min) (point-max))))
- (cond ((not iedit-occurrences-overlays)
- (message "No matches found for %s" regexp)
- (iedit-done))
- ((equal result 'not-same-length)
- (message "Matches are not the same length.")
- (iedit-done)))
- (goto-char pos))
- (advice-remove 'iedit-start #'isl--advice-iedit-start)))))
+ (save-restriction
+ (when (and isl--point-min isl--point-max)
+ (narrow-to-region isl--point-min isl--point-max))
+ (let ((case-fold-search (isl-set-case-fold-search regexp))
+ result)
+ (setq mark-active nil)
+ (run-hooks 'deactivate-mark-hook)
+ (when iedit-mode
+ (iedit-lib-cleanup))
+ (advice-add 'iedit-start :around #'isl--advice-iedit-start)
+ (unwind-protect
+ (progn
+ (setq result
+ (catch 'not-same-length
+ (iedit-start regexp (point-min) (point-max))))
+ (cond ((not iedit-occurrences-overlays)
+ (message "No matches found for %s" regexp)
+ (iedit-done))
+ ((equal result 'not-same-length)
+ (message "Matches are not the same length.")
+ (iedit-done)))
+ (goto-char pos))
+ (advice-remove 'iedit-start #'isl--advice-iedit-start))))))
(abort-recursive-edit)))
(put 'isl-jump-to-iedit-mode 'no-helm-mx t)
@@ -838,10 +843,8 @@ appended at end."
(markdown-show-entry)))
(error nil)))))
-;;;###autoload
-(defun isl-search ()
+(defun isl-search-1 ()
"Start incremental searching in current buffer."
- (interactive)
(setq isl-initial-pos (point)
isl-pattern ""
isl--direction 'forward
@@ -858,13 +861,25 @@ appended at end."
(and (not (string= isl-pattern ""))
(recenter))))
+;;;###autoload
+(defun isl-search ()
+ "Start incremental searching in current buffer."
+ (interactive)
+ (setq isl--point-min nil
+ isl--point-max nil)
+ (isl-search-1))
+
;;;###autoload
(defun isl-narrow-to-defun ()
"Start incremental searching in current defun."
(interactive)
+ (setq isl--point-min nil
+ isl--point-max nil)
(save-restriction
(narrow-to-defun)
- (isl-search)))
+ (setq isl--point-min (point-min)
+ isl--point-max (point-max))
+ (isl-search-1)))
(provide 'isearch-light)