[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search 56d9f20 165/332: Add some useful commands for
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search 56d9f20 165/332: Add some useful commands for *El Occur* buffers |
Date: |
Tue, 1 Dec 2020 15:48:36 -0500 (EST) |
branch: externals/el-search
commit 56d9f207e9e4f2367259933a4588533fd135af7d
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
Add some useful commands for *El Occur* buffers
Add commands `el-search-occur-next-match',
`el-search-occur-previous-match' for quick navigation between matches
and `el-search-edit-occur-pattern', a command to modify the search
pattern associated with an occur buffer.
---
el-search.el | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/el-search.el b/el-search.el
index 2c0fd0b..56a9773 100644
--- a/el-search.el
+++ b/el-search.el
@@ -2067,6 +2067,18 @@ Use the normal search commands to seize the search."
(defun el-search-occur-revert-function (&rest _)
(el-search--occur el-search-occur-search-object t))
+(defun el-search-edit-occur-pattern (new-pattern)
+ "Change the search pattern associated with this occur buffer.
+Prompt for a new pattern and revert the occur buffer."
+ (interactive (list (let ((el-search--initial-mb-contents
+ (el-search--pp-to-string
+ (el-search-object-pattern
el-search-occur-search-object))))
+ (el-search--read-pattern-for-interactive))))
+ (setf (el-search-object-pattern el-search-occur-search-object)
+ new-pattern)
+ (el-search-compile-pattern-in-search el-search-occur-search-object)
+ (revert-buffer))
+
(defun el-search-occur-jump-to-match ()
(interactive)
(if (button-at (point))
@@ -2092,6 +2104,32 @@ Use the normal search commands to seize the search."
'from-here)
(setq-local el-search-keep-hl 'once))))))
+(defun el-search-occur--next-match (&optional backwards)
+ (let ((done nil) (pos (point)))
+ (when-let ((this-ov (cl-some (lambda (ov) (and (overlay-get ov
'el-search-match) ov))
+ (overlays-at pos))))
+ (setq pos (funcall (if backwards #'overlay-start #'overlay-end)
this-ov)))
+ (while (and (not done) (setq pos (funcall (if backwards
#'previous-single-char-property-change
+
#'next-single-char-property-change)
+ pos 'el-search-match)))
+ (setq done (or (memq pos (list (point-min) (point-max)))
+ (cl-some (lambda (ov) (overlay-get ov 'el-search-match))
+ (overlays-at pos)))))
+ (if (memq pos (list (point-min) (point-max)))
+ (el-search--message-no-log "No match %s this position" (if backwards
"before" "after"))
+ (goto-char pos)
+ (save-excursion (hs-show-block)))))
+
+(defun el-search-occur-next-match ()
+ "Move point to the next match."
+ (interactive)
+ (el-search-occur--next-match))
+
+(defun el-search-occur-previous-match ()
+ "Move point to the previous match."
+ (interactive)
+ (el-search-occur--next-match 'backwards))
+
(declare-function orgstruct-hijacker-org-shifttab-2 'org)
(defun el-search-occur-cycle ()
(interactive)
@@ -2106,6 +2144,9 @@ Use the normal search commands to seize the search."
(define-key map "\r" #'el-search-occur-jump-to-match)
(define-key map [S-iso-lefttab] #'el-search-occur-cycle)
(define-key map [(shift tab)] #'el-search-occur-cycle)
+ (define-key map [?p] #'el-search-occur-previous-match)
+ (define-key map [?n] #'el-search-occur-next-match)
+ (define-key map [?e] #'el-search-edit-occur-pattern)
(set-keymap-parent map (make-composed-keymap special-mode-map
emacs-lisp-mode-map))
map))
@@ -2244,7 +2285,8 @@ Use the normal search commands to seize the search."
(goto-char (scan-sexps
(point) 1))))
'match-data `(,buffer
,match-beg ,file)))
(let ((ov (make-overlay
insertion-point (point) nil t)))
- (overlay-put ov 'face
'el-search-match))
+ (overlay-put ov 'face
'el-search-match)
+ (overlay-put ov 'el-search-match
t))
(with-current-buffer buffer
(point)))))
(let ((working-position context-beg))
(while (not (stream-empty-p matches))
- [elpa] externals/el-search 468745a 185/332: Show match count for `el-search-query-replace', (continued)
- [elpa] externals/el-search 468745a 185/332: Show match count for `el-search-query-replace', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c80df81 186/332: Fix resuming search in a modified buffer, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0b93a25 188/332: * el-search/el-search.el: Minor tweak., Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 145ce47 102/332: Update copyright, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 24d0638 099/332: Rewrite the `change' and `changed' patterns, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search da31900 146/332: Update some copyrights, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 94b79e5 149/332: Add new pattern type `de-morgan', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3b73e0e 154/332: Extend heuristic matching to top-level sexps, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0cff5d2 153/332: Recompile search pattern when resuming searches, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 51a539a 158/332: Implement multi-buffer query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 56d9f20 165/332: Add some useful commands for *El Occur* buffers,
Stefan Monnier <=
- [elpa] externals/el-search 40217c0 174/332: Fix replacing matches with nil, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1bfe7c0 110/332: Simplify `el-search--transform-nontrivial-lpat', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6ff7aa4 116/332: Work around Emacs bug#24542, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 817c902 123/332: Document change-revision transformer function; make a defcustom, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2d6aad6 132/332: Explicitly `error' when trying to jump to invalid search head, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8875d2a 137/332: Avoid infinite recursion in circular programs, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search f02e86f 142/332: New command `el-search-from-beginning', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 4b6a363 138/332: Improve handling of reader errors in el-search-atom-list, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 806bfc4 157/332: Add new command `el-search-this-sexp', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c66d1da 160/332: Make the el-search-object struct contain an alist of properties, Stefan Monnier, 2020/12/01