annotate lisp/next-error.el @ 3108:40bebdb82ec4

[xemacs-hg @ 2005-11-29 03:31:25 by stephent] yet more 21.5.24 release preparation.
author stephent
date Tue, 29 Nov 2005 03:31:25 +0000
parents 1e7cc382eb16
children b593e47979a5
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
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
14 ;; any later version.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
15
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
19 ;; GNU General Public License for more details.
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
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
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 ;;; Synched up with: FSF 22.0.50.1 (CVS)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
27
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
28 (defgroup next-error nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
29 "`next-error' support framework."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
30 :group 'compilation
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
31 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
32
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
33 (defface next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
34 '((t (:inherit region)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
35 "Face used to highlight next error locus."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
36 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
37 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
38
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
39 (defcustom next-error-highlight 0.1
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
40 "*Highlighting of locations in selected source buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
41 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
42 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
43 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
44 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
45 :type '(choice (number :tag "Delay")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
46 (const :tag "Persistent overlay" t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
47 (const :tag "No highlighting" nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
48 (const :tag "Fringe arrow" 'fringe-arrow))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
49 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
50 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
51
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
52 (defcustom next-error-highlight-no-select 0.1
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
53 "*Highlighting of locations in non-selected source buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
54 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
55 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
56 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
57 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
58 :type '(choice (number :tag "Delay")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
59 (const :tag "Persistent overlay" t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
60 (const :tag "No highlighting" nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
61 (const :tag "Fringe arrow" 'fringe-arrow))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
62 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
63 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
64
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
65 (defcustom next-error-hook nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
66 "*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
67 :type 'hook
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
68 :group 'next-error)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
69
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
70 (defvar next-error-highlight-timer nil)
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 ;(defvar next-error-overlay-arrow-position nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
73 ;(put 'next-error-overlay-arrow-position 'overlay-arrow-string "=>")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
74 ;(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
75
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
76 (defvar next-error-last-buffer nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
77 "The most recent `next-error' buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
78 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
79 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
80 or \\[compile-goto-error].")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
81
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
82 (defvar next-error-function nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
83 "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
84 The function is called with 2 parameters:
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
85 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
86 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
87 of the errors before moving.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
88 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
89 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
90 to navigate in it.")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
91
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
92 (make-variable-buffer-local 'next-error-function)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
93
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
94 (defsubst next-error-buffer-p (buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
95 &optional avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
96 extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
97 extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
98 "Test if BUFFER is a `next-error' capable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
99
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
100 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
101 as an absolute last resort only.
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 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
104 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
105 in question is treated as usable.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
106
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
107 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
108 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
109 that buffer is rejected."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
110 (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
111 (not (and avoid-current (eq buffer (current-buffer))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
112 (with-current-buffer buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
113 (if next-error-function ; This is the normal test.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
114 ;; Optionally reject some buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
115 (if extra-test-exclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
116 (funcall extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
117 t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
118 ;; Optionally accept some other buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
119 (and extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
120 (funcall extra-test-inclusive))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
121
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
122 (defun next-error-find-buffer (&optional avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
123 extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
124 extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
125 "Return a `next-error' capable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
126 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
127 as an absolute last resort only.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
128
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
129 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
130 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
131 in question is treated as usable.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
132
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
133 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
134 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
135 that buffer is rejected."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
136 (or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
137 ;; 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
138 (let ((window-buffers
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
139 (delete-dups
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
140 (delq nil (mapcar (lambda (w)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
141 (if (next-error-buffer-p
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
142 (window-buffer w)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
143 avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
144 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
145 (window-buffer w)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
146 (window-list))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
147 (if (eq (length window-buffers) 1)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
148 (car window-buffers)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
149 ;; 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
150 (if (and next-error-last-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
151 (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
152 extra-test-inclusive extra-test-exclusive))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
153 next-error-last-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
154 ;; 3. If the current buffer is acceptable, choose it.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
155 (if (next-error-buffer-p (current-buffer) avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
156 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
157 (current-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
158 ;; 4. Look for any acceptable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
159 (let ((buffers (buffer-list)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
160 (while (and buffers
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
161 (not (next-error-buffer-p
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
162 (car buffers) avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
163 extra-test-inclusive extra-test-exclusive)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
164 (setq buffers (cdr buffers)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
165 (car buffers))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
166 ;; 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
167 ;; even despite AVOID-CURRENT.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
168 (and avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
169 (next-error-buffer-p (current-buffer) nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
170 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
171 (progn
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
172 (message "This is the only next-error capable buffer")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
173 (current-buffer)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
174 ;; 6. Give up.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
175 (error "No next-error capable buffer found")))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
176
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
177 ;;;###autoload
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
178 (defun next-error (&optional arg reset)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
179 "Visit next `next-error' message and corresponding source code.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
180
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
181 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
182 the message buffer is checked for new ones.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
183
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
184 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
185 negative means move back to previous error messages.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
186 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
187 and start at the first error.
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 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
190
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
191 \\[next-error] normally uses the most recently started
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
192 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
193 buffer with output from the \\[compile], \\[grep] commands, or,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
194 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
195 Compilation Minor mode enabled, or any buffer in which
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
196 `next-error-function' is bound to an appropriate function.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
197 To specify use of a particular buffer for error messages, type
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
198 \\[next-error] in that buffer when it is the only one displayed
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
199 in the current frame.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
200
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
201 Once \\[next-error] has chosen the buffer for error messages, it
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
202 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
203 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
204 or Compilation Minor mode.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
205
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
206 See variables `compilation-parse-errors-function' and
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
207 \`compilation-error-regexp-alist' for customization ideas."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
208 (interactive "P")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
209 (if (consp arg) (setq reset t arg nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
210 (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
211 ;; 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
212 (with-current-buffer next-error-last-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
213 (funcall next-error-function (prefix-numeric-value arg) reset)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
214 (run-hooks 'next-error-hook))))
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 (defalias 'goto-next-locus 'next-error)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
217 (defalias 'next-match 'next-error)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
218
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
219 (defun previous-error (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
220 "Visit previous `next-error' message and corresponding source code.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
221
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
222 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
223 forwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
224
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
225 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
226 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
227 (next-error (- (or n 1))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
228
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
229 (defun first-error (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
230 "Restart at the first error.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
231 Visit corresponding source code.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
232 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
233 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
234 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
235 (next-error n t))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
236
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
237 (defun next-error-no-select (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
238 "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
239 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
240 backwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
241 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
242 select the source buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
243 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
244 (let ((next-error-highlight next-error-highlight-no-select))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
245 (next-error n))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
246 (pop-to-buffer next-error-last-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
247
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
248 (defun previous-error-no-select (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
249 "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
250 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
251 forwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
252 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
253 select the source buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
254 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
255 (next-error-no-select (- (or n 1))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
256
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
257 ;;; 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
258 (defvar next-error-follow-last-line nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
259
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
260 (define-minor-mode next-error-follow-minor-mode
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
261 "Minor mode for compilation, occur and diff modes.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
262 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
263 buffer causes automatic display of the corresponding source code
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
264 location."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
265 :group 'next-error :init-value nil :lighter " Fol"
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
266 (if (not next-error-follow-minor-mode)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
267 (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
268 (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
269 (make-local-variable 'next-error-follow-last-line)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
270
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
271 ;;; 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
272 ;;; for the *Compilation* *grep* and *Occur* buffers.
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
273 (defvar compilation-current-error)
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
274 (defvar compilation-context-lines)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
275 (defun next-error-follow-mode-post-command-hook ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
276 (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
277 (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
278 (condition-case nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
279 (let ((compilation-context-lines nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
280 (setq compilation-current-error (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
281 (next-error-no-select 0))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
282 (error t))))
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 (provide 'next-error)