annotate lisp/next-error.el @ 5067:7d7ae8db0341

add functions `stable-union' and `stable-intersection' to do stable set operations -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2010-02-22 Ben Wing <ben@xemacs.org> * cl-seq.el: * cl-seq.el (stable-union): New. * cl-seq.el (stable-intersection): New. New functions to do stable set operations, i.e. preserve the order of the elements in the argument lists, and prefer LIST1 over LIST2 when ordering the combined result. The result looks as much like LIST1 as possible, followed (in the case of `stable-union') by any necessary elements from LIST2, in order. This is contrary to `union' and `intersection', which are not required to be order- preserving and are not -- they prefer LIST2 and output results in backwards order.
author Ben Wing <ben@xemacs.org>
date Mon, 22 Feb 2010 21:23:02 -0600
parents b593e47979a5
children 308d34e9f07d
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)
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
27 ;;; 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
28 ;;; 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
29 ;;; will use this framework.
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
30
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
31 (defgroup next-error nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
32 "`next-error' support framework."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
33 :group 'compilation
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
34 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
35
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
36 (defface next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
37 '((t (:inherit region)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
38 "Face used to highlight next error locus."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
39 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
40 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
41
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
42 (defcustom next-error-highlight 0.1
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
43 "*Highlighting of locations in selected source buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
44 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
45 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
46 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
47 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
48 :type '(choice (number :tag "Delay")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
49 (const :tag "Persistent overlay" t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
50 (const :tag "No highlighting" nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
51 (const :tag "Fringe arrow" 'fringe-arrow))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
52 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
53 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
54
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
55 (defcustom next-error-highlight-no-select 0.1
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
56 "*Highlighting of locations in non-selected source buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
57 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
58 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
59 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
60 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
61 :type '(choice (number :tag "Delay")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
62 (const :tag "Persistent overlay" t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
63 (const :tag "No highlighting" nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
64 (const :tag "Fringe arrow" 'fringe-arrow))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
65 :group 'next-error
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
66 :version "22.1")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
67
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
68 (defcustom next-error-hook nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
69 "*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
70 :type 'hook
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
71 :group 'next-error)
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-highlight-timer nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
74
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
75 ;(defvar next-error-overlay-arrow-position nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
76 ;(put 'next-error-overlay-arrow-position 'overlay-arrow-string "=>")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
77 ;(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
78
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
79 (defvar next-error-last-buffer nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
80 "The most recent `next-error' buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
81 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
82 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
83 or \\[compile-goto-error].")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
84
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
85 (defvar next-error-function nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
86 "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
87 The function is called with 2 parameters:
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
88 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
89 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
90 of the errors before moving.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
91 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
92 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
93 to navigate in it.")
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 (make-variable-buffer-local 'next-error-function)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
96
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
97 (defsubst next-error-buffer-p (buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
98 &optional avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
99 extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
100 extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
101 "Test if BUFFER is a `next-error' capable buffer.
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 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
104 as an absolute last resort only.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
105
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
106 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
107 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
108 in question is treated as usable.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
109
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
110 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
111 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
112 that buffer is rejected."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
113 (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
114 (not (and avoid-current (eq buffer (current-buffer))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
115 (with-current-buffer buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
116 (if next-error-function ; This is the normal test.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
117 ;; Optionally reject some buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
118 (if extra-test-exclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
119 (funcall extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
120 t)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
121 ;; Optionally accept some other buffers.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
122 (and extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
123 (funcall extra-test-inclusive))))))
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 next-error-find-buffer (&optional avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
126 extra-test-inclusive
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
127 extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
128 "Return a `next-error' capable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
129 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
130 as an absolute last resort only.
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 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
133 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
134 in question is treated as usable.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
135
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
136 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
137 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
138 that buffer is rejected."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
139 (or
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
140 ;; 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
141 (let ((window-buffers
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
142 (delete-dups
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
143 (delq nil (mapcar (lambda (w)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
144 (if (next-error-buffer-p
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 avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
147 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
148 (window-buffer w)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
149 (window-list))))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
150 (if (eq (length window-buffers) 1)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
151 (car window-buffers)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
152 ;; 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
153 (if (and next-error-last-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
154 (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
155 extra-test-inclusive extra-test-exclusive))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
156 next-error-last-buffer)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
157 ;; 3. If the current buffer is acceptable, choose it.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
158 (if (next-error-buffer-p (current-buffer) avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
159 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
160 (current-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
161 ;; 4. Look for any acceptable buffer.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
162 (let ((buffers (buffer-list)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
163 (while (and buffers
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
164 (not (next-error-buffer-p
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
165 (car buffers) avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
166 extra-test-inclusive extra-test-exclusive)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
167 (setq buffers (cdr buffers)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
168 (car buffers))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
169 ;; 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
170 ;; even despite AVOID-CURRENT.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
171 (and avoid-current
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
172 (next-error-buffer-p (current-buffer) nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
173 extra-test-inclusive extra-test-exclusive)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
174 (progn
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
175 (message "This is the only next-error capable buffer")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
176 (current-buffer)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
177 ;; 6. Give up.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
178 (error "No next-error capable buffer found")))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
179
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
180 ;;;###autoload
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
181 (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
182 "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
183
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
184 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
185 the message buffer is checked for new ones.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
186
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
187 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
188 negative means move back to previous error messages.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
189 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
190 and start at the first error.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
191
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
192 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
193
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
194 \\[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
195 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
196 buffer with output from the \\[compile], \\[grep] commands, or,
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
197 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
198 Compilation Minor mode enabled, or any buffer in which
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
199 `next-error-function' is bound to an appropriate function.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
200 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
201 \\[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
202 in the current frame.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
203
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
204 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
205 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
206 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
207 or Compilation Minor mode.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
208
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
209 See variables `compilation-parse-errors-function' and
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
210 \`compilation-error-regexp-alist' for customization ideas."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
211 (interactive "P")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
212 (if (consp arg) (setq reset t arg nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
213 (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
214 ;; 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
215 (with-current-buffer next-error-last-buffer
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
216 (funcall next-error-function (prefix-numeric-value arg) reset)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
217 (run-hooks 'next-error-hook))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
218
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
219 (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
220 (defalias 'next-match 'next-error-framework-next-error)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
221
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
222 (defun next-error-framework-previous-error (&optional n)
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
223 "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
224
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
225 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
226 forwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
227
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
228 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
229 (interactive "p")
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
230 (next-error-framework-next-error (- (or n 1))))
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
231
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
232 (defun next-error-framework-first-error (&optional n)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
233 "Restart at the first error.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
234 Visit corresponding source code.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
235 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
236 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
237 (interactive "p")
3299
b593e47979a5 [xemacs-hg @ 2006-03-25 11:20:50 by malcolmp]
malcolmp
parents: 3017
diff changeset
238 (next-error-framework-next-error n t))
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
239
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
240 (defun next-error-no-select (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
241 "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
242 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
243 backwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
244 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
245 select the source buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
246 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
247 (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
248 (next-error-framework-next-error n))
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
249 (pop-to-buffer next-error-last-buffer))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
250
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
251 (defun previous-error-no-select (&optional n)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
252 "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
253 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
254 forwards, if negative).
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
255 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
256 select the source buffer."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
257 (interactive "p")
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
258 (next-error-no-select (- (or n 1))))
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 ;;; 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
261 (defvar next-error-follow-last-line nil)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
262
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
263 (define-minor-mode next-error-follow-minor-mode
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
264 "Minor mode for compilation, occur and diff modes.
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
265 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
266 buffer causes automatic display of the corresponding source code
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
267 location."
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
268 :group 'next-error :init-value nil :lighter " Fol"
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
269 (if (not next-error-follow-minor-mode)
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
270 (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
271 (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
272 (make-local-variable 'next-error-follow-last-line)))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
273
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
274 ;;; 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
275 ;;; for the *Compilation* *grep* and *Occur* buffers.
3017
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
276 (defvar compilation-current-error)
1e7cc382eb16 [xemacs-hg @ 2005-10-24 10:07:26 by ben]
ben
parents: 3000
diff changeset
277 (defvar compilation-context-lines)
3000
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
278 (defun next-error-follow-mode-post-command-hook ()
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
279 (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
280 (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
281 (condition-case nil
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
282 (let ((compilation-context-lines nil))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
283 (setq compilation-current-error (point))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
284 (next-error-no-select 0))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
285 (error t))))
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
286
5df5ea55d3fc [xemacs-hg @ 2005-10-18 20:49:41 by malcolmp]
malcolmp
parents:
diff changeset
287 (provide 'next-error)