# HG changeset patch # User Carsten Dominik # Date 1201085371 0 # Node ID 5e627a8698d8b48a30f7a499a2d1ed5683df0a05 # Parent caee9efd739b3f9b3b3f363b0df0dc7b6b0650f8 * replace.el (occur-mode-find-occurrence-hook): New hook that can be used to reveal or highlight the location of a match. (occur-mode-goto-occurrence) (occur-mode-goto-occurrence-other-window) (occur-mode-display-occurrence): Run `occur-mode-find-occurrence-hook'. diff -r caee9efd739b -r 5e627a8698d8 lisp/replace.el --- a/lisp/replace.el Wed Jan 23 10:48:57 2008 +0000 +++ b/lisp/replace.el Wed Jan 23 10:49:31 2008 +0000 @@ -789,6 +789,13 @@ :type 'hook :group 'matching) +(defcustom occur-mode-find-occurrence-hook nil + "Hook run by Occur after locating an occurrence. +This will be called with the cursor position at the occurrence. An application +for this is to reveal context in an outline-mode when the occurrence is hidden." + :type 'hook + :group 'matching) + (put 'occur-mode 'mode-class 'special) (defun occur-mode () "Major mode for output from \\[occur]. @@ -837,14 +844,16 @@ same-window-buffer-names same-window-regexps) (pop-to-buffer (marker-buffer pos)) - (goto-char pos))) + (goto-char pos) + (run-hooks 'occur-mode-find-occurrence-hook))) (defun occur-mode-goto-occurrence-other-window () "Go to the occurrence the current line describes, in another window." (interactive) (let ((pos (occur-mode-find-occurrence))) (switch-to-buffer-other-window (marker-buffer pos)) - (goto-char pos))) + (goto-char pos) + (run-hooks 'occur-mode-find-occurrence-hook))) (defun occur-mode-display-occurrence () "Display in another window the occurrence the current line describes." @@ -858,7 +867,8 @@ ;; This is the way to set point in the proper window. (save-selected-window (select-window window) - (goto-char pos)))) + (goto-char pos) + (run-hooks 'occur-mode-find-occurrence-hook)))) (defun occur-find-match (n search message) (if (not n) (setq n 1))