[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d260c48 322/399: swiper.el: Obey search-invisible
From: |
Oleh Krehel |
Subject: |
[elpa] master d260c48 322/399: swiper.el: Obey search-invisible |
Date: |
Sat, 20 Jul 2019 14:57:49 -0400 (EDT) |
branch: master
commit d260c48f88c3d500771a9764d0d4d13e45a6885b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el: Obey search-invisible
When `search-invisible' is nil, `swiper' and `swiper-isearch' will not
match hidden text (e.g. hidden Org outlines).
Fixes #1739
---
swiper.el | 58 ++++++++++++++++++++++++++++++++++------------------------
1 file changed, 34 insertions(+), 24 deletions(-)
diff --git a/swiper.el b/swiper.el
index 0ee0a9f..7c645c2 100644
--- a/swiper.el
+++ b/swiper.el
@@ -497,7 +497,7 @@ numbers; replaces calculating the width from buffer line
count."
(1+ (floor (log n-lines 10)))))
(setq swiper--format-spec
(format "%%-%dd " swiper--width))
- (let ((line-number 0)
+ (let ((line-number 1)
(advancer (if swiper-use-visual-line
(lambda (arg) (line-move arg t))
#'forward-line))
@@ -506,18 +506,20 @@ numbers; replaces calculating the width from buffer line
count."
(goto-char (point-min))
(swiper-font-lock-ensure)
(while (< (point) (point-max))
- (let ((str (swiper--line)))
- (setq str (ivy-cleanup-string str))
- (let ((line-number-str
- (format swiper--format-spec (cl-incf line-number))))
- (if swiper-include-line-number-in-search
- (setq str (concat line-number-str str))
+ (when (swiper-match-usable-p)
+ (let ((str (swiper--line)))
+ (setq str (ivy-cleanup-string str))
+ (let ((line-number-str
+ (format swiper--format-spec line-number)))
+ (if swiper-include-line-number-in-search
+ (setq str (concat line-number-str str))
+ (put-text-property
+ 0 1 'display line-number-str str))
(put-text-property
- 0 1 'display line-number-str str))
- (put-text-property
- 0 1 'swiper-line-number line-number-str str))
- (push str candidates))
- (funcall advancer 1))
+ 0 1 'swiper-line-number line-number-str str))
+ (push str candidates)))
+ (funcall advancer 1)
+ (cl-incf line-number))
(nreverse candidates))))))
(defvar swiper--opoint 1
@@ -728,7 +730,7 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
(setq swiper-invocation-face
(plist-get (text-properties-at (point)) 'face))
(let ((preselect
- (if swiper-use-visual-line
+ (if (or swiper-use-visual-line (null search-invisible))
(count-screen-lines
(point-min)
(save-excursion (beginning-of-visual-line) (point)))
@@ -1267,6 +1269,13 @@ come back to the same place as when \"a\" was initially
entered.")
(with-ivy-window
(swiper--isearch-function str)))
+(defun swiper-match-usable-p ()
+ (or search-invisible
+ (not (cl-find-if
+ (lambda (ov)
+ (invisible-p (overlay-get ov 'invisible)))
+ (overlays-at (point))))))
+
(defun swiper--isearch-function (str)
(let* ((case-fold-search (ivy--case-fold-p str))
(re-full (funcall ivy--regex-function str))
@@ -1282,17 +1291,18 @@ come back to the same place as when \"a\" was initially
entered.")
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
- (unless idx-found
- (when (or
- (eq (match-beginning 0) pt-hist)
- (>= (match-beginning 0) (cdar
swiper--isearch-point-history)))
- (push (cons str (match-beginning 0))
swiper--isearch-point-history)
- (setq idx-found idx)))
- (cl-incf idx)
- (let ((pos (if swiper-goto-start-of-match
- (match-beginning 0)
- (point))))
- (push pos cands))))
+ (when (swiper-match-usable-p)
+ (unless idx-found
+ (when (or
+ (eq (match-beginning 0) pt-hist)
+ (>= (match-beginning 0) (cdar
swiper--isearch-point-history)))
+ (push (cons str (match-beginning 0))
swiper--isearch-point-history)
+ (setq idx-found idx)))
+ (cl-incf idx)
+ (let ((pos (if swiper-goto-start-of-match
+ (match-beginning 0)
+ (point))))
+ (push pos cands)))))
(setq ivy--old-re re)
(when idx-found
(ivy-set-index idx-found))
- [elpa] master 4a37e1e 314/399: swiper.el (swiper-query-replace): Make eval-style replacement more accessible, (continued)
- [elpa] master 4a37e1e 314/399: swiper.el (swiper-query-replace): Make eval-style replacement more accessible, Oleh Krehel, 2019/07/20
- [elpa] master dd2d495 312/399: swiper.el (swiper-all-thing-at-point): Add, Oleh Krehel, 2019/07/20
- [elpa] master 0576b61 315/399: .github/FUNDING.yml: Add, Oleh Krehel, 2019/07/20
- [elpa] master d060eea 313/399: swiper.el (swiper-query-replace): Add query-replace-compile-replacement, Oleh Krehel, 2019/07/20
- [elpa] master 09b9508 321/399: ivy.el (ivy--find-file-action): Fix for virtual buffers, Oleh Krehel, 2019/07/20
- [elpa] master 7d46450 311/399: Add more information about the collection argument in `ivy-read`., Oleh Krehel, 2019/07/20
- [elpa] master 676a8ee 318/399: swiper.el (swiper-isearch-current-match): Remove unused face, Oleh Krehel, 2019/07/20
- [elpa] master ba626e7 317/399: ivy.el (ivy-next-history-element): Use minibuffer-default for dired-dwim-target, Oleh Krehel, 2019/07/20
- [elpa] master 51e765e 316/399: ivy.el (ivy-partial): Return nil when comletion was not updated, Oleh Krehel, 2019/07/20
- [elpa] master 16d2268 320/399: Fix ivy-push/switch-view windows layout, Oleh Krehel, 2019/07/20
- [elpa] master d260c48 322/399: swiper.el: Obey search-invisible,
Oleh Krehel <=
- [elpa] master de8842e 323/399: Add ivy-switch-buffer-map to counsel-switch-buffer, Oleh Krehel, 2019/07/20
- [elpa] master 0d87297 326/399: counsel.el (counsel-open-buffer-file-externally): Cleanup, Oleh Krehel, 2019/07/20
- [elpa] master 7defba2 327/399: ivy.el (ivy-avy): Fix when there's a scroll, Oleh Krehel, 2019/07/20
- [elpa] master 07c65b3 325/399: ivy.el (ivy--set-index-dynamic-collection): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 400d56f 319/399: counsel.el (counsel-open-buffer-file-externally): New function, Oleh Krehel, 2019/07/20
- [elpa] master 704b1de 328/399: ivy.el (ivy-avy): Allow to scroll with "C-v" and "M-v", Oleh Krehel, 2019/07/20
- [elpa] master 7183491 332/399: ivy.el (ivy--minibuffer-setup): Avoid extra call to ivy--exhibit, Oleh Krehel, 2019/07/20
- [elpa] master a249d15 329/399: ivy-test.el (ivy-avy): Only run if avy is installed, Oleh Krehel, 2019/07/20
- [elpa] master 15f8e10 330/399: .travis.yml: Add emacs-25.3 and emacs-26.2, Oleh Krehel, 2019/07/20
- [elpa] master d752db5 333/399: counsel.el (counsel-find-file-extern-extensions): New defcustom, Oleh Krehel, 2019/07/20