annotate lisp/occur.el @ 5556:a142ad1a9140

Use dlsym() in preference to NSLookupSymbolInModule() on Darwin, if available. ChangeLog addition: 2011-08-24 Aidan Kehoe <kehoea@parhasard.net> * configure.ac: On OS X, if dlopen() is available in dlfcn.h, use it in preference to dyld; the latter API is deprecated. Move DLSYM_NEEDS_UNDERSCORE together with HAVE_DLYD, it's not needed if the dlsym() and dlopen() APIs are being used. Define REALPATH_CORRECTS_CASE, DEFAULT_FILE_SYSTEM_IGNORE_CASE in this file, don't define them in terms of HAVE_DYLD in src/config.h.in. * configure: Regenerate. src/ChangeLog addition: 2011-08-24 Aidan Kehoe <kehoea@parhasard.net> * config.h.in: Move REALPATH_CORRECTS_CASE, DEFAULT_FILE_SYSTEM_IGNORE_CASE to ../configure.ac rather than implementing them in terms of HAVE_DYLD here.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 24 Aug 2011 23:41:29 +0100
parents ac37a5f7e5be
children cc6f0266bc36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
1 ;;; occur.el --- Show all lines in the current buffer containing a match for REGEXP.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
2
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1996, 1997, 2000, 2001,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
4 ;; 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
5
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
7 ;; Keywords: internal
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
8
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
9 ;; This file is part of XEmacs.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
10
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
14 ;; option) any later version.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
15
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
19 ;; for more details.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
20
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4103
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
23
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
24 ;;; Synched up with: FSF 22.0.50.1 (CVS)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
25
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
26 (require 'next-error)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
27 (defun query-replace-descr (string)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
28 (mapconcat 'isearch-text-char-description string ""))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
29
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
30 (defvar occur-mode-map ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
31 "Keymap for `occur-mode'.")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
32 (if occur-mode-map
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
33 ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
34 (setq occur-mode-map (make-sparse-keymap))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
35 (set-keymap-name occur-mode-map 'occur-mode-map) ; XEmacs
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
36 (define-key occur-mode-map 'button2 'occur-mode-mouse-goto) ; XEmacs
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
37 (define-key occur-mode-map "\C-c\C-c" 'occur-mode-goto-occurrence)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
38 (define-key occur-mode-map "\C-m" 'occur-mode-goto-occurrence)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
39 (define-key occur-mode-map "o" 'occur-mode-goto-occurrence-other-window)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
40 (define-key occur-mode-map "\C-o" 'occur-mode-display-occurrence)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
41 (define-key occur-mode-map "\M-n" 'occur-next)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
42 (define-key occur-mode-map "\M-p" 'occur-prev)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
43 (define-key occur-mode-map "r" 'occur-rename-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
44 (define-key occur-mode-map "c" 'clone-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
45 (define-key occur-mode-map "g" 'revert-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
46 (define-key occur-mode-map "q" 'quit-window)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
47 (define-key occur-mode-map "z" 'kill-this-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
48 (define-key occur-mode-map "\C-c\C-f" 'next-error-follow-minor-mode))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
49
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
50 (defvar occur-revert-arguments nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
51 "Arguments to pass to `occur-1' to revert an Occur mode buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
52 See `occur-revert-function'.")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
53
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
54 (defcustom occur-mode-hook nil ; XEmacs
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
55 "Hook run when entering Occur mode."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
56 :type 'hook
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
57 :group 'matching)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
58
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
59 (defcustom occur-hook nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
60 "Hook run by Occur when there are any matches."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
61 :type 'hook
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
62 :group 'matching)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
63
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
64 (put 'occur-mode 'mode-class 'special)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
65 ;;;###autoload
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
66 (defun occur-mode ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
67 "Major mode for output from \\[occur].
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
68 \\<occur-mode-map>Move point to one of the items in this buffer, then use
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
69 \\[occur-mode-goto-occurrence] to go to the occurrence that the item refers to.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
70 Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
71
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
72 \\{occur-mode-map}"
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
73 (interactive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
74 (kill-all-local-variables)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
75 (use-local-map occur-mode-map)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
76 (setq major-mode 'occur-mode)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
77 (setq mode-name (gettext "Occur")) ; XEmacs
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
78 (set (make-local-variable 'revert-buffer-function) 'occur-revert-function)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
79 (make-local-variable 'occur-revert-arguments)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
80 (add-hook 'change-major-mode-hook 'turn-off-font-lock t t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
81 (setq next-error-function 'occur-next-error)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
82 (require 'mode-motion) ; XEmacs
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
83 (setq mode-motion-hook 'mode-motion-highlight-line) ; XEmacs
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
84 (run-mode-hooks 'occur-mode-hook))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
85
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
86 (defun occur-revert-function (ignore1 ignore2)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
87 "Handle `revert-buffer' for Occur mode buffers."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
88 (apply 'occur-1 (append occur-revert-arguments (list (buffer-name)))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
89
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
90 ;; FSF Version of next function:
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
91 ; (defun occur-mode-mouse-goto (event)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
92 ; "In Occur mode, go to the occurrence whose line you click on."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
93 ; (interactive "e")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
94 ; (let (pos)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
95 ; (save-excursion
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
96 ; (set-buffer (window-buffer (posn-window (event-end event))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
97 ; (save-excursion
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
98 ; (goto-char (posn-point (event-end event)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
99 ; (setq pos (occur-mode-find-occurrence))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
100 ; (pop-to-buffer (marker-buffer pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
101 ; (goto-char pos)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
102
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
103 (defun occur-mode-mouse-goto (event)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
104 "Go to the occurrence highlighted by mouse.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
105 This function should be bound to a mouse key in the `*Occur*' buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
106 (interactive "e")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
107 (let ((window-save (selected-window))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
108 (frame-save (selected-frame)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
109 ;; preserve the window/frame setup
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
110 (unwind-protect
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
111 (progn
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
112 (mouse-set-point event)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
113 (occur-mode-goto-occurrence))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
114 (select-frame frame-save)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
115 (select-window window-save))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
116
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
117 (defun occur-mode-find-occurrence ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
118 (let ((pos (get-text-property (point) 'occur-target)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
119 (unless pos
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
120 (error "No occurrence on this line"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
121 (unless (buffer-live-p (marker-buffer pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
122 (error "Buffer for this occurrence was killed"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
123 pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
124
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
125 (defun occur-mode-goto-occurrence ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
126 "Go to the occurrence the current line describes."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
127 (interactive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
128 (let ((pos (occur-mode-find-occurrence)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
129 (pop-to-buffer (marker-buffer pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
130 (goto-char pos)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
131
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
132 (defun occur-mode-goto-occurrence-other-window ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
133 "Go to the occurrence the current line describes, in another window."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
134 (interactive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
135 (let ((pos (occur-mode-find-occurrence)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
136 (switch-to-buffer-other-window (marker-buffer pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
137 (goto-char pos)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
138
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
139 (defun occur-mode-display-occurrence ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
140 "Display in another window the occurrence the current line describes."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
141 (interactive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
142 (let ((pos (occur-mode-find-occurrence))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
143 window
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
144 ;; Bind these to ensure `display-buffer' puts it in another window.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
145 same-window-buffer-names
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
146 same-window-regexps)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
147 (setq window (display-buffer (marker-buffer pos)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
148 ;; This is the way to set point in the proper window.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
149 (save-selected-window
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
150 (select-window window)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
151 (goto-char pos))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
152
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
153 (defun occur-find-match (n search message)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
154 (if (not n) (setq n 1))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
155 (let ((r))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
156 (while (> n 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
157 (setq r (funcall search (point) 'occur-match))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
158 (and r
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
159 (get-text-property r 'occur-match)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
160 (setq r (funcall search r 'occur-match)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
161 (if r
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
162 (goto-char r)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
163 (error message))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
164 (setq n (1- n)))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
165
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
166 (defun occur-next (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
167 "Move to the Nth (default 1) next match in an Occur mode buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
168 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
169 (occur-find-match n #'next-single-property-change "No more matches"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
170
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
171 (defun occur-prev (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
172 "Move to the Nth (default 1) previous match in an Occur mode buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
173 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
174 (occur-find-match n #'previous-single-property-change "No earlier matches"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
175
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
176 (defun occur-next-error (&optional argp reset)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
177 "Move to the Nth (default 1) next match in an Occur mode buffer.
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3112
diff changeset
178 Compatibility function for \\[next-error-framework-next-error] invocations."
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
179 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
180 ;; we need to run occur-find-match from within the Occur buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
181 (with-current-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
182 ;; Choose the buffer and make it current.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
183 (if (next-error-buffer-p (current-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
184 (current-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
185 (next-error-find-buffer nil nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
186 (lambda ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
187 (eq major-mode 'occur-mode))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
188
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
189 (goto-char (cond (reset (point-min))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
190 ((< argp 0) (line-beginning-position))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
191 ((line-end-position))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
192 (occur-find-match
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
193 (abs argp)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
194 (if (> 0 argp)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
195 #'previous-single-property-change
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
196 #'next-single-property-change)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
197 "No more matches")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
198 ;; In case the *Occur* buffer is visible in a nonselected window.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
199 (set-window-point (get-buffer-window (current-buffer)) (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
200 (occur-mode-goto-occurrence)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
201
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
202 (defface match
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
203 '((((class color) (background light))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
204 (:background "Tan"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
205 (((class color) (background dark))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
206 (:background "RoyalBlue3"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
207 (((class color))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
208 (:background "blue" :foreground "white"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
209 (((type tty) (class mono))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
210 (:inverse-video t))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
211 (t (:background "gray")))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
212 "Face used to highlight matches permanently."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
213 :group 'matching
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
214 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
215
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
216 (defcustom list-matching-lines-default-context-lines 0
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
217 "*Default number of context lines included around `list-matching-lines' matches.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
218 A negative number means to include that many lines before the match.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
219 A positive number means to include that many lines both before and after."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
220 :type 'integer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
221 :group 'matching)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
222
3112
42f7d9eb33a4 [xemacs-hg @ 2005-11-29 12:33:46 by malcolmp]
malcolmp
parents: 3017
diff changeset
223 ;;;###autoload
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
224 (defalias 'list-matching-lines 'occur)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
225
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
226 (defcustom list-matching-lines-face 'match
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
227 "*Face used by \\[list-matching-lines] to show the text that matches.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
228 If the value is nil, don't highlight the matching portions specially."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
229 :type 'face
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
230 :group 'matching)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
231
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
232 (defcustom list-matching-lines-buffer-name-face 'underline
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
233 "*Face used by \\[list-matching-lines] to show the names of buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
234 If the value is nil, don't highlight the buffer names specially."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
235 :type 'face
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
236 :group 'matching)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
237
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
238 (defun occur-accumulate-lines (count &optional keep-props)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
239 (save-excursion
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
240 (let ((forwardp (> count 0))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
241 result beg end)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
242 (while (not (or (zerop count)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
243 (if forwardp
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
244 (eobp)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
245 (bobp))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
246 (setq count (+ count (if forwardp -1 1)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
247 (setq beg (line-beginning-position)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
248 end (line-end-position))
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
249 (if (and keep-props (if-boundp 'jit-lock-mode jit-lock-mode)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
250 (text-property-not-all beg end 'fontified t))
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
251 (if-fboundp 'jit-lock-fontify-now
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
252 (jit-lock-fontify-now beg end)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
253 (push
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
254 (funcall (if keep-props
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
255 #'buffer-substring
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
256 #'buffer-substring-no-properties)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
257 beg end)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
258 result)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
259 (forward-line (if forwardp 1 -1)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
260 (nreverse result))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
261
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
262 (defun occur-read-primary-args ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
263 (list (let* ((default (or (symbol-near-point)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
264 (and regexp-history
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
265 (car regexp-history))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
266 (minibuffer-history-minimum-string-length 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
267 (input
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
268 (if default
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
269 ;; XEmacs: rewritten for I18N3 snarfing
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
270 (read-from-minibuffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
271 (format "List lines matching regexp (default `%s'): "
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
272 default) nil nil nil 'regexp-history nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
273 default)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
274 (read-from-minibuffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
275 "List lines matching regexp: "
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
276 nil nil nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
277 'regexp-history))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
278 (if (equal input "")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
279 default
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
280 input))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
281 (when current-prefix-arg
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
282 (prefix-numeric-value current-prefix-arg))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
283
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
284 ;;;###autoload
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
285 (defun occur-rename-buffer (&optional unique-p interactive-p)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
286 "Rename the current *Occur* buffer to *Occur: original-buffer-name*.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
287 Here `original-buffer-name' is the buffer name were Occur was originally run.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
288 When given the prefix argument, or called non-interactively, the renaming
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
289 will not clobber the existing buffer(s) of that name, but use
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
290 `generate-new-buffer-name' instead. You can add this to `occur-hook'
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
291 if you always want a separate *Occur* buffer for each buffer where you
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
292 invoke `occur'."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
293 (interactive "P\np")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
294 (with-current-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
295 (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
296 (rename-buffer (concat "*Occur: "
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
297 (mapconcat #'buffer-name
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
298 (car (cddr occur-revert-arguments)) "/")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
299 "*")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
300 (or unique-p (not interactive-p)))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
301
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
302 ;;;###autoload
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
303 (defun occur (regexp &optional nlines)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
304 "Show all lines in the current buffer containing a match for REGEXP.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
305 This function can not handle matches that span more than one line.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
306
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
307 Each line is displayed with NLINES lines before and after, or -NLINES
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
308 before if NLINES is negative.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
309 NLINES defaults to `list-matching-lines-default-context-lines'.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
310 Interactively it is the prefix arg.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
311
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
312 The lines are shown in a buffer named `*Occur*'.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
313 It serves as a menu to find any of the occurrences in this buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
314 \\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
315
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
316 If REGEXP contains upper case characters (excluding those preceded by `\\'),
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
317 the matching is case-sensitive."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
318 (interactive (occur-read-primary-args))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
319 (occur-1 regexp nlines (list (current-buffer))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
320
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
321 ;;;###autoload
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
322 (defun multi-occur (bufs regexp &optional nlines)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
323 "Show all lines in buffers BUFS containing a match for REGEXP.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
324 This function acts on multiple buffers; otherwise, it is exactly like
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
325 `occur'."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
326 (interactive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
327 (cons
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
328 (let* ((bufs (list (read-buffer "First buffer to search: "
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
329 (current-buffer) t)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
330 (buf nil)
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3112
diff changeset
331 ; (ido-ignore-item-temp-list bufs)
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3112
diff changeset
332 )
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
333 (while (not (string-equal
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
334 (setq buf (read-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
335 (if (and-boundp 'read-buffer-function
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
336 '(eq read-buffer-function 'ido-read-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
337 "Next buffer to search (C-j to end): "
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
338 "Next buffer to search (RET to end): ")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
339 nil t))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
340 ""))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
341 (add-to-list 'bufs buf)
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3112
diff changeset
342 ; (setq ido-ignore-item-temp-list bufs)
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3112
diff changeset
343 )
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
344 (nreverse (mapcar #'get-buffer bufs)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
345 (occur-read-primary-args)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
346 (occur-1 regexp nlines bufs))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
347
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
348 ;;;###autoload
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
349 (defun multi-occur-by-filename-regexp (bufregexp regexp &optional nlines)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
350 "Show all lines matching REGEXP in buffers named by BUFREGEXP.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
351 See also `multi-occur'."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
352 (interactive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
353 (cons
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
354 (let* ((default (car regexp-history))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
355 (input
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
356 (read-from-minibuffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
357 "List lines in buffers whose filename matches regexp: "
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
358 nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
359 nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
360 nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
361 'regexp-history)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
362 (if (equal input "")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
363 default
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
364 input))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
365 (occur-read-primary-args)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
366 (when bufregexp
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
367 (occur-1 regexp nlines
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
368 (delq nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
369 (mapcar (lambda (buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
370 (when (and (buffer-file-name buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
371 (string-match bufregexp
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
372 (buffer-file-name buf)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
373 buf))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
374 (buffer-list))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
375
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
376 (defun occur-1 (regexp nlines bufs &optional buf-name)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
377 (unless buf-name
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
378 (setq buf-name "*Occur*"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
379 (let (occur-buf
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
380 (active-bufs (delq nil (mapcar #'(lambda (buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
381 (when (buffer-live-p buf) buf))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
382 bufs))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
383 ;; Handle the case where one of the buffers we're searching is the
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
384 ;; output buffer. Just rename it.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
385 (when (member buf-name (mapcar 'buffer-name active-bufs))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
386 (with-current-buffer (get-buffer buf-name)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
387 (rename-uniquely)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
388
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
389 ;; Now find or create the output buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
390 ;; If we just renamed that buffer, we will make a new one here.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
391 (setq occur-buf (get-buffer-create buf-name))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
392
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
393 (with-current-buffer occur-buf
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
394 (occur-mode)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
395 (let ((inhibit-read-only t))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
396 (erase-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
397 (let ((count (occur-engine
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
398 regexp active-bufs occur-buf
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
399 (or nlines list-matching-lines-default-context-lines)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
400 (and case-fold-search
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
401 (no-upper-case-p regexp t))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
402 list-matching-lines-buffer-name-face
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
403 nil list-matching-lines-face t)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
404 (let* ((bufcount (length active-bufs))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
405 (diff (- (length bufs) bufcount)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
406 (message "Searched %d buffer%s%s; %s match%s for `%s'"
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
407 bufcount (if (= bufcount 1) "" "s")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
408 (if (zerop diff) "" (format " (%d killed)" diff))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
409 (if (zerop count) "no" (format "%d" count))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
410 (if (= count 1) "" "es")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
411 regexp))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
412 (setq occur-revert-arguments (list regexp nlines bufs))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
413 (if (= count 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
414 (kill-buffer occur-buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
415 (display-buffer occur-buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
416 (setq next-error-last-buffer occur-buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
417 (setq buffer-read-only t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
418 (set-buffer-modified-p nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
419 (run-hooks 'occur-hook)))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
420
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
421 (defun occur-engine-add-prefix (lines)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
422 (mapcar
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
423 #'(lambda (line)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
424 (concat " :" line "\n"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
425 lines))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
426
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
427 (defun occur-engine (regexp buffers out-buf nlines case-fold-search
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
428 title-face prefix-face match-face keep-props)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
429 (with-current-buffer out-buf
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
430 (let ((globalcount 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
431 ;; Don't generate undo entries for creation of the initial contents.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
432 (buffer-undo-list t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
433 (coding nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
434 ;; Map over all the buffers
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
435 (dolist (buf buffers)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
436 (when (buffer-live-p buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
437 (let ((matches 0) ;; count of matched lines
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
438 (lines 1) ;; line count
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
439 (matchbeg 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
440 (origpt nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
441 (begpt nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
442 (endpt nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
443 (marker nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
444 (curstring "")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
445 (headerpt (with-current-buffer out-buf (point))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
446 (save-excursion
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
447 (set-buffer buf)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
448 (or coding
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
449 ;; Set CODING only if the current buffer locally
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
450 ;; binds buffer-file-coding-system.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
451 (not (local-variable-p 'buffer-file-coding-system (current-buffer)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
452 (setq coding buffer-file-coding-system))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
453 (save-excursion
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
454 (goto-char (point-min)) ;; begin searching in the buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
455 (while (not (eobp))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
456 (setq origpt (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
457 (when (setq endpt (re-search-forward regexp nil t))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
458 (setq matches (1+ matches)) ;; increment match count
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
459 (setq matchbeg (match-beginning 0))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
460 (setq lines (+ lines (1- (count-lines origpt endpt))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
461 (save-excursion
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
462 (goto-char matchbeg)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
463 (setq begpt (line-beginning-position)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
464 endpt (line-end-position)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
465 (setq marker (make-marker))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
466 (set-marker marker matchbeg)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
467 (if (and keep-props
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 3299
diff changeset
468 (if-boundp 'jit-lock-mode jit-lock-mode)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
469 (text-property-not-all begpt endpt 'fontified t))
5368
ed74d2ca7082 Use ', not #', when a given symbol may not have a function binding at read time
Aidan Kehoe <kehoea@parhasard.net>
parents: 4103
diff changeset
470 (if-fboundp 'jit-lock-fontify-now
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
471 (jit-lock-fontify-now begpt endpt)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
472 (setq curstring (buffer-substring begpt endpt))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
473 ;; Depropertize the string, and maybe
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
474 ;; highlight the matches
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
475 (let ((len (length curstring))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
476 (start 0))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
477 (unless keep-props
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
478 (set-text-properties 0 len nil curstring))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
479 (while (and (< start len)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
480 (string-match regexp curstring start))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
481 (add-text-properties
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
482 (match-beginning 0) (match-end 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
483 (append
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
484 `(occur-match t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
485 (when match-face
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
486 ;; Use `face' rather than `font-lock-face' here
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
487 ;; so as to override faces copied from the buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
488 `(face ,match-face)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
489 curstring)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
490 (setq start (match-end 0))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
491 ;; Generate the string to insert for this match
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
492 (let* ((out-line
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
493 (concat
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
494 ;; Using 7 digits aligns tabs properly.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
495 (apply #'propertize (format "%7d:" lines)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
496 (append
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
497 (when prefix-face
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
498 `(font-lock-face prefix-face))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
499 '(occur-prefix t)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
500 ;; We don't put `mouse-face' on the newline,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
501 ;; because that loses. And don't put it
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
502 ;; on context lines to reduce flicker.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
503 (propertize curstring 'mouse-face 'highlight)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
504 "\n"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
505 (data
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
506 (if (= nlines 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
507 ;; The simple display style
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
508 out-line
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
509 ;; The complex multi-line display
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
510 ;; style. Generate a list of lines,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
511 ;; concatenate them all together.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
512 (apply #'concat
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
513 (nconc
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
514 (occur-engine-add-prefix (nreverse (cdr (occur-accumulate-lines (- (1+ (abs nlines))) keep-props))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
515 (list out-line)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
516 (if (> nlines 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
517 (occur-engine-add-prefix
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
518 (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
519 ;; Actually insert the match display data
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
520 (with-current-buffer out-buf
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
521 (let ((beg (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
522 (end (progn (insert data) (point))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
523 (unless (= nlines 0)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
524 (insert "-------\n"))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
525 (add-text-properties
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
526 beg end
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
527 `(occur-target ,marker help-echo "mouse-2: go to this occurrence")))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
528 (goto-char endpt))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
529 (if endpt
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
530 (progn
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
531 (setq lines (1+ lines))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
532 ;; On to the next match...
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
533 (forward-line 1))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
534 (goto-char (point-max))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
535 (when (not (zerop matches)) ;; is the count zero?
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
536 (setq globalcount (+ globalcount matches))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
537 (with-current-buffer out-buf
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
538 (goto-char headerpt)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
539 (let ((beg (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
540 end)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
541 (insert (format "%d match%s for \"%s\" in buffer: %s\n"
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
542 matches (if (= matches 1) "" "es")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
543 regexp (buffer-name buf)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
544 (setq end (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
545 (add-text-properties beg end
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
546 (append
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
547 (when title-face
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
548 `(font-lock-face ,title-face))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
549 `(occur-title ,buf))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
550 (goto-char (point-min)))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
551 (if coding
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
552 ;; CODING is buffer-file-coding-system of the first buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
553 ;; that locally binds it. Let's use it also for the output
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
554 ;; buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
555 (set-buffer-file-coding-system coding))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
556 ;; Return the number of matches
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
557 globalcount)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
558
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
559 (provide 'occur)