[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search adbf76d 262/332: [el-search] Open invisible t
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search adbf76d 262/332: [el-search] Open invisible text |
Date: |
Tue, 1 Dec 2020 15:48:59 -0500 (EST) |
branch: externals/el-search
commit adbf76da82d8dc78cf77375f1431bd2761f35c45
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
[el-search] Open invisible text
Make el-search open invisible text like isearch. We only define glue
code functions that call the respective isearch functions and use
these in the relevant places. We also make
'el-search--scroll-sexp-in-view' do calculations based on visible
lines to make it work with invisible text as expected.
Bump version to 1.7.8.
* packages/el-search/el-search.el (el-search-open-invisible): New
variable.
(el-search-hide-immediately): New user option.
(el-search-unhide-invisible, el-search-rehide-invisible): New
functions.
(el-search-hl-sexp): Call 'el-search-unhide-invisible'.
(el-search-hl-remove): Call 'el-search-rehide-invisible'.
(el-search--scroll-sexp-in-view): Do calculation based on visible
lines.
---
NEWS | 4 ++++
el-search.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/NEWS b/NEWS
index af00d2f..863d2f5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
Some of the user visible news were:
+Version: 1.7.8
+
+ Similar to isearch, el-search now opens invisible text.
+
Version: 1.7.7
The new scroll commands `el-search-scroll-down' and
diff --git a/el-search.el b/el-search.el
index 6cd83d8..a11e9d4 100644
--- a/el-search.el
+++ b/el-search.el
@@ -7,7 +7,7 @@
;; Created: 29 Jul 2015
;; Keywords: lisp
;; Compatibility: GNU Emacs 25
-;; Version: 1.7.7
+;; Version: 1.7.8
;; Package-Requires: ((emacs "25") (stream "2.2.4") (cl-print "1.0"))
@@ -612,6 +612,26 @@ consulted by all streams
`el-search-stream-of-directory-files'
returns."
:type 'boolean)
+(defvar el-search-open-invisible t
+ ;; Not an option because I don't know if a nil value is useful to
+ ;; anyone.
+ "Whether el-search should open invisible text.
+When non-nil, el-search automatically opens text hidden by
+\"outline.el\" or \"hideshow.el\" to make the current match
+visible, like isearch does by default. See also
+`el-search-hide-immediately'.
+
+Note that el-search always matches invisible text, this option
+only controls whether matches are made visible.")
+
+(defcustom el-search-hide-immediately t
+ "If non-nil, re-hide an invisible match right away.
+This is the exact counterpart of `isearch-hide-immediately': it
+controls whether opened invisible text is re-hidden already while
+searching after leaving the opened area, or only after exiting
+the search. The last successful match is never hidden."
+ :type 'boolean)
+
;;;; Helpers and Definitions
@@ -690,6 +710,22 @@ nil."
(cons defun-beg defun-end)
nil)))))))
+(defun el-search-unhide-invisible (&optional beg end)
+ (when el-search-open-invisible
+ (cl-callf or beg (point))
+ (let ((isearch-hide-immediately el-search-hide-immediately)
+ (search-invisible 'open)
+ (isearch-old-opened-overlays (copy-sequence
isearch-opened-overlays)))
+ (isearch-range-invisible beg (or end (1+ beg)))
+ (when (cl-set-difference
+ ;; Closing overlays may make additional text visible
+ isearch-old-opened-overlays isearch-opened-overlays)
+ (el-search--after-scroll nil (window-start))))))
+
+(defun el-search-rehide-invisible ()
+ (when el-search-open-invisible
+ (isearch-clean-overlays)))
+
(defun el-search-with-short-term-memory (function)
"Wrap FUNCTION to cache the last arguments/result pair."
(let ((cached nil))
@@ -2106,19 +2142,14 @@ absolute name must be matched by all of them."
(scroll-up (min
(max
;; make at least sexp end + a small margin visible
- (- (line-number-at-pos (cadr bounds))
- (line-number-at-pos (window-end))
- (- (max 2 (/ wheight 4))))
+ (+ (count-screen-lines (cadr bounds) (window-end))
+ (max 2 (/ wheight 4)))
;; also try to center current sexp
- (- (/ ( + (line-number-at-pos (car bounds))
- (line-number-at-pos (cadr bounds)))
- 2)
- (/ (+ (line-number-at-pos (window-start))
- (line-number-at-pos (window-end)))
- 2)))
+ (/ (+ (count-screen-lines (window-start) (car bounds))
+ (count-screen-lines (window-end) (cadr bounds)))
+ 2))
;; but also ensure at least a small margin is left
between point and window start
- (- (line-number-at-pos (car bounds))
- (line-number-at-pos (window-start))
+ (- (count-screen-lines (car bounds) (window-start))
3)))
((beginning-of-buffer end-of-buffer) nil)))))
@@ -2135,6 +2166,7 @@ absolute name must be matched by all of them."
;; must apparently be displayed for this to work.
(while (not (eq t (frame-visible-p (selected-frame))))
(sleep-for .1))
+ (apply #'el-search-unhide-invisible bounds)
(redisplay)
(el-search--scroll-sexp-in-view bounds))
@@ -2281,7 +2313,8 @@ local binding of `window-scroll-functions'."
(delete-overlay el-search-hl-overlay))
(remove-hook 'window-scroll-functions #'el-search--after-scroll t)
(mapc #'delete-overlay el-search-hl-other-overlays)
- (setq el-search-hl-other-overlays '()))
+ (setq el-search-hl-other-overlays '())
+ (el-search-rehide-invisible))
(defun el-search-hl-post-command-fun ()
(pcase this-command
- [elpa] externals/el-search 3da4529 316/332: [el-search] Minor tweaks and version bump, (continued)
- [elpa] externals/el-search 3da4529 316/332: [el-search] Minor tweaks and version bump, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e96c51e 319/332: [el-search] Key syntax cleanup, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search f091ed5 320/332: [el-search] Prefer rx forms to stringish regexps, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 47ee6b1 226/332: Improve working of `el-search-kill-left-over-search-buffers', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e21a53d 240/332: [el-search] Use current buffer to check for matches in replacement, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 188fb4a 259/332: [el-search] Minor tweaks and bump version to 1.7.5, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d909f2e 260/332: [el-search] Follow-ups to transient map handling, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d9950e1 264/332: [el-search] Fix nested match issues in *El Occur*, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d9b2ff6 257/332: [el-search] Extend meaning of C-J prefix arg, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 656869c 235/332: * el-search/el-search.el: Fix heuristic matcher for 'nil, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search adbf76d 262/332: [el-search] Open invisible text,
Stefan Monnier <=
- [elpa] externals/el-search 60ad12e 268/332: [el-search] Small fix in el-search--reset-wrap-flag, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 73a15d2 274/332: [el-search] Stop for problematic comments, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 4961830 273/332: [el-search] Make replacement editable and ediff'able, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search da1f46b 282/332: [el-search] Make mouse clicks not abort the search, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2a098da 293/332: [el-search] Unify go-to-previous/next-match key bindings, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d4f8b3b 289/332: [el-search] Tweak my last commit "Add menus", Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 4d81139 299/332: [el-search] Fine tune separator for splicing replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 424138b 307/332: [el-search] Tweak 'display-buffer' actions, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d9acf3a 314/332: [el-search] Fix sanity check regarding comments, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 13fc32d 323/332: [el-search] Fix a highlighting corner case, Stefan Monnier, 2020/12/01