annotate lisp/next-error.el @ 5753:dbd8305e13cb

Warn about non-string non-integer ARG to #'gensym, bytecomp.el. lisp/ChangeLog addition: 2013-08-21 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el: * bytecomp.el (gensym): * bytecomp.el (byte-compile-gensym): New. Warn that gensym called in a for-effect context is unlikely to be useful. Warn about non-string non-integer ARGs, this is incorrect. Am not changing the function to error with same, most code that makes the mistake is has no problems, which is why it has survived so long. * window-xemacs.el (save-window-excursion/mapping): * window.el (save-window-excursion): Call #'gensym with a string, not a symbol.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 21 Aug 2013 19:02:59 +0100
parents cc6f0266bc36
children
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 ;;; next-error.el --- Next error support framework
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, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
4 ;; 2000, 2001, 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: 3299
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: 3299
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: 3299
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: 3299
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: 3299
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: 3299
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: 3299
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: 3299
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: 3299
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)
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
25 ;;; Some functions renamed with the next-error-framework prefix to avoid
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
26 ;;; clashes with the next-error code in compile.el. One day compile.el
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
27 ;;; will use this framework.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
28
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
29 (defgroup next-error nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
30 "`next-error' support framework."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
31 :group 'compilation
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
32 :version "22.1")
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 (defface next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
35 '((t (:inherit region)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
36 "Face used to highlight next error locus."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
37 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
38 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
39
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
40 (defcustom next-error-highlight 0.1
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
41 "*Highlighting of locations in selected source buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
42 If number, highlight the locus in `next-error' face for given time in seconds.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
43 If t, use persistent overlays fontified in `next-error' face.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
44 If nil, don't highlight the locus in the source buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
45 If `fringe-arrow', indicate the locus by the fringe arrow."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
46 :type '(choice (number :tag "Delay")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
47 (const :tag "Persistent overlay" t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
48 (const :tag "No highlighting" nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
49 (const :tag "Fringe arrow" 'fringe-arrow))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
50 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
51 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
52
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
53 (defcustom next-error-highlight-no-select 0.1
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
54 "*Highlighting of locations in non-selected source buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
55 If number, highlight the locus in `next-error' face for given time in seconds.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
56 If t, use persistent overlays fontified in `next-error' face.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
57 If nil, don't highlight the locus in the source buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
58 If `fringe-arrow', indicate the locus by the fringe arrow."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
59 :type '(choice (number :tag "Delay")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
60 (const :tag "Persistent overlay" t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
61 (const :tag "No highlighting" nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
62 (const :tag "Fringe arrow" 'fringe-arrow))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
63 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
64 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
65
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
66 (defcustom next-error-hook nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
67 "*List of hook functions run by `next-error' after visiting source file."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
68 :type 'hook
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
69 :group 'next-error)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
70
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
71 (defvar next-error-highlight-timer nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
72
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
73 ;(defvar next-error-overlay-arrow-position nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
74 ;(put 'next-error-overlay-arrow-position 'overlay-arrow-string "=>")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
75 ;(add-to-list 'overlay-arrow-variable-list 'next-error-overlay-arrow-position)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
76
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
77 (defvar next-error-last-buffer nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
78 "The most recent `next-error' buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
79 A buffer becomes most recent when its compilation, grep, or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
80 similar mode is started, or when it is used with \\[next-error]
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
81 or \\[compile-goto-error].")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
82
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
83 (defvar next-error-function nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
84 "Function to use to find the next error in the current buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
85 The function is called with 2 parameters:
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
86 ARG is an integer specifying by how many errors to move.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
87 RESET is a boolean which, if non-nil, says to go back to the beginning
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
88 of the errors before moving.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
89 Major modes providing compile-like functionality should set this variable
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
90 to indicate to `next-error' that this is a candidate buffer and how
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
91 to navigate in it.")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
92
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
93 (make-variable-buffer-local 'next-error-function)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
94
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
95 (defsubst next-error-buffer-p (buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
96 &optional avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
97 extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
98 extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
99 "Test if BUFFER is a `next-error' capable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
100
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
101 If AVOID-CURRENT is non-nil, treat the current buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
102 as an absolute last resort only.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
103
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
104 The function EXTRA-TEST-INCLUSIVE, if non-nil, is called in each buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
105 that normally would not qualify. If it returns t, the buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
106 in question is treated as usable.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
107
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
108 The function EXTRA-TEST-EXCLUSIVE, if non-nil is called in each buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
109 that would normally be considered usable. If it returns nil,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
110 that buffer is rejected."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
111 (and (buffer-name buffer) ;First make sure it's live.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
112 (not (and avoid-current (eq buffer (current-buffer))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
113 (with-current-buffer buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
114 (if next-error-function ; This is the normal test.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
115 ;; Optionally reject some buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
116 (if extra-test-exclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
117 (funcall extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
118 t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
119 ;; Optionally accept some other buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
120 (and extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
121 (funcall extra-test-inclusive))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
122
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
123 (defun next-error-find-buffer (&optional avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
124 extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
125 extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
126 "Return a `next-error' capable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
127 If AVOID-CURRENT is non-nil, treat the current buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
128 as an absolute last resort only.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
129
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
130 The function EXTRA-TEST-INCLUSIVE, if non-nil, is called in each buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
131 that normally would not qualify. If it returns t, the buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
132 in question is treated as usable.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
133
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
134 The function EXTRA-TEST-EXCLUSIVE, if non-nil is called in each buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
135 that would normally be considered usable. If it returns nil,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
136 that buffer is rejected."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
137 (or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
138 ;; 1. If one window on the selected frame displays such buffer, return it.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
139 (let ((window-buffers
5652
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
140 (delete-duplicates
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
141 (mapcan #'(lambda (w)
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
142 (if (next-error-buffer-p
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
143 (window-buffer w)
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
144 avoid-current
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
145 extra-test-inclusive extra-test-exclusive)
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
146 (list (window-buffer w))))
cc6f0266bc36 Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
147 (window-list)))))
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
148 (if (eq (length window-buffers) 1)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
149 (car window-buffers)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
150 ;; 2. If next-error-last-buffer is an acceptable buffer, use that.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
151 (if (and next-error-last-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
152 (next-error-buffer-p next-error-last-buffer avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
153 extra-test-inclusive extra-test-exclusive))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
154 next-error-last-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
155 ;; 3. If the current buffer is acceptable, choose it.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
156 (if (next-error-buffer-p (current-buffer) avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
157 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
158 (current-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
159 ;; 4. Look for any acceptable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
160 (let ((buffers (buffer-list)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
161 (while (and buffers
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
162 (not (next-error-buffer-p
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
163 (car buffers) avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
164 extra-test-inclusive extra-test-exclusive)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
165 (setq buffers (cdr buffers)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
166 (car buffers))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
167 ;; 5. Use the current buffer as a last resort if it qualifies,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
168 ;; even despite AVOID-CURRENT.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
169 (and avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
170 (next-error-buffer-p (current-buffer) nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
171 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
172 (progn
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
173 (message "This is the only next-error capable buffer")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
174 (current-buffer)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
175 ;; 6. Give up.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
176 (error "No next-error capable buffer found")))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
177
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
178 ;;;###autoload
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
179 (defun next-error-framework-next-error (&optional arg reset)
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
180 "Visit next `next-error-framework-next-error' message and corresponding source code.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
181
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
182 If all the error messages parsed so far have been processed already,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
183 the message buffer is checked for new ones.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
184
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
185 A prefix ARG specifies how many error messages to move;
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
186 negative means move back to previous error messages.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
187 Just \\[universal-argument] as a prefix means reparse the error message buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
188 and start at the first error.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
189
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
190 The RESET argument specifies that we should restart from the beginning.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
191
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
192 \\[next-error-framework-next-error] normally uses the most recently started
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
193 compilation, grep, or occur buffer. It can also operate on any
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
194 buffer with output from the \\[compile], \\[grep] commands, or,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
195 more generally, on any buffer in Compilation mode or with
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
196 Compilation Minor mode enabled, or any buffer in which
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
197 `next-error-function' is bound to an appropriate function.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
198 To specify use of a particular buffer for error messages, type
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
199 \\[next-error-framework-next-error] in that buffer when it is the only one displayed
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
200 in the current frame.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
201
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
202 Once \\[next-error-framework-next-error] has chosen the buffer for error messages, it
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
203 runs `next-error-hook' with `run-hooks', and stays with that buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
204 until you use it in some other buffer which uses Compilation mode
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
205 or Compilation Minor mode.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
206
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
207 See variables `compilation-parse-errors-function' and
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
208 \`compilation-error-regexp-alist' for customization ideas."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
209 (interactive "P")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
210 (if (consp arg) (setq reset t arg nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
211 (when (setq next-error-last-buffer (next-error-find-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
212 ;; we know here that next-error-function is a valid symbol we can funcall
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
213 (with-current-buffer next-error-last-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
214 (funcall next-error-function (prefix-numeric-value arg) reset)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
215 (run-hooks 'next-error-hook))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
216
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
217 (defalias 'goto-next-locus 'next-error-framework-next-error)
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
218 (defalias 'next-match 'next-error-framework-next-error)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
219
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
220 (defun next-error-framework-previous-error (&optional n)
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
221 "Visit previous `next-error-framework-next-error' message and corresponding source code.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
222
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
223 Prefix arg N says how many error messages to move backwards (or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
224 forwards, if negative).
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 This operates on the output from the \\[compile] and \\[grep] commands."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
227 (interactive "p")
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
228 (next-error-framework-next-error (- (or n 1))))
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
229
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
230 (defun next-error-framework-first-error (&optional n)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
231 "Restart at the first error.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
232 Visit corresponding source code.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
233 With prefix arg N, visit the source code of the Nth error.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
234 This operates on the output from the \\[compile] command, for instance."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
235 (interactive "p")
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
236 (next-error-framework-next-error n t))
3000
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 next-error-no-select (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
239 "Move point to the next error in the `next-error' buffer and highlight match.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
240 Prefix arg N says how many error messages to move forwards (or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
241 backwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
242 Finds and highlights the source line like \\[next-error], but does not
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
243 select the source buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
244 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
245 (let ((next-error-highlight next-error-highlight-no-select))
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
246 (next-error-framework-next-error n))
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
247 (pop-to-buffer next-error-last-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
248
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
249 (defun previous-error-no-select (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
250 "Move point to the previous error in the `next-error' buffer and highlight match.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
251 Prefix arg N says how many error messages to move backwards (or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
252 forwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
253 Finds and highlights the source line like \\[previous-error], but does not
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
254 select the source buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
255 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
256 (next-error-no-select (- (or n 1))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
257
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
258 ;;; Internal variable for `next-error-follow-mode-post-command-hook'.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
259 (defvar next-error-follow-last-line nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
260
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
261 (define-minor-mode next-error-follow-minor-mode
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
262 "Minor mode for compilation, occur and diff modes.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
263 When turned on, cursor motion in the compilation, grep, occur or diff
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
264 buffer causes automatic display of the corresponding source code
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
265 location."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
266 :group 'next-error :init-value nil :lighter " Fol"
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
267 (if (not next-error-follow-minor-mode)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
268 (remove-hook 'post-command-hook 'next-error-follow-mode-post-command-hook t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
269 (add-hook 'post-command-hook 'next-error-follow-mode-post-command-hook nil t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
270 (make-local-variable 'next-error-follow-last-line)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
271
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
272 ;;; Used as a `post-command-hook' by `next-error-follow-mode'
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
273 ;;; for the *Compilation* *grep* and *Occur* buffers.
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
274 (defvar compilation-current-error)
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
275 (defvar compilation-context-lines)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
276 (defun next-error-follow-mode-post-command-hook ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
277 (unless (equal next-error-follow-last-line (line-number-at-pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
278 (setq next-error-follow-last-line (line-number-at-pos))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
279 (condition-case nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
280 (let ((compilation-context-lines nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
281 (setq compilation-current-error (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
282 (next-error-no-select 0))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
283 (error t))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
284
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
285 (provide 'next-error)