aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd2021-08-01 11:52:00 +0200
committerMattias EngdegÄrd2021-08-01 14:42:07 +0200
commit660b17ef3e2f169478b56aaaacf6b9aa761b0619 (patch)
tree76b1080592761219550b17db9aec82fa524c4046 /lisp/replace.el
parent12af7ee46d47152a2c499e24970a6ab4a94aed61 (diff)
downloademacs-660b17ef3e2f169478b56aaaacf6b9aa761b0619.tar.gz
emacs-660b17ef3e2f169478b56aaaacf6b9aa761b0619.zip
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.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 148b7ce48b1..462cc26e993 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1443,6 +1443,19 @@ To return to ordinary Occur mode, use \\[occur-cease-edit]."
1443 (error "Buffer for this occurrence was killed")) 1443 (error "Buffer for this occurrence was killed"))
1444 targets)) 1444 targets))
1445 1445
1446(defun occur--set-arrow ()
1447 "Set the overlay arrow at the first line of the occur match at point."
1448 (save-excursion
1449 (let ((start (point))
1450 (target (get-text-property (point) 'occur-target))
1451 ;; Find the start of the occur match, in case it's multi-line.
1452 (prev (previous-single-property-change (point) 'occur-target)))
1453 (when (and prev (eq (get-text-property prev 'occur-target) target))
1454 (goto-char prev))
1455 (setq overlay-arrow-position
1456 (set-marker (or overlay-arrow-position (make-marker))
1457 (line-beginning-position))))))
1458
1446(defalias 'occur-mode-mouse-goto 'occur-mode-goto-occurrence) 1459(defalias 'occur-mode-mouse-goto 'occur-mode-goto-occurrence)
1447(defun occur-mode-goto-occurrence (&optional event) 1460(defun occur-mode-goto-occurrence (&optional event)
1448 "Go to the occurrence specified by EVENT, a mouse click. 1461 "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."
1460 (goto-char (posn-point (event-end event))) 1473 (goto-char (posn-point (event-end event)))
1461 (occur-mode--find-occurrences))))) 1474 (occur-mode--find-occurrences)))))
1462 (pos (occur--targets-start targets))) 1475 (pos (occur--targets-start targets)))
1476 (occur--set-arrow)
1463 (pop-to-buffer (marker-buffer pos)) 1477 (pop-to-buffer (marker-buffer pos))
1464 (goto-char pos) 1478 (goto-char pos)
1465 (occur--highlight-occurrences targets) 1479 (occur--highlight-occurrences targets)
@@ -1471,6 +1485,7 @@ If not invoked by a mouse click, go to occurrence on the current line."
1471 (interactive) 1485 (interactive)
1472 (let ((buffer (current-buffer)) 1486 (let ((buffer (current-buffer))
1473 (pos (occur--targets-start (occur-mode--find-occurrences)))) 1487 (pos (occur--targets-start (occur-mode--find-occurrences))))
1488 (occur--set-arrow)
1474 (switch-to-buffer-other-window (marker-buffer pos)) 1489 (switch-to-buffer-other-window (marker-buffer pos))
1475 (goto-char pos) 1490 (goto-char pos)
1476 (next-error-found buffer (current-buffer)) 1491 (next-error-found buffer (current-buffer))
@@ -1530,6 +1545,7 @@ If not invoked by a mouse click, go to occurrence on the current line."
1530 '(nil (inhibit-same-window . t))) 1545 '(nil (inhibit-same-window . t)))
1531 window) 1546 window)
1532 (setq window (display-buffer (marker-buffer pos) t)) 1547 (setq window (display-buffer (marker-buffer pos) t))
1548 (occur--set-arrow)
1533 ;; This is the way to set point in the proper window. 1549 ;; This is the way to set point in the proper window.
1534 (save-selected-window 1550 (save-selected-window
1535 (select-window window) 1551 (select-window window)