diff options
| author | Carsten Dominik | 2008-01-23 10:49:31 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2008-01-23 10:49:31 +0000 |
| commit | 8e62d5e855c245b2d576b7e1ce7aa11e94061cbd (patch) | |
| tree | f4a9333b0be675271ae18fec473dbb9d9fceddc8 /lisp/replace.el | |
| parent | 5deae9b3b1d19a5fa885e023cf221c1ffb06adc8 (diff) | |
| download | emacs-8e62d5e855c245b2d576b7e1ce7aa11e94061cbd.tar.gz emacs-8e62d5e855c245b2d576b7e1ce7aa11e94061cbd.zip | |
* 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'.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 0217e73e44c..3680d574e8c 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -789,6 +789,13 @@ See `occur-revert-function'.") | |||
| 789 | :type 'hook | 789 | :type 'hook |
| 790 | :group 'matching) | 790 | :group 'matching) |
| 791 | 791 | ||
| 792 | (defcustom occur-mode-find-occurrence-hook nil | ||
| 793 | "Hook run by Occur after locating an occurrence. | ||
| 794 | This will be called with the cursor position at the occurrence. An application | ||
| 795 | for this is to reveal context in an outline-mode when the occurrence is hidden." | ||
| 796 | :type 'hook | ||
| 797 | :group 'matching) | ||
| 798 | |||
| 792 | (put 'occur-mode 'mode-class 'special) | 799 | (put 'occur-mode 'mode-class 'special) |
| 793 | (defun occur-mode () | 800 | (defun occur-mode () |
| 794 | "Major mode for output from \\[occur]. | 801 | "Major mode for output from \\[occur]. |
| @@ -837,14 +844,16 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 837 | same-window-buffer-names | 844 | same-window-buffer-names |
| 838 | same-window-regexps) | 845 | same-window-regexps) |
| 839 | (pop-to-buffer (marker-buffer pos)) | 846 | (pop-to-buffer (marker-buffer pos)) |
| 840 | (goto-char pos))) | 847 | (goto-char pos) |
| 848 | (run-hooks 'occur-mode-find-occurrence-hook))) | ||
| 841 | 849 | ||
| 842 | (defun occur-mode-goto-occurrence-other-window () | 850 | (defun occur-mode-goto-occurrence-other-window () |
| 843 | "Go to the occurrence the current line describes, in another window." | 851 | "Go to the occurrence the current line describes, in another window." |
| 844 | (interactive) | 852 | (interactive) |
| 845 | (let ((pos (occur-mode-find-occurrence))) | 853 | (let ((pos (occur-mode-find-occurrence))) |
| 846 | (switch-to-buffer-other-window (marker-buffer pos)) | 854 | (switch-to-buffer-other-window (marker-buffer pos)) |
| 847 | (goto-char pos))) | 855 | (goto-char pos) |
| 856 | (run-hooks 'occur-mode-find-occurrence-hook))) | ||
| 848 | 857 | ||
| 849 | (defun occur-mode-display-occurrence () | 858 | (defun occur-mode-display-occurrence () |
| 850 | "Display in another window the occurrence the current line describes." | 859 | "Display in another window the occurrence the current line describes." |
| @@ -858,7 +867,8 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 858 | ;; This is the way to set point in the proper window. | 867 | ;; This is the way to set point in the proper window. |
| 859 | (save-selected-window | 868 | (save-selected-window |
| 860 | (select-window window) | 869 | (select-window window) |
| 861 | (goto-char pos)))) | 870 | (goto-char pos) |
| 871 | (run-hooks 'occur-mode-find-occurrence-hook)))) | ||
| 862 | 872 | ||
| 863 | (defun occur-find-match (n search message) | 873 | (defun occur-find-match (n search message) |
| 864 | (if (not n) (setq n 1)) | 874 | (if (not n) (setq n 1)) |