mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-15 09:47:20 +00:00
Indicate selected occur target with fringe arrow
* lisp/replace.el (occur--set-arrow): New function. (occur-mode-goto-occurrence) (occur-mode-goto-occurrence-other-window) (occur-mode-display-occurrence): Call it. * etc/NEWS: Announce.
This commit is contained in:
parent
12af7ee46d
commit
660b17ef3e
3
etc/NEWS
3
etc/NEWS
@ -791,6 +791,9 @@ compilation buffers, recenters the current displayed occurrence/error.
|
||||
The method of highlighting is specified by the user options
|
||||
'next-error-highlight' and 'next-error-highlight-no-select'.
|
||||
|
||||
---
|
||||
*** A fringe arrow in the '*Occur*' buffer indicates the selected match.
|
||||
|
||||
---
|
||||
*** Occur mode may use a different type for 'occur-target' property values.
|
||||
The value was previously always a marker set to the start of the first
|
||||
|
@ -1443,6 +1443,19 @@ To return to ordinary Occur mode, use \\[occur-cease-edit]."
|
||||
(error "Buffer for this occurrence was killed"))
|
||||
targets))
|
||||
|
||||
(defun occur--set-arrow ()
|
||||
"Set the overlay arrow at the first line of the occur match at point."
|
||||
(save-excursion
|
||||
(let ((start (point))
|
||||
(target (get-text-property (point) 'occur-target))
|
||||
;; Find the start of the occur match, in case it's multi-line.
|
||||
(prev (previous-single-property-change (point) 'occur-target)))
|
||||
(when (and prev (eq (get-text-property prev 'occur-target) target))
|
||||
(goto-char prev))
|
||||
(setq overlay-arrow-position
|
||||
(set-marker (or overlay-arrow-position (make-marker))
|
||||
(line-beginning-position))))))
|
||||
|
||||
(defalias 'occur-mode-mouse-goto 'occur-mode-goto-occurrence)
|
||||
(defun occur-mode-goto-occurrence (&optional event)
|
||||
"Go to the occurrence specified by EVENT, a mouse click.
|
||||
@ -1460,6 +1473,7 @@ If not invoked by a mouse click, go to occurrence on the current line."
|
||||
(goto-char (posn-point (event-end event)))
|
||||
(occur-mode--find-occurrences)))))
|
||||
(pos (occur--targets-start targets)))
|
||||
(occur--set-arrow)
|
||||
(pop-to-buffer (marker-buffer pos))
|
||||
(goto-char pos)
|
||||
(occur--highlight-occurrences targets)
|
||||
@ -1471,6 +1485,7 @@ If not invoked by a mouse click, go to occurrence on the current line."
|
||||
(interactive)
|
||||
(let ((buffer (current-buffer))
|
||||
(pos (occur--targets-start (occur-mode--find-occurrences))))
|
||||
(occur--set-arrow)
|
||||
(switch-to-buffer-other-window (marker-buffer pos))
|
||||
(goto-char pos)
|
||||
(next-error-found buffer (current-buffer))
|
||||
@ -1530,6 +1545,7 @@ If not invoked by a mouse click, go to occurrence on the current line."
|
||||
'(nil (inhibit-same-window . t)))
|
||||
window)
|
||||
(setq window (display-buffer (marker-buffer pos) t))
|
||||
(occur--set-arrow)
|
||||
;; This is the way to set point in the proper window.
|
||||
(save-selected-window
|
||||
(select-window window)
|
||||
|
Loading…
Reference in New Issue
Block a user