* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
@ 2004-02-12 19:48 ` Stefan Monnier
2004-02-12 20:34 ` Ted Zlatanov
2004-02-13 17:03 ` Ted Zlatanov
` (13 subsequent siblings)
14 siblings, 1 reply; 101+ messages in thread
From: Stefan Monnier @ 2004-02-12 19:48 UTC (permalink / raw)
Cc: emacs-devel
> I saw some discussion of a compile.el update, I hope the new version
> preserves this patch's behavior.
Right now it doesn't.
But it should not be difficult to change.
By the way: why (make-variable-buffer-local 'compilation-next-error-function)?
It seems completely unnecessary. People can make-local-variable when needed.
It's generally clearer if they do it anyway.
Also why not rename next-error to compilation-next-error, then default
compilation-next-error-function to compilation-next-error and just write:
(defun next-error (argp)
(interactive ...)
(with-current-buffer compilation-last-buffer
(funcall compilation-next-error-function argp))
-- Stefan
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 19:48 ` Stefan Monnier
@ 2004-02-12 20:34 ` Ted Zlatanov
2004-02-12 20:57 ` Stefan Monnier
2004-02-12 23:19 ` Kim F. Storm
0 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-12 20:34 UTC (permalink / raw)
Cc: emacs-devel
On 12 Feb 2004, monnier@iro.umontreal.ca wrote:
>> I saw some discussion of a compile.el update, I hope the new
>> version preserves this patch's behavior.
>
> Right now it doesn't.
> But it should not be difficult to change.
OK, I'll be glad to up-rev the patch as needed.
> By the way: why (make-variable-buffer-local
> 'compilation-next-error-function)? It seems completely unnecessary.
> People can make-local-variable when needed. It's generally clearer
> if they do it anyway.
I think Kim suggested that. It's so that multiple modes can set
compilation-next-error-function without using make-local-variable. If
you change it, you're just pushing that work to the modes that use
this interface. I think it's 6 one way, half-dozen the other, so
whatever the Emacs developers prefer is fine with me.
> Also why not rename next-error to compilation-next-error, then
> default compilation-next-error-function to compilation-next-error
> and just write:
>
> (defun next-error (argp)
> (interactive ...)
> (with-current-buffer compilation-last-buffer
> (funcall compilation-next-error-function argp))
compilation-last-buffer is not necessarily what we want. We need to
find a suitable buffer, so you can run next-error anywhere and at any
time. That preserves the existing semantics of next-error; I don't
think your version does. I may be wrong, though.
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 20:34 ` Ted Zlatanov
@ 2004-02-12 20:57 ` Stefan Monnier
2004-02-13 20:58 ` Andreas Schwab
2004-02-12 23:19 ` Kim F. Storm
1 sibling, 1 reply; 101+ messages in thread
From: Stefan Monnier @ 2004-02-12 20:57 UTC (permalink / raw)
Cc: emacs-devel
> I think Kim suggested that. It's so that multiple modes can set
> compilation-next-error-function without using make-local-variable. If
> you change it, you're just pushing that work to the modes that use
> this interface. I think it's 6 one way, half-dozen the other, so
> whatever the Emacs developers prefer is fine with me.
I think the general feling I got over the years is that
make-local-variable should generally be preferred over
make-variable-buffer-local. For exemple the elisp manual says:
The time to use `make-variable-buffer-local' is when it is crucial
that no two buffers ever share the same binding. For example,
when a variable is used for internal purposes in a Lisp program
which depends on having separate values in separate buffers, then
using `make-variable-buffer-local' can be the best solution.
One of the classic pitfalls of make-variable-buffer-local which your code
suffers from is the following:
Say I change diff-mode to do
(setq compilation-next-error-function 'diff-foo)
just like I intend to. Now the behavior will be either to set the local or
the global vriable depending on whether or not compile.el has already
been loaded. And no: requiring compile.el is not an acceptable option.
>> Also why not rename next-error to compilation-next-error, then
>> default compilation-next-error-function to compilation-next-error
>> and just write:
>>
>> (defun next-error (argp)
>> (interactive ...)
>> (with-current-buffer compilation-last-buffer
>> (funcall compilation-next-error-function argp))
> compilation-last-buffer is not necessarily what we want. We need to
> find a suitable buffer, so you can run next-error anywhere and at any
> time. That preserves the existing semantics of next-error; I don't
> think your version does. I may be wrong, though.
My code was not intended to be taken as is, obviously. I just wanted
to say is that instead of
(defvar X-function nil)
...
..(if X-function (funcall X-function) (do-something))
you can do
(defvar X-function 'X-default)
(defun X-default () (do-something))
...
..(funcall X-function)
-- Stefan
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 20:57 ` Stefan Monnier
@ 2004-02-13 20:58 ` Andreas Schwab
2004-02-13 21:04 ` Stefan Monnier
2004-02-14 17:17 ` Richard Stallman
0 siblings, 2 replies; 101+ messages in thread
From: Andreas Schwab @ 2004-02-13 20:58 UTC (permalink / raw)
Cc: Ted Zlatanov, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> One of the classic pitfalls of make-variable-buffer-local which your code
> suffers from is the following:
> Say I change diff-mode to do
>
> (setq compilation-next-error-function 'diff-foo)
>
> just like I intend to. Now the behavior will be either to set the local or
> the global vriable depending on whether or not compile.el has already
> been loaded. And no: requiring compile.el is not an acceptable option.
This can be fixed with
;;;###autoload (make-variable-buffer-local 'compilation-next-error-function)
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 20:34 ` Ted Zlatanov
2004-02-12 20:57 ` Stefan Monnier
@ 2004-02-12 23:19 ` Kim F. Storm
2004-02-14 17:15 ` Richard Stallman
1 sibling, 1 reply; 101+ messages in thread
From: Kim F. Storm @ 2004-02-12 23:19 UTC (permalink / raw)
Cc: Stefan Monnier, emacs-devel
Ted Zlatanov <tzz@lifelogs.com> writes:
> On 12 Feb 2004, monnier@iro.umontreal.ca wrote:
>
> > By the way: why (make-variable-buffer-local
> > 'compilation-next-error-function)? It seems completely unnecessary.
> > People can make-local-variable when needed. It's generally clearer
> > if they do it anyway.
>
> I think Kim suggested that.
Indeed. I find this more logical, as it never makes sense to set the
global value of compilation-next-error-function to a non-nil value.
> > Also why not rename next-error to compilation-next-error, then
> > default compilation-next-error-function to compilation-next-error
> > and just write:
> >
> > (defun next-error (argp)
> > (interactive ...)
> > (with-current-buffer compilation-last-buffer
> > (funcall compilation-next-error-function argp))
>
> compilation-last-buffer is not necessarily what we want.
Indeed, but Stefan has a good point here.
You could define:
(defun compilation-next-error (arg)
(interactive "P")
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
and
(defun next-error (arg)
(interactive "P")
(when (setq compilation-last-buffer (compilation-find-buffer))
(with-current-buffer compilation-last-buffer
(funcall compilation-next-error-function argp))))
And then
(defvar compilation-next-error-function 'compilation-next-error)
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
2004-02-12 19:48 ` Stefan Monnier
@ 2004-02-13 17:03 ` Ted Zlatanov
2004-02-13 21:47 ` Kim F. Storm
2004-02-14 17:16 ` Richard Stallman
2004-02-23 20:18 ` Ted Zlatanov
` (12 subsequent siblings)
14 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-13 17:03 UTC (permalink / raw)
On 13 Feb 2004, storm@cua.dk wrote:
> (defun compilation-next-error (arg)
> (interactive "P")
> (compilation-goto-locus (compilation-next-error-locus
> ;; We want to pass a number here only if
> ;; we got a numeric prefix arg, not just C-u.
> (and (not (consp argp))
> (prefix-numeric-value argp))
> (consp argp))))
> and
> (defun next-error (arg)
> (interactive "P")
> (when (setq compilation-last-buffer (compilation-find-buffer))
> (with-current-buffer compilation-last-buffer
> (funcall compilation-next-error-function argp))))
> And then
> (defvar compilation-next-error-function 'compilation-next-error)
I see. I took Stefan literally with his example.
This looks fine (by now, you've written the patch for me :) and it
adds a whole new dimension to the patch. A lot of other modes in
Emacs could use a general-purpose function like this, and most
already have it but without this "glue" to hold it all together.
This makes me wonder if this should be a separate next-error.el file,
instead of a patch to compile.el... That way we don't have to load
compile.el, and the code presents a standard interface to other
modules. What do you think? If you like next-error.el, I can write
that up.
If we're just modifying compile.el, I need to know if you and Stefan
agree about whether the variable should be just local or buffer-local.
I'm OK with either, though I think just make-local-variable makes more
sense because of the reasons Stefan gave.
Thanks
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-13 17:03 ` Ted Zlatanov
@ 2004-02-13 21:47 ` Kim F. Storm
2004-02-14 17:16 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Kim F. Storm @ 2004-02-13 21:47 UTC (permalink / raw)
Cc: emacs-devel
Ted Zlatanov <tzz@lifelogs.com> writes:
> This makes me wonder if this should be a separate next-error.el file,
> instead of a patch to compile.el... That way we don't have to load
> compile.el, and the code presents a standard interface to other
> modules. What do you think? If you like next-error.el, I can write
> that up.
I agree that splitting next-error out of compile.el would be useful.
I wonder if it really warrents a separate file though; maybe it could
just go into simple.el?
>
> If we're just modifying compile.el, I need to know if you and Stefan
> agree about whether the variable should be just local or buffer-local.
> I'm OK with either, though I think just make-local-variable makes more
> sense because of the reasons Stefan gave.
It is ok with me.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-13 17:03 ` Ted Zlatanov
2004-02-13 21:47 ` Kim F. Storm
@ 2004-02-14 17:16 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-02-14 17:16 UTC (permalink / raw)
Cc: emacs-devel
This makes me wonder if this should be a separate next-error.el file,
instead of a patch to compile.el... That way we don't have to load
compile.el, and the code presents a standard interface to other
modules. What do you think? If you like next-error.el, I can write
that up.
We certainly do not want a separate file for such a small function.
Perhaps we could put it in simple.el.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
2004-02-12 19:48 ` Stefan Monnier
2004-02-13 17:03 ` Ted Zlatanov
@ 2004-02-23 20:18 ` Ted Zlatanov
2004-02-25 13:24 ` Richard Stallman
2004-02-23 20:33 ` Ted Zlatanov
` (11 subsequent siblings)
14 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-23 20:18 UTC (permalink / raw)
On Sat, 14 Feb 2004, rms@gnu.org wrote:
> In making a change of this kind,
> think the most important question is:
>
> what is the criterion for deciding which buffer to use?
>
> What does the current proposed patch do?
Note I'm discussing the updated version of this patch, which I will
post to emacs-devel shortly (in both a unified and a context diff
version).
I follow the behavior of compile.el, which is:
- is the current buffer usable? if yes, use it
- else, if we were given a usable buffer, use that
- else, look through all the buffer for a usable buffer
- else, throw an error
Now, the major difference is that I no longer use
compilation-buffer-p, which also tests if a buffer is a
compilation-mode buffer:
;;; test if a buffer is a compilation buffer
(defsubst compilation-buffer-p (buffer)
"Test if BUFFER is a compilation buffer."
(with-current-buffer buffer
(or compilation-shell-minor-mode
compilation-minor-mode
(eq major-mode 'compilation-mode)
compilation-next-error-function)))
I now use just next-error-buffer-p:
(defsubst next-error-buffer-p (buffer)
"Test if BUFFER is a next-error capable buffer."
(with-current-buffer buffer
next-error-function))
Which will work properly with compile.el (because compile-internal
sets next-error-function), with grep.el (because it uses
compile-internal), and with any other modes that set and support
next-error-function (such as occur, as noted in the modified
replace.el). So backwards compatibility is guaranteed.
I'll mention my other modifications in the post with the patch.
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-23 20:18 ` Ted Zlatanov
@ 2004-02-25 13:24 ` Richard Stallman
0 siblings, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-02-25 13:24 UTC (permalink / raw)
Cc: emacs-devel
I follow the behavior of compile.el, which is:
- is the current buffer usable? if yes, use it
- else, if we were given a usable buffer, use that
Could you say more precisely what "given" means, here?
Do you by any chance mean next-error-last-buffer?
If so, what is the user-level behavior caused by this? Practically
speaking, if the user has done M-x compile and M-x occur, does this
get the compilation buffer or the occur buffer? What criteria
control this choice?
- else, look through all the buffer for a usable buffer
If there is more than one usable buffer, which one do you use?
Is it the compilation buffer, or the occur buffer?
That is a very important question, for usability. The decision must
not be left to chance. It needs to be made intentionally, and we need
to verify users are happy with the decision.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (2 preceding siblings ...)
2004-02-23 20:18 ` Ted Zlatanov
@ 2004-02-23 20:33 ` Ted Zlatanov
2004-02-24 0:37 ` Kim F. Storm
2004-03-02 23:25 ` Kevin Rodgers
` (10 subsequent siblings)
14 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-23 20:33 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
Here's another version of the next-error patch. What it does:
- move the next-error framework to simple.el, so it's always loaded.
This was next-error plus all the related functions.
- make the next-error-function always local (but not buffer-local)
- hook compile.el, occur (in replace.el), and grep.el into the
next-error framework; make it easy to hook more modes into the
framework since it's guaranteed to be always loaded and using it is
as simple as setting next-error-function to something meaningful to
the mode
- preserve the compile.el behavior of:
a) if called in a usable buffer, use it for next-error
b) else, if given a usable buffer, use it
c) else, look through all the buffers and find a suitable one
- fix up some documentation
I hope it's nearly done :) It seems to be useful in its current state.
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error patch --]
[-- Type: text/x-patch, Size: 11164 bytes --]
--- /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/progmodes/compile.el Sat Jan 3 17:38:03 2004
+++ /home/tzz/emacs/mine/compile.el Mon Feb 23 15:34:43 2004
@@ -811,7 +811,13 @@
(select-window outwin)
(goto-char (point-max)))))
;; Make it so the next C-x ` will use this buffer.
- (setq compilation-last-buffer outbuf)))
+ (setq next-error-last-buffer outbuf)
+ (setq compilation-last-buffer outbuf)
+ (with-current-buffer outbuf
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function))))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
@@ -1056,12 +1062,6 @@
(setq errors (cdr errors)))
errors))
-(defsubst compilation-buffer-p (buffer)
- (save-excursion
- (set-buffer buffer)
- (or compilation-shell-minor-mode compilation-minor-mode
- (eq major-mode 'compilation-mode))))
-
(defun compilation-next-error (n)
"Move point to the next error in the compilation buffer.
Prefix arg N says how many error messages to move forwards (or
@@ -1363,88 +1363,33 @@
(push-mark)
(next-error 1))
+;;; test if a buffer is a compilation buffer
+(defsubst compilation-buffer-p (buffer)
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (or compilation-shell-minor-mode
+ compilation-minor-mode
+ (eq major-mode 'compilation-mode)
+ compilation-next-error-function)))
+
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (let ((next-error-buffer-p compilation-buffer-p))
+ (next-error-find-buffer other-buffer)))
;;;###autoload
-(defun next-error (&optional argp)
- "Visit next compilation error message and corresponding source code.
-
-If all the error messages parsed so far have been processed already,
-the message buffer is checked for new ones.
-
-A prefix ARGP specifies how many error messages to move;
-negative means move back to previous error messages.
-Just \\[universal-argument] as a prefix means reparse the error message buffer
-and start at the first error.
-
-\\[next-error] normally uses the most recently started compilation or
-grep buffer. However, it can operate on any buffer with output from
-the \\[compile] and \\[grep] commands, or, more generally, on any
-buffer in Compilation mode or with Compilation Minor mode enabled. To
-specify use of a particular buffer for error messages, type
-\\[next-error] in that buffer.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variables `compilation-parse-errors-function' and
-\`compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (argp)
(interactive "P")
- (setq compilation-last-buffer (compilation-find-buffer))
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (argp)
- "Visit previous compilation error message and corresponding source code.
-
-A prefix ARGP specifies how many error messages to move;
-negative means move forward to next error messages.
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "P")
- (next-error (- (prefix-numeric-value argp))))
-
-(defun first-error ()
- "Reparse the error message buffer and start at the first error.
-Visit corresponding source code.
-This operates on the output from the \\[compile] command."
- (interactive)
- (next-error '(4)))
(defvar compilation-skip-to-next-location nil
"*If non-nil, skip multiple error messages for the same source location.")
--- /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/replace.el Mon Feb 2 09:23:00 2004
+++ /home/tzz/emacs/mine/replace.el Mon Feb 23 15:09:11 2004
@@ -614,6 +614,19 @@
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+(defun occur-next-error (&optional argp)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +813,10 @@
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
- (display-buffer occur-buf)
+ (progn
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf)
+ (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/simple.el Sun Feb 1 03:12:34 2004
+++ /home/tzz/emacs/mine/simple.el Mon Feb 23 15:35:09 2004
@@ -66,6 +66,114 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-local-variable 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ next-error-function))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer)))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers)))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer))
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also operate on any
+buffer with output from the \\[compile], \\[grep] commands, or,
+more generally, on any buffer in Compilation mode or with
+Compilation Minor mode enabled, or any buffer in which
+`next-error-function' is bound to an appropriate
+function. To specify use of a particular buffer for error
+messages, type \\[next-error] in that buffer.
+
+Once \\[next-error] has chosen the buffer for error messages,
+it stays with that buffer until you use it in some other buffer which
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (argp)
+ "Visit previous next-error message and corresponding source code.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move forward to next next-error messages.
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "P")
+ (next-error (- (prefix-numeric-value argp))))
+
+(defun first-error ()
+ "Reparse the next-error message buffer and start over.
+Visit corresponding source code. This operates on the output
+from the \\[compile] and \\[grep] commands, for instance."
+ (interactive)
+ (next-error '(4)))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
[-- Attachment #3: context version of the next-errorpatch for rms --]
[-- Type: text/plain, Size: 12804 bytes --]
*** /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/replace.el Mon Feb 2 09:23:00 2004
--- /home/tzz/emacs/mine/replace.el Mon Feb 23 15:09:11 2004
***************
*** 614,619 ****
--- 614,632 ----
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+ (defun occur-next-error (&optional argp)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 813,822 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf)
! (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
*** /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/progmodes/compile.el Sat Jan 3 17:38:03 2004
--- /home/tzz/emacs/mine/compile.el Mon Feb 23 15:34:43 2004
***************
*** 811,817 ****
(select-window outwin)
(goto-char (point-max)))))
;; Make it so the next C-x ` will use this buffer.
! (setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
--- 811,823 ----
(select-window outwin)
(goto-char (point-max)))))
;; Make it so the next C-x ` will use this buffer.
! (setq next-error-last-buffer outbuf)
! (setq compilation-last-buffer outbuf)
! (with-current-buffer outbuf
! ;; note that compilation-next-error-function is for interfacing
! ;; with the next-error function in simple.el, and it's only
! ;; coincidentally named similarly to compilation-next-error
! (setq next-error-function 'compilation-next-error-function))))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
***************
*** 1056,1067 ****
(setq errors (cdr errors)))
errors))
- (defsubst compilation-buffer-p (buffer)
- (save-excursion
- (set-buffer buffer)
- (or compilation-shell-minor-mode compilation-minor-mode
- (eq major-mode 'compilation-mode))))
-
(defun compilation-next-error (n)
"Move point to the next error in the compilation buffer.
Prefix arg N says how many error messages to move forwards (or
--- 1062,1067 ----
***************
*** 1363,1450 ****
(push-mark)
(next-error 1))
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional argp)
! "Visit next compilation error message and corresponding source code.
!
! If all the error messages parsed so far have been processed already,
! the message buffer is checked for new ones.
!
! A prefix ARGP specifies how many error messages to move;
! negative means move back to previous error messages.
! Just \\[universal-argument] as a prefix means reparse the error message buffer
! and start at the first error.
!
! \\[next-error] normally uses the most recently started compilation or
! grep buffer. However, it can operate on any buffer with output from
! the \\[compile] and \\[grep] commands, or, more generally, on any
! buffer in Compilation mode or with Compilation Minor mode enabled. To
! specify use of a particular buffer for error messages, type
! \\[next-error] in that buffer.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variables `compilation-parse-errors-function' and
! \`compilation-error-regexp-alist' for customization ideas."
(interactive "P")
- (setq compilation-last-buffer (compilation-find-buffer))
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (argp)
- "Visit previous compilation error message and corresponding source code.
-
- A prefix ARGP specifies how many error messages to move;
- negative means move forward to next error messages.
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "P")
- (next-error (- (prefix-numeric-value argp))))
-
- (defun first-error ()
- "Reparse the error message buffer and start at the first error.
- Visit corresponding source code.
- This operates on the output from the \\[compile] command."
- (interactive)
- (next-error '(4)))
(defvar compilation-skip-to-next-location nil
"*If non-nil, skip multiple error messages for the same source location.")
--- 1363,1395 ----
(push-mark)
(next-error 1))
+ ;;; test if a buffer is a compilation buffer
+ (defsubst compilation-buffer-p (buffer)
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (or compilation-shell-minor-mode
+ compilation-minor-mode
+ (eq major-mode 'compilation-mode)
+ compilation-next-error-function)))
+
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (let ((next-error-buffer-p compilation-buffer-p))
! (next-error-find-buffer other-buffer)))
;;;###autoload
! (defun compilation-next-error-function (argp)
(interactive "P")
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
(defvar compilation-skip-to-next-location nil
"*If non-nil, skip multiple error messages for the same source location.")
*** /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/simple.el Sun Feb 1 03:12:34 2004
--- /home/tzz/emacs/mine/simple.el Mon Feb 23 15:35:09 2004
***************
*** 66,71 ****
--- 66,179 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-local-variable 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ next-error-function))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer)))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers)))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer))
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also operate on any
+ buffer with output from the \\[compile], \\[grep] commands, or,
+ more generally, on any buffer in Compilation mode or with
+ Compilation Minor mode enabled, or any buffer in which
+ `next-error-function' is bound to an appropriate
+ function. To specify use of a particular buffer for error
+ messages, type \\[next-error] in that buffer.
+
+ Once \\[next-error] has chosen the buffer for error messages,
+ it stays with that buffer until you use it in some other buffer which
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (argp)
+ "Visit previous next-error message and corresponding source code.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move forward to next next-error messages.
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "P")
+ (next-error (- (prefix-numeric-value argp))))
+
+ (defun first-error ()
+ "Reparse the next-error message buffer and start over.
+ Visit corresponding source code. This operates on the output
+ from the \\[compile] and \\[grep] commands, for instance."
+ (interactive)
+ (next-error '(4)))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-23 20:33 ` Ted Zlatanov
@ 2004-02-24 0:37 ` Kim F. Storm
2004-02-24 17:23 ` Ted Zlatanov
0 siblings, 1 reply; 101+ messages in thread
From: Kim F. Storm @ 2004-02-24 0:37 UTC (permalink / raw)
Cc: emacs-devel
Ted Zlatanov <tzz@lifelogs.com> writes:
> Here's another version of the next-error patch.
Getting closer :-)
> What it does:
>
> - move the next-error framework to simple.el, so it's always loaded.
> This was next-error plus all the related functions.
>
> - make the next-error-function always local (but not buffer-local)
The way you use make-local-variable doesn't accomplish that.
Either use make-variable-buffer-local at the global level (it will work
in this case, as simple.el is pre-loaded.
Or use
(set (make-local-variable 'next-error-function) 'some-function)
everywhere you currently setq next-error-function.
> (defun compilation-find-buffer (&optional other-buffer)
> ! (let ((next-error-buffer-p compilation-buffer-p))
> ! (next-error-find-buffer other-buffer)))
This does not function-bind next-error-buffer-p ...
Does it really work?
> + (make-local-variable 'next-error-function)
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-24 0:37 ` Kim F. Storm
@ 2004-02-24 17:23 ` Ted Zlatanov
0 siblings, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-24 17:23 UTC (permalink / raw)
Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]
On 24 Feb 2004, storm@cua.dk wrote:
>> - make the next-error-function always local (but not buffer-local)
>
> The way you use make-local-variable doesn't accomplish that.
>
> Either use make-variable-buffer-local at the global level (it will
> work in this case, as simple.el is pre-loaded.
Right. Done.
>> (defun compilation-find-buffer (&optional other-buffer)
>> ! (let ((next-error-buffer-p compilation-buffer-p))
>> ! (next-error-find-buffer other-buffer)))
>
> This does not function-bind next-error-buffer-p ...
> Does it really work?
No, I was confused.
Here's another version, which passes in extra tests. I actually like
this better because it lets a mode decide if it wants extra tests,
but will always check next-error-function as it should.
compilation-buffer-p still works as it did before.
bytecomp.el should eventually hook into the next-error framework, I
think. Should I do that too? Any other modes of interest?
I've started using the new next-error heavily, and I wonder how I
managed without it :)
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error patch --]
[-- Type: text/x-patch, Size: 11519 bytes --]
--- /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/progmodes/compile.el Sat Jan 3 17:38:03 2004
+++ /home/tzz/emacs/mine/compile.el Tue Feb 24 12:22:04 2004
@@ -811,7 +811,13 @@
(select-window outwin)
(goto-char (point-max)))))
;; Make it so the next C-x ` will use this buffer.
- (setq compilation-last-buffer outbuf)))
+ (setq next-error-last-buffer outbuf)
+ (setq compilation-last-buffer outbuf)
+ (with-current-buffer outbuf
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function))))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
@@ -1056,12 +1062,6 @@
(setq errors (cdr errors)))
errors))
-(defsubst compilation-buffer-p (buffer)
- (save-excursion
- (set-buffer buffer)
- (or compilation-shell-minor-mode compilation-minor-mode
- (eq major-mode 'compilation-mode))))
-
(defun compilation-next-error (n)
"Move point to the next error in the compilation buffer.
Prefix arg N says how many error messages to move forwards (or
@@ -1363,88 +1363,37 @@
(push-mark)
(next-error 1))
+;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
+(defsubst compilation-buffer-p (buffer)
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+(defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (or compilation-shell-minor-mode
+ compilation-minor-mode
+ (eq major-mode 'compilation-mode)
+ compilation-next-error-function))
+
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
-(defun next-error (&optional argp)
- "Visit next compilation error message and corresponding source code.
-
-If all the error messages parsed so far have been processed already,
-the message buffer is checked for new ones.
-
-A prefix ARGP specifies how many error messages to move;
-negative means move back to previous error messages.
-Just \\[universal-argument] as a prefix means reparse the error message buffer
-and start at the first error.
-
-\\[next-error] normally uses the most recently started compilation or
-grep buffer. However, it can operate on any buffer with output from
-the \\[compile] and \\[grep] commands, or, more generally, on any
-buffer in Compilation mode or with Compilation Minor mode enabled. To
-specify use of a particular buffer for error messages, type
-\\[next-error] in that buffer.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variables `compilation-parse-errors-function' and
-\`compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (argp)
(interactive "P")
- (setq compilation-last-buffer (compilation-find-buffer))
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (argp)
- "Visit previous compilation error message and corresponding source code.
-
-A prefix ARGP specifies how many error messages to move;
-negative means move forward to next error messages.
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "P")
- (next-error (- (prefix-numeric-value argp))))
-
-(defun first-error ()
- "Reparse the error message buffer and start at the first error.
-Visit corresponding source code.
-This operates on the output from the \\[compile] command."
- (interactive)
- (next-error '(4)))
(defvar compilation-skip-to-next-location nil
"*If non-nil, skip multiple error messages for the same source location.")
--- /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/replace.el Mon Feb 2 09:23:00 2004
+++ /home/tzz/emacs/mine/replace.el Mon Feb 23 15:09:11 2004
@@ -614,6 +614,19 @@
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+(defun occur-next-error (&optional argp)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +813,10 @@
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
- (display-buffer occur-buf)
+ (progn
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf)
+ (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/simple.el Sun Feb 1 03:12:34 2004
+++ /home/tzz/emacs/mine/simple.el Tue Feb 24 12:23:28 2004
@@ -66,6 +66,115 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also operate on any
+buffer with output from the \\[compile], \\[grep] commands, or,
+more generally, on any buffer in Compilation mode or with
+Compilation Minor mode enabled, or any buffer in which
+`next-error-function' is bound to an appropriate
+function. To specify use of a particular buffer for error
+messages, type \\[next-error] in that buffer.
+
+Once \\[next-error] has chosen the buffer for error messages,
+it stays with that buffer until you use it in some other buffer which
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (argp)
+ "Visit previous next-error message and corresponding source code.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move forward to next next-error messages.
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "P")
+ (next-error (- (prefix-numeric-value argp))))
+
+(defun first-error ()
+ "Reparse the next-error message buffer and start over.
+Visit corresponding source code. This operates on the output
+from the \\[compile] and \\[grep] commands, for instance."
+ (interactive)
+ (next-error '(4)))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: context version of next-error patch for rms --]
[-- Type: text/x-patch, Size: 13164 bytes --]
*** /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/replace.el Mon Feb 2 09:23:00 2004
--- /home/tzz/emacs/mine/replace.el Mon Feb 23 15:09:11 2004
***************
*** 614,619 ****
--- 614,632 ----
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+ (defun occur-next-error (&optional argp)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 813,822 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf)
! (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
*** /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/progmodes/compile.el Sat Jan 3 17:38:03 2004
--- /home/tzz/emacs/mine/compile.el Tue Feb 24 12:22:04 2004
***************
*** 811,817 ****
(select-window outwin)
(goto-char (point-max)))))
;; Make it so the next C-x ` will use this buffer.
! (setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
--- 811,823 ----
(select-window outwin)
(goto-char (point-max)))))
;; Make it so the next C-x ` will use this buffer.
! (setq next-error-last-buffer outbuf)
! (setq compilation-last-buffer outbuf)
! (with-current-buffer outbuf
! ;; note that compilation-next-error-function is for interfacing
! ;; with the next-error function in simple.el, and it's only
! ;; coincidentally named similarly to compilation-next-error
! (setq next-error-function 'compilation-next-error-function))))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
***************
*** 1056,1067 ****
(setq errors (cdr errors)))
errors))
- (defsubst compilation-buffer-p (buffer)
- (save-excursion
- (set-buffer buffer)
- (or compilation-shell-minor-mode compilation-minor-mode
- (eq major-mode 'compilation-mode))))
-
(defun compilation-next-error (n)
"Move point to the next error in the compilation buffer.
Prefix arg N says how many error messages to move forwards (or
--- 1062,1067 ----
***************
*** 1363,1450 ****
(push-mark)
(next-error 1))
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional argp)
! "Visit next compilation error message and corresponding source code.
!
! If all the error messages parsed so far have been processed already,
! the message buffer is checked for new ones.
!
! A prefix ARGP specifies how many error messages to move;
! negative means move back to previous error messages.
! Just \\[universal-argument] as a prefix means reparse the error message buffer
! and start at the first error.
!
! \\[next-error] normally uses the most recently started compilation or
! grep buffer. However, it can operate on any buffer with output from
! the \\[compile] and \\[grep] commands, or, more generally, on any
! buffer in Compilation mode or with Compilation Minor mode enabled. To
! specify use of a particular buffer for error messages, type
! \\[next-error] in that buffer.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variables `compilation-parse-errors-function' and
! \`compilation-error-regexp-alist' for customization ideas."
(interactive "P")
- (setq compilation-last-buffer (compilation-find-buffer))
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (argp)
- "Visit previous compilation error message and corresponding source code.
-
- A prefix ARGP specifies how many error messages to move;
- negative means move forward to next error messages.
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "P")
- (next-error (- (prefix-numeric-value argp))))
-
- (defun first-error ()
- "Reparse the error message buffer and start at the first error.
- Visit corresponding source code.
- This operates on the output from the \\[compile] command."
- (interactive)
- (next-error '(4)))
(defvar compilation-skip-to-next-location nil
"*If non-nil, skip multiple error messages for the same source location.")
--- 1363,1399 ----
(push-mark)
(next-error 1))
+ ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
+ (defsubst compilation-buffer-p (buffer)
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+ ;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+ (defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (or compilation-shell-minor-mode
+ compilation-minor-mode
+ (eq major-mode 'compilation-mode)
+ compilation-next-error-function))
+
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
! (defun compilation-next-error-function (argp)
(interactive "P")
(compilation-goto-locus (compilation-next-error-locus
;; We want to pass a number here only if
;; we got a numeric prefix arg, not just C-u.
(and (not (consp argp))
(prefix-numeric-value argp))
(consp argp))))
(defvar compilation-skip-to-next-location nil
"*If non-nil, skip multiple error messages for the same source location.")
*** /opt/local-csw/encap/emacs-cvs/share/emacs/21.3.50/lisp/simple.el Sun Feb 1 03:12:34 2004
--- /home/tzz/emacs/mine/simple.el Tue Feb 24 12:23:28 2004
***************
*** 66,71 ****
--- 66,180 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-variable-buffer-local 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also operate on any
+ buffer with output from the \\[compile], \\[grep] commands, or,
+ more generally, on any buffer in Compilation mode or with
+ Compilation Minor mode enabled, or any buffer in which
+ `next-error-function' is bound to an appropriate
+ function. To specify use of a particular buffer for error
+ messages, type \\[next-error] in that buffer.
+
+ Once \\[next-error] has chosen the buffer for error messages,
+ it stays with that buffer until you use it in some other buffer which
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (argp)
+ "Visit previous next-error message and corresponding source code.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move forward to next next-error messages.
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "P")
+ (next-error (- (prefix-numeric-value argp))))
+
+ (defun first-error ()
+ "Reparse the next-error message buffer and start over.
+ Visit corresponding source code. This operates on the output
+ from the \\[compile] and \\[grep] commands, for instance."
+ (interactive)
+ (next-error '(4)))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (3 preceding siblings ...)
2004-02-23 20:33 ` Ted Zlatanov
@ 2004-03-02 23:25 ` Kevin Rodgers
2004-03-03 13:27 ` Stefan Monnier
2004-03-04 16:41 ` Richard Stallman
2004-03-05 18:14 ` Ted Zlatanov
` (9 subsequent siblings)
14 siblings, 2 replies; 101+ messages in thread
From: Kevin Rodgers @ 2004-03-02 23:25 UTC (permalink / raw)
Richard Stallman wrote:
> I follow the behavior of compile.el, which is:
>
> - is the current buffer usable? if yes, use it
>
> - else, if we were given a usable buffer, use that
>
> Could you say more precisely what "given" means, here?
> Do you by any chance mean next-error-last-buffer?
I sure hope so!
> If so, what is the user-level behavior caused by this? Practically
> speaking, if the user has done M-x compile and M-x occur, does this
> get the compilation buffer or the occur buffer? What criteria
> control this choice?
>
> - else, look through all the buffer for a usable buffer
>
> If there is more than one usable buffer, which one do you use?
> Is it the compilation buffer, or the occur buffer?
>
> That is a very important question, for usability. The decision must
> not be left to chance. It needs to be made intentionally, and we need
> to verify users are happy with the decision.
I think next-error should use the last created compile/grep/occur buffer,
which is next-error-last-buffer because those commands reset its value.
But I would like to give the user some control over that. For instance,
if next-error-last-buffer were a list with the most recently created
buffer at the front (like a stack), the user could go back to his/her
previous next-error task simply by killing the most recent
compile/grep/occur buffer. (Those buffers should remove themselves from
the list when they're killed, so that next-error doesn't have to check
for a dead buffer.)
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-03-02 23:25 ` Kevin Rodgers
@ 2004-03-03 13:27 ` Stefan Monnier
2004-03-04 16:41 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-03-03 13:27 UTC (permalink / raw)
Cc: emacs-devel
> But I would like to give the user some control over that. For instance,
> if next-error-last-buffer were a list with the most recently created
> buffer at the front (like a stack), the user could go back to his/her
> previous next-error task simply by killing the most recent
> compile/grep/occur buffer.
I'm not sure it's worth the trouble. They can instead select the desired
buffer and use next-error in it, which will set next-error-last-buffer.
> (Those buffers should remove themselves from
> the list when they're killed, so that next-error doesn't have to check
> for a dead buffer.)
It's probably easier and surely more robust to check for liveness than to
reliably remove buffers from the list.
Stefan
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-03-02 23:25 ` Kevin Rodgers
2004-03-03 13:27 ` Stefan Monnier
@ 2004-03-04 16:41 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-03-04 16:41 UTC (permalink / raw)
Cc: emacs-devel
But I would like to give the user some control over that. For instance,
if next-error-last-buffer were a list with the most recently created
buffer at the front (like a stack), the user could go back to his/her
previous next-error task simply by killing the most recent
compile/grep/occur buffer. (Those buffers should remove themselves from
the list when they're killed, so that next-error doesn't have to check
for a dead buffer.)
Making it a stack of buffers sounds good to me.
Explicit use of a buffer would move it to the front.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (4 preceding siblings ...)
2004-03-02 23:25 ` Kevin Rodgers
@ 2004-03-05 18:14 ` Ted Zlatanov
2004-03-11 20:19 ` Richard Stallman
[not found] ` <jwvr7x06q95.fsf-monnier+emacs <E1Avz1R-0001M2-Df@fencepost.gnu.org>
` (8 subsequent siblings)
14 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-03-05 18:14 UTC (permalink / raw)
On Tue, 02 Mar 2004, ihs_4664@yahoo.com wrote:
> I think next-error should use the last created compile/grep/occur
> buffer, which is next-error-last-buffer because those commands reset
> its value.
>
> But I would like to give the user some control over that. For
> instance, if next-error-last-buffer were a list with the most
> recently created buffer at the front (like a stack), the user could
> go back to his/her previous next-error task simply by killing the
> most recent compile/grep/occur buffer.
I'm not opposed to adding this as a future option, but I don't want to
complicate the intentionally simple interface to next-error (set
next-error-function and next-error-last-buffer, that's it). I think a
list of buffers would complicate life for users and developers alike,
without adding much functionality. It would be especially bad for
backward compatibility, which RMS insists on. So maybe it could be an
optional registration API into next-error for advanced users, but
definitely not the primary interface.
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-03-05 18:14 ` Ted Zlatanov
@ 2004-03-11 20:19 ` Richard Stallman
2004-03-14 2:04 ` Kim F. Storm
0 siblings, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2004-03-11 20:19 UTC (permalink / raw)
Cc: emacs-devel
I'm not opposed to adding this as a future option, but I don't want to
complicate the intentionally simple interface to next-error (set
next-error-function and next-error-last-buffer, that's it). I think a
list of buffers would complicate life for users and developers alike,
without adding much functionality. It would be especially bad for
backward compatibility, which RMS insists on.
There's a misunderstanding here. I am not saying this change must be
entirely "backward compatibility". The intended feature, making
next-error handle Occur buffers, is an incompatible change, but that
is ok.
Rather, the point is to get the behavior for choice of buffers
that will *seem right and convenient to the user*.
Someone pointed out that the stack idea might not really offer much
benefit, though.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-03-11 20:19 ` Richard Stallman
@ 2004-03-14 2:04 ` Kim F. Storm
0 siblings, 0 replies; 101+ messages in thread
From: Kim F. Storm @ 2004-03-14 2:04 UTC (permalink / raw)
Cc: Ted Zlatanov, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> I'm not opposed to adding this as a future option, but I don't want to
> complicate the intentionally simple interface to next-error (set
> next-error-function and next-error-last-buffer, that's it). I think a
> list of buffers would complicate life for users and developers alike,
> without adding much functionality. It would be especially bad for
> backward compatibility, which RMS insists on.
>
> There's a misunderstanding here. I am not saying this change must be
> entirely "backward compatibility". The intended feature, making
> next-error handle Occur buffers, is an incompatible change, but that
> is ok.
>
> Rather, the point is to get the behavior for choice of buffers
> that will *seem right and convenient to the user*.
>
> Someone pointed out that the stack idea might not really offer much
> benefit, though.
IMHO, we should just try this without the stack approach.
If it turns out to work sub-optimal, we can improve it later.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 101+ messages in thread
[parent not found: <jwvr7x06q95.fsf-monnier+emacs <E1Avz1R-0001M2-Df@fencepost.gnu.org>]
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (6 preceding siblings ...)
[not found] ` <jwvr7x06q95.fsf-monnier+emacs <E1Avz1R-0001M2-Df@fencepost.gnu.org>
@ 2004-03-25 5:31 ` Ted Zlatanov
2004-03-25 10:01 ` Kim F. Storm
2004-03-25 16:24 ` Stefan Monnier
2004-04-07 21:01 ` Ted Zlatanov
` (6 subsequent siblings)
14 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-03-25 5:31 UTC (permalink / raw)
On 14 Mar 2004, storm@cua.dk wrote:
> IMHO, we should just try this without the stack approach.
> If it turns out to work sub-optimal, we can improve it later.
Sorry I couldn't write back sooner. If everyone is OK with trying
out the patch I submitted, it can be comitted on a trial basis.
Please let me know if I need to correct any problems in the
next-error patch.
Thanks
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-03-25 5:31 ` Ted Zlatanov
@ 2004-03-25 10:01 ` Kim F. Storm
2004-03-25 16:24 ` Stefan Monnier
1 sibling, 0 replies; 101+ messages in thread
From: Kim F. Storm @ 2004-03-25 10:01 UTC (permalink / raw)
Cc: emacs-devel
Ted Zlatanov <tzz@lifelogs.com> writes:
> On 14 Mar 2004, storm@cua.dk wrote:
>
> > IMHO, we should just try this without the stack approach.
> > If it turns out to work sub-optimal, we can improve it later.
>
> Sorry I couldn't write back sooner. If everyone is OK with trying
> out the patch I submitted, it can be comitted on a trial basis.
> Please let me know if I need to correct any problems in the
> next-error patch.
Since you made your patch, a new (and rather different) version of
compile.el has been installed; please review the changes and adapt
your patch accordingly.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-03-25 5:31 ` Ted Zlatanov
2004-03-25 10:01 ` Kim F. Storm
@ 2004-03-25 16:24 ` Stefan Monnier
1 sibling, 0 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-03-25 16:24 UTC (permalink / raw)
Cc: emacs-devel
>> IMHO, we should just try this without the stack approach.
>> If it turns out to work sub-optimal, we can improve it later.
> Sorry I couldn't write back sooner. If everyone is OK with trying
> out the patch I submitted, it can be comitted on a trial basis.
> Please let me know if I need to correct any problems in the
> next-error patch.
As Kim mentioned, compile.el has changed significantly.
This should not have much impact on your code, tho, since compile.le's
internals have changed, but the UI aspects like next-error and
compilation-last-buffer are left untouched. Nothing to be scared of.
Stefan
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (7 preceding siblings ...)
2004-03-25 5:31 ` Ted Zlatanov
@ 2004-04-07 21:01 ` Ted Zlatanov
2004-04-07 21:50 ` Stefan Monnier
2004-04-08 14:57 ` Richard Stallman
2004-04-14 3:28 ` Ted Zlatanov
` (5 subsequent siblings)
14 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-07 21:01 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 677 bytes --]
On 25 Mar 2004, monnier@iro.umontreal.ca wrote:
> As Kim mentioned, compile.el has changed significantly. This should
> not have much impact on your code, tho, since compile.le's internals
> have changed, but the UI aspects like next-error and
> compilation-last-buffer are left untouched. Nothing to be scared
> of.
It was not entirely painless, but I got the patch ported. Sorry for
the delay.
This is a preliminary version of the patch, so please take a look and
let me know if anything looks off. Also, the author of the new
changes to compile.el should take a look please. I don't think I've
broken anything. I'm testing the patch on my machine now.
Thanks
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error.patch --]
[-- Type: text/x-patch, Size: 11449 bytes --]
--- /local/share/src/emacs-cvs/lisp/progmodes/compile.el Wed Apr 7 16:23:31 2004
+++ /home/tzz/emacs/mine/compile.el Wed Apr 7 16:50:40 2004
@@ -945,7 +945,14 @@
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
- (setq compilation-last-buffer outbuf)))
+ (setq compilation-last-buffer outbuf)
+ (setq next-error-last-buffer outbuf)
+ (setq compilation-last-buffer outbuf)
+ (with-current-buffer outbuf
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function))))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
@@ -1247,8 +1254,16 @@
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
- (local-variable-p 'compilation-locs buffer))
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+(defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (local-variable-p 'compilation-locs (current-buffer)))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
@@ -1379,51 +1394,14 @@
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
-(defun next-error (&optional n)
- "Visit next compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-
-\\[next-error] normally uses the most recently started compilation or
-grep buffer. However, it can operate on any buffer with output from
-the \\[compile] and \\[grep] commands, or, more generally, on any
-buffer in Compilation mode or with Compilation Minor mode enabled. To
-specify use of a particular buffer for error messages, type
-\\[next-error] in that buffer.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variable `compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (argp &optional reset)
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
@@ -1463,27 +1441,6 @@
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
-(defun first-error (n)
- "Restart at the first error.
-Visit corresponding source code.
-With prefix arg N, visit the source code of the Nth error.
-This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- /local/share/src/emacs-cvs/lisp/replace.el Sat Mar 13 03:22:41 2004
+++ /home/tzz/emacs/mine/replace.el Wed Apr 7 16:49:24 2004
@@ -614,6 +614,21 @@
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+(defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +815,10 @@
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
- (display-buffer occur-buf)
+ (progn
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf)
+ (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
@@ -916,7 +934,7 @@
(goto-char headerpt)
(let ((beg (point))
end)
- (insert (format "%d matches for \"%s\" in buffer: %s\n"
+ (insert (format "%d lines matching \"%s\" in buffer: %s\n"
matches regexp (buffer-name buf)))
(setq end (point))
(add-text-properties beg end
--- /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
+++ /home/tzz/emacs/mine/simple.el Wed Apr 7 16:55:23 2004
@@ -66,6 +66,118 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+The RESET argument specifies that we should restart from the beginning
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also operate on any
+buffer with output from the \\[compile], \\[grep] commands, or,
+more generally, on any buffer in Compilation mode or with
+Compilation Minor mode enabled, or any buffer in which
+`next-error-function' is bound to an appropriate
+function. To specify use of a particular buffer for error
+messages, type \\[next-error] in that buffer.
+
+Once \\[next-error] has chosen the buffer for error messages,
+it stays with that buffer until you use it in some other buffer which
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+(defun first-error (n)
+ "Restart at the first error.
+Visit corresponding source code.
+With prefix arg N, visit the source code of the Nth error.
+This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
[-- Attachment #3: simple format patch for RMS --]
[-- Type: text/plain, Size: 13153 bytes --]
*** /local/share/src/emacs-cvs/lisp/replace.el Sat Mar 13 03:22:41 2004
--- /home/tzz/emacs/mine/replace.el Wed Apr 7 16:49:24 2004
***************
*** 614,619 ****
--- 614,634 ----
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+ (defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 815,824 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf)
! (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
***************
*** 916,922 ****
(goto-char headerpt)
(let ((beg (point))
end)
! (insert (format "%d matches for \"%s\" in buffer: %s\n"
matches regexp (buffer-name buf)))
(setq end (point))
(add-text-properties beg end
--- 934,940 ----
(goto-char headerpt)
(let ((beg (point))
end)
! (insert (format "%d lines matching \"%s\" in buffer: %s\n"
matches regexp (buffer-name buf)))
(setq end (point))
(add-text-properties beg end
*** /local/share/src/emacs-cvs/lisp/progmodes/compile.el Wed Apr 7 16:23:31 2004
--- /home/tzz/emacs/mine/compile.el Wed Apr 7 16:50:40 2004
***************
*** 945,951 ****
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
! (setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
--- 945,958 ----
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
! (setq compilation-last-buffer outbuf)
! (setq next-error-last-buffer outbuf)
! (setq compilation-last-buffer outbuf)
! (with-current-buffer outbuf
! ;; note that compilation-next-error-function is for interfacing
! ;; with the next-error function in simple.el, and it's only
! ;; coincidentally named similarly to compilation-next-error
! (setq next-error-function 'compilation-next-error-function))))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
***************
*** 1247,1254 ****
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
(defsubst compilation-buffer-p (buffer)
! (local-variable-p 'compilation-locs buffer))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
--- 1254,1269 ----
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+ ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
! "Test if BUFFER is a compilation buffer."
! (with-current-buffer buffer
! (compilation-buffer-internal-p)))
!
! ;;; test if a buffer is a compilation buffer, assuming we're in the buffer
! (defsubst compilation-buffer-internal-p ()
! "Test if inside a compilation buffer."
! (local-variable-p 'compilation-locs (current-buffer)))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
***************
*** 1379,1429 ****
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional n)
! "Visit next compilation error message and corresponding source code.
! Prefix arg N says how many error messages to move forwards (or
! backwards, if negative).
!
! \\[next-error] normally uses the most recently started compilation or
! grep buffer. However, it can operate on any buffer with output from
! the \\[compile] and \\[grep] commands, or, more generally, on any
! buffer in Compilation mode or with Compilation Minor mode enabled. To
! specify use of a particular buffer for error messages, type
! \\[next-error] in that buffer.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variable `compilation-error-regexp-alist' for customization ideas."
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
--- 1394,1407 ----
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
! (defun compilation-next-error-function (argp &optional reset)
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
***************
*** 1463,1489 ****
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
- (defun first-error (n)
- "Restart at the first error.
- Visit corresponding source code.
- With prefix arg N, visit the source code of the Nth error.
- This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- 1441,1446 ----
*** /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
--- /home/tzz/emacs/mine/simple.el Wed Apr 7 16:55:23 2004
***************
*** 66,71 ****
--- 66,183 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-variable-buffer-local 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ The RESET argument specifies that we should restart from the beginning
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also operate on any
+ buffer with output from the \\[compile], \\[grep] commands, or,
+ more generally, on any buffer in Compilation mode or with
+ Compilation Minor mode enabled, or any buffer in which
+ `next-error-function' is bound to an appropriate
+ function. To specify use of a particular buffer for error
+ messages, type \\[next-error] in that buffer.
+
+ Once \\[next-error] has chosen the buffer for error messages,
+ it stays with that buffer until you use it in some other buffer which
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+ (defun first-error (n)
+ "Restart at the first error.
+ Visit corresponding source code.
+ With prefix arg N, visit the source code of the Nth error.
+ This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-04-07 21:01 ` Ted Zlatanov
@ 2004-04-07 21:50 ` Stefan Monnier
2004-04-08 14:57 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-04-07 21:50 UTC (permalink / raw)
Cc: emacs-devel
> (select-window outwin)
> (goto-char (point-max))))
> ;; Make it so the next C-x ` will use this buffer.
> - (setq compilation-last-buffer outbuf)))
> + (setq compilation-last-buffer outbuf)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
duplicate with the one below.
> + (setq next-error-last-buffer outbuf)
> + (setq compilation-last-buffer outbuf)
> + (with-current-buffer outbuf
> + ;; note that compilation-next-error-function is for interfacing
> + ;; with the next-error function in simple.el, and it's only
> + ;; coincidentally named similarly to compilation-next-error
> + (setq next-error-function 'compilation-next-error-function))))
Shouldn't we get rid of compilation-last-buffer?
And (setq next-error-function 'compilation-next-error-function)
should be in compilation-setup.
> +;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
> (defsubst compilation-buffer-p (buffer)
> - (local-variable-p 'compilation-locs buffer))
> + "Test if BUFFER is a compilation buffer."
> + (with-current-buffer buffer
> + (compilation-buffer-internal-p)))
> +
> +;;; test if a buffer is a compilation buffer, assuming we're in the buffer
> +(defsubst compilation-buffer-internal-p ()
> + "Test if inside a compilation buffer."
> + (local-variable-p 'compilation-locs (current-buffer)))
Huh? This looks like a complicated way to do thing. Just make
the BUFFER argument optional instead (local-variable-p will DTRT).
> +(defun compilation-next-error-function (argp &optional reset)
I'd use a special value like `first' for ARGP instead of adding
a RESET argument. BTW, what does `argp' stand for and wouldn't
you have to update the body since it still presumably refers to the old
N argument name instead?
> + (setq next-error-function 'occur-next-error))
This should be placed in occur-mode.
> +(defvar next-error-last-buffer nil
> +(defvar next-error-function nil
> +(make-variable-buffer-local 'next-error-function)
> +(defsubst next-error-buffer-p (buffer &optional extra-test)
> +(defun next-error-find-buffer (&optional other-buffer extra-test)
> +(defun next-error (argp &optional reset)
> +(defalias 'goto-next-locus 'next-error)
> +(defalias 'next-match 'next-error)
> +(define-key ctl-x-map "`" 'next-error)
> +(defun previous-error (n)
> +(defun first-error (n)
Should we also move next-error-no-select and previous-error-no-select ?
Stefan
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-04-07 21:01 ` Ted Zlatanov
2004-04-07 21:50 ` Stefan Monnier
@ 2004-04-08 14:57 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-04-08 14:57 UTC (permalink / raw)
Cc: emacs-devel
Could you please write the etc/NEWS entry for this patch?
And the lisp/ChangeLog entry; we need that too.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (8 preceding siblings ...)
2004-04-07 21:01 ` Ted Zlatanov
@ 2004-04-14 3:28 ` Ted Zlatanov
2004-04-14 17:57 ` Ted Zlatanov
` (4 subsequent siblings)
14 siblings, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-14 3:28 UTC (permalink / raw)
On Thu, 08 Apr 2004, rms@gnu.org wrote:
> Could you please write the etc/NEWS entry for this patch?
> And the lisp/ChangeLog entry; we need that too.
I'm working on it right now, should be ready Real Soon Now.
Sorry for the delay. I hope the patch makes it before the feature
freeze Kim Storm mentioned.
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (9 preceding siblings ...)
2004-04-14 3:28 ` Ted Zlatanov
@ 2004-04-14 17:57 ` Ted Zlatanov
2004-04-15 0:20 ` Kim F. Storm
2004-04-15 16:44 ` Richard Stallman
2004-04-14 18:04 ` Ted Zlatanov
` (3 subsequent siblings)
14 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-14 17:57 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
After playing catch-up with the changes of compile.el and others,
here's the Latest Next-Error Patch(tm).
I'll address Simon Josefsson's concerns in a followup, and I provide
NEWS and ChangeLog entries.
Please test - it seems to work fine for me.
Thanks
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error patch --]
[-- Type: text/x-patch, Size: 16402 bytes --]
--- /local/share/src/emacs-cvs/lisp/progmodes/compile.el Wed Apr 14 03:23:50 2004
+++ /home/tzz/emacs/mine/compile.el Wed Apr 14 13:46:41 2004
@@ -949,6 +949,7 @@
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
+ (setq next-error-last-buffer outbuf)
(setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
@@ -1141,6 +1142,10 @@
;; jit-lock might fontify some things too late.
(set (make-local-variable 'font-lock-support-mode) nil)
(set (make-local-variable 'font-lock-maximum-size) nil)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(let ((fld font-lock-defaults))
(if (and minor fld)
(font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
@@ -1249,8 +1254,16 @@
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
- (local-variable-p 'compilation-locs buffer))
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+(defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
@@ -1319,25 +1332,6 @@
(interactive "p")
(compilation-next-error (- n)))
-(defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-Finds and highlights the source line like \\[next-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
-(defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-Finds and highlights the source line like \\[previous-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
@@ -1379,51 +1373,14 @@
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
-(defun next-error (&optional n)
- "Visit next compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-
-\\[next-error] normally uses the most recently started compilation or
-grep buffer. However, it can operate on any buffer with output from
-the \\[compile] and \\[grep] commands, or, more generally, on any
-buffer in Compilation mode or with Compilation Minor mode enabled. To
-specify use of a particular buffer for error messages, type
-\\[next-error] in that buffer.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variable `compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (n &optional reset)
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
@@ -1469,27 +1426,6 @@
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
-(defun first-error (n)
- "Restart at the first error.
-Visit corresponding source code.
-With prefix arg N, visit the source code of the Nth error.
-This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
+++ /home/tzz/emacs/mine/replace.el Wed Apr 14 13:53:47 2004
@@ -614,6 +614,21 @@
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+(defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +815,10 @@
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
- (display-buffer occur-buf)
+ (progn
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf)
+ (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
+++ /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
@@ -66,6 +66,137 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+The RESET argument specifies that we should restart from the beginning
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also operate on any
+buffer with output from the \\[compile], \\[grep] commands, or,
+more generally, on any buffer in Compilation mode or with
+Compilation Minor mode enabled, or any buffer in which
+`next-error-function' is bound to an appropriate
+function. To specify use of a particular buffer for error
+messages, type \\[next-error] in that buffer.
+
+Once \\[next-error] has chosen the buffer for error messages,
+it stays with that buffer until you use it in some other buffer which
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+(defun first-error (n)
+ "Restart at the first error.
+Visit corresponding source code.
+With prefix arg N, visit the source code of the Nth error.
+This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+(defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move forwards (or
+backwards, if negative).
+Finds and highlights the source line like \\[next-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+(defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+Finds and highlights the source line like \\[previous-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
--- /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
+++ /home/tzz/emacs/mine/NEWS Tue Apr 13 17:04:54 2004
@@ -14,6 +14,14 @@
\f
* Installation Changes in Emacs 21.4
+** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
+
+** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
---
** A Bulgarian translation of the Emacs Tutorial is available.
@@ -87,12 +95,6 @@
\f
* Changes in Emacs 21.4
-
-** New command line option -Q.
-
-This is like using -q --no-site-file, but in addition it also disables
-the menu-bar, the tool-bar, the scroll-bars, tool tips, the blinking
-cursor, and the fancy startup screen.
** C-h v and C-h f commands now include a hyperlink to the C source for
variables and functions defined in C (if the C source is available).
--- /local/share/src/emacs-cvs/lisp/ChangeLog Wed Apr 14 03:23:43 2004
+++ /home/tzz/emacs/mine/ChangeLog Wed Apr 14 14:06:05 2004
@@ -1,28 +1,27 @@
-2004-04-14 Daniel Pfeiffer <occitan@esperanto.org>
+2004-04-14 Teodor Zlatanov <tzz@lifelogs.com>
- * progmodes/compile.el (compilation-setup): Localize
- overlay-arrow-position.
- (compilation-sentinel): Restructure code equivalently.
- (compilation-next-error): Find message on same line after point if
- not found before point.
- (compile-mouse-goto-error): Restore function so that compilation
- buffer need not be current and use compile-goto-error.
- (compile-goto-error): Restore function.
- (next-error): Set overlay-arrow-position.
- (compilation-forget-errors): Don't localize already local
- compilation-locs and remove FIXME about refontifying.
+ * simple.el (next-error-last-buffer, next-error-function): new
+ variables for the next-error framework
+ (next-error-buffer-p): is a buffer capable of next-error?
+ (next-error-find-buffer): the functionality of
+ compilation-find-buffer, generalized
+ (next-error, previous-error, first-error, next-error-no-select)
+ (previous-error-no-select): next-error framework
-2004-04-14 Kim F. Storm <storm@cua.dk>
+ * replace.el (occur-next-error, occur-1): support the next-error
+ framework
- * startup.el (emacs-quick-startup): New defvar (set by -Q).
- (command-line): New option -Q. Like -q --no-site-file, but
- in addition it also disables menu-bar, tool-bar, scroll-bars,
- tool-tips, and the blinking cursor.
- (command-line-1): Skip startup screen if -Q.
- (fancy-splash-head): Use :align-to center prop to center splash image.
-
- * emulation/cua-base.el (cua-read-only-cursor-color)
- (cua-overwrite-cursor-color, cua-global-mark-cursor-color): Doc fix.
+ * compile.el (compilation-start): set next-error-last-buffer so
+ next-error knows where to jump
+ (compilation-setup): set the buffer-local variable
+ next-error-function to 'compilation-next-error-function
+ (compilation-buffer-p, compilation-buffer-internal-p): use an
+ alternate way to find if a buffer is a compilation buffer, for
+ next-error convenience
+ (next-error-no-select, previous-error-no-select, next-error)
+ (previous-error, first-error): moved to simple.el
+ (compilation-find-buffer): functionality moved to
+ next-error-find-buffer in simple.el
2004-04-13 Dave Love <fx@gnu.org>
[-- Attachment #3: context patch for RMS --]
[-- Type: text/plain, Size: 17979 bytes --]
*** /local/share/src/emacs-cvs/lisp/progmodes/compile.el Wed Apr 14 03:23:50 2004
--- /home/tzz/emacs/mine/compile.el Wed Apr 14 13:46:41 2004
***************
*** 949,954 ****
--- 949,955 ----
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
+ (setq next-error-last-buffer outbuf)
(setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
***************
*** 1141,1146 ****
--- 1142,1151 ----
;; jit-lock might fontify some things too late.
(set (make-local-variable 'font-lock-support-mode) nil)
(set (make-local-variable 'font-lock-maximum-size) nil)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(let ((fld font-lock-defaults))
(if (and minor fld)
(font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
***************
*** 1249,1256 ****
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
(defsubst compilation-buffer-p (buffer)
! (local-variable-p 'compilation-locs buffer))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
--- 1254,1269 ----
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+ ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
! "Test if BUFFER is a compilation buffer."
! (with-current-buffer buffer
! (compilation-buffer-internal-p)))
!
! ;;; test if a buffer is a compilation buffer, assuming we're in the buffer
! (defsubst compilation-buffer-internal-p ()
! "Test if inside a compilation buffer."
! (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
***************
*** 1319,1343 ****
(interactive "p")
(compilation-next-error (- n)))
- (defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move forwards (or
- backwards, if negative).
- Finds and highlights the source line like \\[next-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
- (defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
- Finds and highlights the source line like \\[previous-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
--- 1332,1337 ----
***************
*** 1379,1429 ****
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional n)
! "Visit next compilation error message and corresponding source code.
! Prefix arg N says how many error messages to move forwards (or
! backwards, if negative).
!
! \\[next-error] normally uses the most recently started compilation or
! grep buffer. However, it can operate on any buffer with output from
! the \\[compile] and \\[grep] commands, or, more generally, on any
! buffer in Compilation mode or with Compilation Minor mode enabled. To
! specify use of a particular buffer for error messages, type
! \\[next-error] in that buffer.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variable `compilation-error-regexp-alist' for customization ideas."
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
--- 1373,1386 ----
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
! (defun compilation-next-error-function (n &optional reset)
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
***************
*** 1469,1495 ****
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
- (defun first-error (n)
- "Restart at the first error.
- Visit corresponding source code.
- With prefix arg N, visit the source code of the Nth error.
- This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- 1426,1431 ----
*** /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
--- /home/tzz/emacs/mine/replace.el Wed Apr 14 13:53:47 2004
***************
*** 614,619 ****
--- 614,634 ----
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+ (defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 815,824 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf)
! (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
*** /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
--- /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
***************
*** 66,71 ****
--- 66,202 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-variable-buffer-local 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ The RESET argument specifies that we should restart from the beginning
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also operate on any
+ buffer with output from the \\[compile], \\[grep] commands, or,
+ more generally, on any buffer in Compilation mode or with
+ Compilation Minor mode enabled, or any buffer in which
+ `next-error-function' is bound to an appropriate
+ function. To specify use of a particular buffer for error
+ messages, type \\[next-error] in that buffer.
+
+ Once \\[next-error] has chosen the buffer for error messages,
+ it stays with that buffer until you use it in some other buffer which
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+ (defun first-error (n)
+ "Restart at the first error.
+ Visit corresponding source code.
+ With prefix arg N, visit the source code of the Nth error.
+ This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+ (defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move forwards (or
+ backwards, if negative).
+ Finds and highlights the source line like \\[next-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+ (defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+ Finds and highlights the source line like \\[previous-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
*** /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
--- /home/tzz/emacs/mine/NEWS Tue Apr 13 17:04:54 2004
***************
*** 14,19 ****
--- 14,27 ----
\f
* Installation Changes in Emacs 21.4
+ ** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
+
+ ** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
---
** A Bulgarian translation of the Emacs Tutorial is available.
***************
*** 87,98 ****
\f
* Changes in Emacs 21.4
-
- ** New command line option -Q.
-
- This is like using -q --no-site-file, but in addition it also disables
- the menu-bar, the tool-bar, the scroll-bars, tool tips, the blinking
- cursor, and the fancy startup screen.
** C-h v and C-h f commands now include a hyperlink to the C source for
variables and functions defined in C (if the C source is available).
--- 95,100 ----
*** /local/share/src/emacs-cvs/lisp/ChangeLog Wed Apr 14 03:23:43 2004
--- /home/tzz/emacs/mine/ChangeLog Wed Apr 14 14:06:05 2004
***************
*** 1,28 ****
! 2004-04-14 Daniel Pfeiffer <occitan@esperanto.org>
! * progmodes/compile.el (compilation-setup): Localize
! overlay-arrow-position.
! (compilation-sentinel): Restructure code equivalently.
! (compilation-next-error): Find message on same line after point if
! not found before point.
! (compile-mouse-goto-error): Restore function so that compilation
! buffer need not be current and use compile-goto-error.
! (compile-goto-error): Restore function.
! (next-error): Set overlay-arrow-position.
! (compilation-forget-errors): Don't localize already local
! compilation-locs and remove FIXME about refontifying.
! 2004-04-14 Kim F. Storm <storm@cua.dk>
! * startup.el (emacs-quick-startup): New defvar (set by -Q).
! (command-line): New option -Q. Like -q --no-site-file, but
! in addition it also disables menu-bar, tool-bar, scroll-bars,
! tool-tips, and the blinking cursor.
! (command-line-1): Skip startup screen if -Q.
! (fancy-splash-head): Use :align-to center prop to center splash image.
!
! * emulation/cua-base.el (cua-read-only-cursor-color)
! (cua-overwrite-cursor-color, cua-global-mark-cursor-color): Doc fix.
2004-04-13 Dave Love <fx@gnu.org>
--- 1,27 ----
! 2004-04-14 Teodor Zlatanov <tzz@lifelogs.com>
! * simple.el (next-error-last-buffer, next-error-function): new
! variables for the next-error framework
! (next-error-buffer-p): is a buffer capable of next-error?
! (next-error-find-buffer): the functionality of
! compilation-find-buffer, generalized
! (next-error, previous-error, first-error, next-error-no-select)
! (previous-error-no-select): next-error framework
! * replace.el (occur-next-error, occur-1): support the next-error
! framework
! * compile.el (compilation-start): set next-error-last-buffer so
! next-error knows where to jump
! (compilation-setup): set the buffer-local variable
! next-error-function to 'compilation-next-error-function
! (compilation-buffer-p, compilation-buffer-internal-p): use an
! alternate way to find if a buffer is a compilation buffer, for
! next-error convenience
! (next-error-no-select, previous-error-no-select, next-error)
! (previous-error, first-error): moved to simple.el
! (compilation-find-buffer): functionality moved to
! next-error-find-buffer in simple.el
2004-04-13 Dave Love <fx@gnu.org>
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-04-14 17:57 ` Ted Zlatanov
@ 2004-04-15 0:20 ` Kim F. Storm
2004-04-15 1:29 ` Kim F. Storm
2004-04-15 16:44 ` Richard Stallman
1 sibling, 1 reply; 101+ messages in thread
From: Kim F. Storm @ 2004-04-15 0:20 UTC (permalink / raw)
Cc: emacs-devel
Ted Zlatanov <tzz@lifelogs.com> writes:
> After playing catch-up with the changes of compile.el and others,
> here's the Latest Next-Error Patch(tm).
>
I haven't tested it, but it looks good to me.
There is one mistake in the patch --> it deletes some recent additions to
lisp/ChangeLog and etc/NEWS, probably because you didn't cvs update before
creating the patch.
How about legal papers for this? I cannot find your name in the
copyright assignment file.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-04-14 17:57 ` Ted Zlatanov
2004-04-15 0:20 ` Kim F. Storm
@ 2004-04-15 16:44 ` Richard Stallman
1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-04-15 16:44 UTC (permalink / raw)
Cc: emacs-devel
* Installation Changes in Emacs 21.4
+ ** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
That is internal, not worth mentioning in NEWS.
+
+ ** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
That is the feature worth mentioning. It should be in the following
section, "Changes in Emacs 21.4", not in the Installation Changes
section.
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (10 preceding siblings ...)
2004-04-14 17:57 ` Ted Zlatanov
@ 2004-04-14 18:04 ` Ted Zlatanov
2004-04-14 21:57 ` Stefan Monnier
2004-04-15 15:40 ` Ted Zlatanov
` (2 subsequent siblings)
14 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-14 18:04 UTC (permalink / raw)
On 07 Apr 2004, monnier@iro.umontreal.ca wrote:
>> (select-window outwin)
>> (goto-char (point-max))))
>> ;; Make it so the next C-x ` will use this buffer.
>> - (setq compilation-last-buffer outbuf)))
>> + (setq compilation-last-buffer outbuf)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> duplicate with the one below.
Fixed.
+ (setq next-error-last-buffer outbuf)
+ (setq compilation-last-buffer outbuf)
+ (with-current-buffer outbuf
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function))))
>
> Shouldn't we get rid of compilation-last-buffer?
I think that would be OK. Any dissenters? :)
> And (setq next-error-function 'compilation-next-error-function)
> should be in compilation-setup.
Done.
>> +;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
>> (defsubst compilation-buffer-p (buffer)
>> - (local-variable-p 'compilation-locs buffer))
>> + "Test if BUFFER is a compilation buffer."
>> + (with-current-buffer buffer
>> + (compilation-buffer-internal-p)))
>> +
>> +;;; test if a buffer is a compilation buffer, assuming we're in the buffer
>> +(defsubst compilation-buffer-internal-p ()
>> + "Test if inside a compilation buffer."
>> + (local-variable-p 'compilation-locs (current-buffer)))
>
> Huh? This looks like a complicated way to do thing. Just make
> the BUFFER argument optional instead (local-variable-p will
> DTRT).
Done, thanks.
>
>> +(defun compilation-next-error-function (argp &optional reset)
>
> I'd use a special value like `first' for ARGP instead of adding
> a RESET argument. BTW, what does `argp' stand for and wouldn't
> you have to update the body since it still presumably refers to the old
> N argument name instead?
With RESET, the function acts as if first-error was called and
then next-error N was called. Good catch on ARGP, that was my
mistake.
>
>> + (setq next-error-function 'occur-next-error))
>
> This should be placed in occur-mode.
It's in replace.el, where occur-mode is defined.
>> +(defvar next-error-last-buffer nil
>> +(defvar next-error-function nil
>> +(make-variable-buffer-local 'next-error-function)
>> +(defsubst next-error-buffer-p (buffer &optional extra-test)
>> +(defun next-error-find-buffer (&optional other-buffer extra-test)
>> +(defun next-error (argp &optional reset)
>> +(defalias 'goto-next-locus 'next-error)
>> +(defalias 'next-match 'next-error)
>> +(define-key ctl-x-map "`" 'next-error)
>> +(defun previous-error (n)
>> +(defun first-error (n)
>
> Should we also move next-error-no-select and previous-error-no-select ?
Done.
Thank you very much for the thorough review. All the changes are
in the latest patch I just posted.
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (11 preceding siblings ...)
2004-04-14 18:04 ` Ted Zlatanov
@ 2004-04-15 15:40 ` Ted Zlatanov
2004-04-15 15:59 ` Ted Zlatanov
2004-04-15 18:43 ` Ted Zlatanov
14 siblings, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-15 15:40 UTC (permalink / raw)
On 15 Apr 2004, storm@cua.dk wrote:
> storm@cua.dk (Kim F. Storm) writes:
>
>> Ted Zlatanov <tzz@lifelogs.com> writes:
>
>> How about legal papers for this? I cannot find your name in the
>> copyright assignment file.
>
> I looked closer, and there is an entry for Teodor Zlatonov (I
> suppose that's a typo). However, that assignment only covers
> changes to GNUS, not emacs as a whole.
My papers for Emacs (in addition to Gnus) are on file with the FSF. I
have a copy at home if the FSF lost the ones I sent some time ago.
Ted
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (12 preceding siblings ...)
2004-04-15 15:40 ` Ted Zlatanov
@ 2004-04-15 15:59 ` Ted Zlatanov
2004-04-15 18:43 ` Ted Zlatanov
14 siblings, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-15 15:59 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
On 15 Apr 2004, storm@cua.dk wrote:
> I haven't tested it, but it looks good to me.
> There is one mistake in the patch --> it deletes some recent
> additions to lisp/ChangeLog and etc/NEWS, probably because you
> didn't cvs update before creating the patch.
I did update, but a lot of updates to compile.el and ChangeLog are
happening. The attached patch is as of this morning (12:00 on April
15).
The major change is that compilation-last-buffer, which was a
write-only variable, has been removed. Otherwise, all the code is
the same as before.
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error patch --]
[-- Type: text/x-patch, Size: 16783 bytes --]
--- /local/share/src/emacs-cvs/lisp/progmodes/compile.el Thu Apr 15 03:23:34 2004
+++ /home/tzz/emacs/mine/compile.el Thu Apr 15 11:54:19 2004
@@ -125,11 +125,6 @@
Each function is called with two arguments: the compilation buffer,
and a string describing how the process finished.")
-(defvar compilation-last-buffer nil
- "The most recent compilation buffer.
-A buffer becomes most recent when its compilation is started
-or when it is used with \\[next-error] or \\[compile-goto-error].")
-
(defvar compilation-in-progress nil
"List of compilation processes now running.")
(or (assq 'compilation-in-progress minor-mode-alist)
@@ -950,7 +945,7 @@
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
- (setq compilation-last-buffer outbuf)))
+ (setq next-error-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
@@ -1081,6 +1076,10 @@
(set (make-local-variable 'page-delimiter)
compilation-page-delimiter)
(compilation-setup)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(run-mode-hooks 'compilation-mode-hook))
(defmacro define-compilation-mode (mode name doc &rest body)
@@ -1140,7 +1139,6 @@
(make-local-variable 'compilation-current-error)
(make-local-variable 'compilation-error-screen-columns)
(make-local-variable 'overlay-arrow-position)
- (setq compilation-last-buffer (current-buffer))
(set (make-local-variable 'font-lock-extra-managed-props)
'(directory message help-echo mouse-face debug))
(set (make-local-variable 'compilation-locs)
@@ -1257,8 +1255,16 @@
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
- (local-variable-p 'compilation-locs buffer))
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+(defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
@@ -1289,7 +1295,6 @@
(or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer"))
(or pt (setq pt (point)))
- (setq compilation-last-buffer (current-buffer))
(let* ((msg (get-text-property pt 'message))
(loc (car msg))
last)
@@ -1327,25 +1332,6 @@
(interactive "p")
(compilation-next-error (- n)))
-(defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-Finds and highlights the source line like \\[next-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
-(defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-Finds and highlights the source line like \\[previous-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
@@ -1383,55 +1369,17 @@
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
-;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
-(defun next-error (&optional n)
- "Visit next compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-
-\\[next-error] normally uses the most recently started compilation or
-grep buffer. However, it can operate on any buffer with output from
-the \\[compile] and \\[grep] commands, or, more generally, on any
-buffer in Compilation mode or with Compilation Minor mode enabled. To
-specify use of a particular buffer for error messages, type
-\\[next-error] in that buffer.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variable `compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (n &optional reset)
(interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (set-buffer (compilation-find-buffer))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
@@ -1477,27 +1425,6 @@
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
-(defun first-error (n)
- "Restart at the first error.
-Visit corresponding source code.
-With prefix arg N, visit the source code of the Nth error.
-This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
+++ /home/tzz/emacs/mine/replace.el Thu Apr 15 11:38:08 2004
@@ -538,6 +538,7 @@
(set (make-local-variable 'revert-buffer-function) 'occur-revert-function)
(make-local-variable 'occur-revert-arguments)
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+ (setq next-error-function 'occur-next-error)
(run-hooks 'occur-mode-hook))
(defun occur-revert-function (ignore1 ignore2)
@@ -614,6 +615,21 @@
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+(defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +816,9 @@
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
- (display-buffer occur-buf)
+ (progn
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
+++ /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
@@ -66,6 +66,137 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+The RESET argument specifies that we should restart from the beginning
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also operate on any
+buffer with output from the \\[compile], \\[grep] commands, or,
+more generally, on any buffer in Compilation mode or with
+Compilation Minor mode enabled, or any buffer in which
+`next-error-function' is bound to an appropriate
+function. To specify use of a particular buffer for error
+messages, type \\[next-error] in that buffer.
+
+Once \\[next-error] has chosen the buffer for error messages,
+it stays with that buffer until you use it in some other buffer which
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+(defun first-error (n)
+ "Restart at the first error.
+Visit corresponding source code.
+With prefix arg N, visit the source code of the Nth error.
+This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+(defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move forwards (or
+backwards, if negative).
+Finds and highlights the source line like \\[next-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+(defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+Finds and highlights the source line like \\[previous-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
--- /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
+++ /home/tzz/emacs/mine/NEWS Thu Apr 15 11:47:06 2004
@@ -14,6 +14,14 @@
\f
* Installation Changes in Emacs 21.4
+** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
+
+** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
---
** A Bulgarian translation of the Emacs Tutorial is available.
--- /local/share/src/emacs-cvs/lisp/ChangeLog Thu Apr 15 03:23:30 2004
+++ /home/tzz/emacs/mine/ChangeLog Thu Apr 15 11:50:15 2004
@@ -1,3 +1,32 @@
+2004-04-15 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * simple.el (next-error-last-buffer, next-error-function): new
+ variables for the next-error framework
+ (next-error-buffer-p): is a buffer capable of next-error?
+ (next-error-find-buffer): the functionality of
+ compilation-find-buffer, generalized
+ (next-error, previous-error, first-error, next-error-no-select)
+ (previous-error-no-select): next-error framework
+
+ * replace.el (occur-next-error, occur-1): support the next-error
+ framework
+
+ * compile.el (compilation-start): set next-error-last-buffer so
+ next-error knows where to jump
+ (compilation-setup): set the buffer-local variable
+ next-error-function to 'compilation-next-error-function
+ (compilation-buffer-p, compilation-buffer-internal-p): use an
+ alternate way to find if a buffer is a compilation buffer, for
+ next-error convenience
+ (next-error-no-select, previous-error-no-select, next-error)
+ (previous-error, first-error): moved to simple.el
+ (compilation-find-buffer): functionality moved to
+ next-error-find-buffer in simple.el
+ (compilation-last-buffer): removed
+ (compilation-start, compilation-next-error, compilation-setup)
+ (compilation-next-error-function, compilation-find-buffer):
+ remove compilation-last-buffer use
+
2004-04-14 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/bytecomp.el (batch-byte-compile-file):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: context patch for RMS --]
[-- Type: text/x-patch, Size: 18677 bytes --]
*** /local/share/src/emacs-cvs/lisp/progmodes/compile.el Thu Apr 15 03:23:34 2004
--- /home/tzz/emacs/mine/compile.el Thu Apr 15 11:54:19 2004
***************
*** 125,135 ****
Each function is called with two arguments: the compilation buffer,
and a string describing how the process finished.")
- (defvar compilation-last-buffer nil
- "The most recent compilation buffer.
- A buffer becomes most recent when its compilation is started
- or when it is used with \\[next-error] or \\[compile-goto-error].")
-
(defvar compilation-in-progress nil
"List of compilation processes now running.")
(or (assq 'compilation-in-progress minor-mode-alist)
--- 125,130 ----
***************
*** 950,956 ****
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
! (setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
--- 945,951 ----
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
! (setq next-error-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
***************
*** 1081,1086 ****
--- 1076,1085 ----
(set (make-local-variable 'page-delimiter)
compilation-page-delimiter)
(compilation-setup)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(run-mode-hooks 'compilation-mode-hook))
(defmacro define-compilation-mode (mode name doc &rest body)
***************
*** 1140,1146 ****
(make-local-variable 'compilation-current-error)
(make-local-variable 'compilation-error-screen-columns)
(make-local-variable 'overlay-arrow-position)
- (setq compilation-last-buffer (current-buffer))
(set (make-local-variable 'font-lock-extra-managed-props)
'(directory message help-echo mouse-face debug))
(set (make-local-variable 'compilation-locs)
--- 1139,1144 ----
***************
*** 1257,1264 ****
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
(defsubst compilation-buffer-p (buffer)
! (local-variable-p 'compilation-locs buffer))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
--- 1255,1270 ----
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+ ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
! "Test if BUFFER is a compilation buffer."
! (with-current-buffer buffer
! (compilation-buffer-internal-p)))
!
! ;;; test if a buffer is a compilation buffer, assuming we're in the buffer
! (defsubst compilation-buffer-internal-p ()
! "Test if inside a compilation buffer."
! (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
***************
*** 1289,1295 ****
(or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer"))
(or pt (setq pt (point)))
- (setq compilation-last-buffer (current-buffer))
(let* ((msg (get-text-property pt 'message))
(loc (car msg))
last)
--- 1295,1300 ----
***************
*** 1327,1351 ****
(interactive "p")
(compilation-next-error (- n)))
- (defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move forwards (or
- backwards, if negative).
- Finds and highlights the source line like \\[next-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
- (defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
- Finds and highlights the source line like \\[previous-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
--- 1332,1337 ----
***************
*** 1383,1437 ****
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
- ;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional n)
! "Visit next compilation error message and corresponding source code.
! Prefix arg N says how many error messages to move forwards (or
! backwards, if negative).
!
! \\[next-error] normally uses the most recently started compilation or
! grep buffer. However, it can operate on any buffer with output from
! the \\[compile] and \\[grep] commands, or, more generally, on any
! buffer in Compilation mode or with Compilation Minor mode enabled. To
! specify use of a particular buffer for error messages, type
! \\[next-error] in that buffer.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variable `compilation-error-regexp-alist' for customization ideas."
(interactive "p")
! (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
--- 1369,1385 ----
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
! (defun compilation-next-error-function (n &optional reset)
(interactive "p")
! (set-buffer (compilation-find-buffer))
! (when reset
! (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
***************
*** 1477,1503 ****
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
- (defun first-error (n)
- "Restart at the first error.
- Visit corresponding source code.
- With prefix arg N, visit the source code of the Nth error.
- This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- 1425,1430 ----
*** /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
--- /home/tzz/emacs/mine/replace.el Thu Apr 15 11:38:08 2004
***************
*** 538,543 ****
--- 538,544 ----
(set (make-local-variable 'revert-buffer-function) 'occur-revert-function)
(make-local-variable 'occur-revert-arguments)
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+ (setq next-error-function 'occur-next-error)
(run-hooks 'occur-mode-hook))
(defun occur-revert-function (ignore1 ignore2)
***************
*** 614,619 ****
--- 615,635 ----
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+ (defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 816,824 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
*** /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
--- /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
***************
*** 66,71 ****
--- 66,202 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-variable-buffer-local 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ The RESET argument specifies that we should restart from the beginning
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also operate on any
+ buffer with output from the \\[compile], \\[grep] commands, or,
+ more generally, on any buffer in Compilation mode or with
+ Compilation Minor mode enabled, or any buffer in which
+ `next-error-function' is bound to an appropriate
+ function. To specify use of a particular buffer for error
+ messages, type \\[next-error] in that buffer.
+
+ Once \\[next-error] has chosen the buffer for error messages,
+ it stays with that buffer until you use it in some other buffer which
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+ (defun first-error (n)
+ "Restart at the first error.
+ Visit corresponding source code.
+ With prefix arg N, visit the source code of the Nth error.
+ This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+ (defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move forwards (or
+ backwards, if negative).
+ Finds and highlights the source line like \\[next-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+ (defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+ Finds and highlights the source line like \\[previous-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
*** /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
--- /home/tzz/emacs/mine/NEWS Thu Apr 15 11:47:06 2004
***************
*** 14,19 ****
--- 14,27 ----
\f
* Installation Changes in Emacs 21.4
+ ** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
+
+ ** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
---
** A Bulgarian translation of the Emacs Tutorial is available.
*** /local/share/src/emacs-cvs/lisp/ChangeLog Thu Apr 15 03:23:30 2004
--- /home/tzz/emacs/mine/ChangeLog Thu Apr 15 11:50:15 2004
***************
*** 1,3 ****
--- 1,32 ----
+ 2004-04-15 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * simple.el (next-error-last-buffer, next-error-function): new
+ variables for the next-error framework
+ (next-error-buffer-p): is a buffer capable of next-error?
+ (next-error-find-buffer): the functionality of
+ compilation-find-buffer, generalized
+ (next-error, previous-error, first-error, next-error-no-select)
+ (previous-error-no-select): next-error framework
+
+ * replace.el (occur-next-error, occur-1): support the next-error
+ framework
+
+ * compile.el (compilation-start): set next-error-last-buffer so
+ next-error knows where to jump
+ (compilation-setup): set the buffer-local variable
+ next-error-function to 'compilation-next-error-function
+ (compilation-buffer-p, compilation-buffer-internal-p): use an
+ alternate way to find if a buffer is a compilation buffer, for
+ next-error convenience
+ (next-error-no-select, previous-error-no-select, next-error)
+ (previous-error, first-error): moved to simple.el
+ (compilation-find-buffer): functionality moved to
+ next-error-find-buffer in simple.el
+ (compilation-last-buffer): removed
+ (compilation-start, compilation-next-error, compilation-setup)
+ (compilation-next-error-function, compilation-find-buffer):
+ remove compilation-last-buffer use
+
2004-04-14 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/bytecomp.el (batch-byte-compile-file):
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: Add M-x occur to the menu-bar
2004-02-12 16:46 ` Ted Zlatanov
` (13 preceding siblings ...)
2004-04-15 15:59 ` Ted Zlatanov
@ 2004-04-15 18:43 ` Ted Zlatanov
14 siblings, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-04-15 18:43 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 528 bytes --]
On Thu, 15 Apr 2004, rms@gnu.org wrote:
> * Installation Changes in Emacs 21.4
>
+ ** next-error and previous-error were moved from compile.el to...
>
> That is internal, not worth mentioning in NEWS.
>
> + ** occur-mode can advance to the next/previous error with next-error
> + and previous-error
>
> That is the feature worth mentioning. It should be in the following
> section, "Changes in Emacs 21.4", not in the Installation Changes
> section.
Both changes were done. Latest patch attached.
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error.patch --]
[-- Type: text/x-patch, Size: 16576 bytes --]
--- /local/share/src/emacs-cvs/lisp/progmodes/compile.el Thu Apr 15 03:23:34 2004
+++ /home/tzz/emacs/mine/compile.el Thu Apr 15 11:54:19 2004
@@ -125,11 +125,6 @@
Each function is called with two arguments: the compilation buffer,
and a string describing how the process finished.")
-(defvar compilation-last-buffer nil
- "The most recent compilation buffer.
-A buffer becomes most recent when its compilation is started
-or when it is used with \\[next-error] or \\[compile-goto-error].")
-
(defvar compilation-in-progress nil
"List of compilation processes now running.")
(or (assq 'compilation-in-progress minor-mode-alist)
@@ -950,7 +945,7 @@
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
- (setq compilation-last-buffer outbuf)))
+ (setq next-error-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
@@ -1081,6 +1076,10 @@
(set (make-local-variable 'page-delimiter)
compilation-page-delimiter)
(compilation-setup)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(run-mode-hooks 'compilation-mode-hook))
(defmacro define-compilation-mode (mode name doc &rest body)
@@ -1140,7 +1139,6 @@
(make-local-variable 'compilation-current-error)
(make-local-variable 'compilation-error-screen-columns)
(make-local-variable 'overlay-arrow-position)
- (setq compilation-last-buffer (current-buffer))
(set (make-local-variable 'font-lock-extra-managed-props)
'(directory message help-echo mouse-face debug))
(set (make-local-variable 'compilation-locs)
@@ -1257,8 +1255,16 @@
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
- (local-variable-p 'compilation-locs buffer))
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+(defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
@@ -1289,7 +1295,6 @@
(or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer"))
(or pt (setq pt (point)))
- (setq compilation-last-buffer (current-buffer))
(let* ((msg (get-text-property pt 'message))
(loc (car msg))
last)
@@ -1327,25 +1332,6 @@
(interactive "p")
(compilation-next-error (- n)))
-(defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-Finds and highlights the source line like \\[next-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
-(defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-Finds and highlights the source line like \\[previous-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
@@ -1383,55 +1369,17 @@
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
-;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
-(defun next-error (&optional n)
- "Visit next compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-
-\\[next-error] normally uses the most recently started compilation or
-grep buffer. However, it can operate on any buffer with output from
-the \\[compile] and \\[grep] commands, or, more generally, on any
-buffer in Compilation mode or with Compilation Minor mode enabled. To
-specify use of a particular buffer for error messages, type
-\\[next-error] in that buffer.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variable `compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (n &optional reset)
(interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (set-buffer (compilation-find-buffer))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
@@ -1477,27 +1425,6 @@
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
-(defun first-error (n)
- "Restart at the first error.
-Visit corresponding source code.
-With prefix arg N, visit the source code of the Nth error.
-This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
+++ /home/tzz/emacs/mine/replace.el Thu Apr 15 11:38:08 2004
@@ -538,6 +538,7 @@
(set (make-local-variable 'revert-buffer-function) 'occur-revert-function)
(make-local-variable 'occur-revert-arguments)
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+ (setq next-error-function 'occur-next-error)
(run-hooks 'occur-mode-hook))
(defun occur-revert-function (ignore1 ignore2)
@@ -614,6 +615,21 @@
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+(defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +816,9 @@
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
- (display-buffer occur-buf)
+ (progn
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
+++ /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
@@ -66,6 +66,137 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+The RESET argument specifies that we should restart from the beginning
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also operate on any
+buffer with output from the \\[compile], \\[grep] commands, or,
+more generally, on any buffer in Compilation mode or with
+Compilation Minor mode enabled, or any buffer in which
+`next-error-function' is bound to an appropriate
+function. To specify use of a particular buffer for error
+messages, type \\[next-error] in that buffer.
+
+Once \\[next-error] has chosen the buffer for error messages,
+it stays with that buffer until you use it in some other buffer which
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+(defun first-error (n)
+ "Restart at the first error.
+Visit corresponding source code.
+With prefix arg N, visit the source code of the Nth error.
+This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+(defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move forwards (or
+backwards, if negative).
+Finds and highlights the source line like \\[next-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+(defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+Finds and highlights the source line like \\[previous-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
--- /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
+++ /home/tzz/emacs/mine/NEWS Thu Apr 15 14:25:18 2004
@@ -88,6 +88,9 @@
\f
* Changes in Emacs 21.4
+** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
** New command line option -Q.
This is like using -q --no-site-file, but in addition it also disables
--- /local/share/src/emacs-cvs/lisp/ChangeLog Thu Apr 15 03:23:30 2004
+++ /home/tzz/emacs/mine/ChangeLog Thu Apr 15 11:50:15 2004
@@ -1,3 +1,32 @@
+2004-04-15 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * simple.el (next-error-last-buffer, next-error-function): new
+ variables for the next-error framework
+ (next-error-buffer-p): is a buffer capable of next-error?
+ (next-error-find-buffer): the functionality of
+ compilation-find-buffer, generalized
+ (next-error, previous-error, first-error, next-error-no-select)
+ (previous-error-no-select): next-error framework
+
+ * replace.el (occur-next-error, occur-1): support the next-error
+ framework
+
+ * compile.el (compilation-start): set next-error-last-buffer so
+ next-error knows where to jump
+ (compilation-setup): set the buffer-local variable
+ next-error-function to 'compilation-next-error-function
+ (compilation-buffer-p, compilation-buffer-internal-p): use an
+ alternate way to find if a buffer is a compilation buffer, for
+ next-error convenience
+ (next-error-no-select, previous-error-no-select, next-error)
+ (previous-error, first-error): moved to simple.el
+ (compilation-find-buffer): functionality moved to
+ next-error-find-buffer in simple.el
+ (compilation-last-buffer): removed
+ (compilation-start, compilation-next-error, compilation-setup)
+ (compilation-next-error-function, compilation-find-buffer):
+ remove compilation-last-buffer use
+
2004-04-14 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/bytecomp.el (batch-byte-compile-file):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: context patch for RMS --]
[-- Type: text/x-patch, Size: 18466 bytes --]
*** /local/share/src/emacs-cvs/lisp/progmodes/compile.el Thu Apr 15 03:23:34 2004
--- /home/tzz/emacs/mine/compile.el Thu Apr 15 11:54:19 2004
***************
*** 125,135 ****
Each function is called with two arguments: the compilation buffer,
and a string describing how the process finished.")
- (defvar compilation-last-buffer nil
- "The most recent compilation buffer.
- A buffer becomes most recent when its compilation is started
- or when it is used with \\[next-error] or \\[compile-goto-error].")
-
(defvar compilation-in-progress nil
"List of compilation processes now running.")
(or (assq 'compilation-in-progress minor-mode-alist)
--- 125,130 ----
***************
*** 950,956 ****
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
! (setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
--- 945,951 ----
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
! (setq next-error-last-buffer outbuf)))
(defun compilation-set-window-height (window)
"Set the height of WINDOW according to `compilation-window-height'."
***************
*** 1081,1086 ****
--- 1076,1085 ----
(set (make-local-variable 'page-delimiter)
compilation-page-delimiter)
(compilation-setup)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(run-mode-hooks 'compilation-mode-hook))
(defmacro define-compilation-mode (mode name doc &rest body)
***************
*** 1140,1146 ****
(make-local-variable 'compilation-current-error)
(make-local-variable 'compilation-error-screen-columns)
(make-local-variable 'overlay-arrow-position)
- (setq compilation-last-buffer (current-buffer))
(set (make-local-variable 'font-lock-extra-managed-props)
'(directory message help-echo mouse-face debug))
(set (make-local-variable 'compilation-locs)
--- 1139,1144 ----
***************
*** 1257,1264 ****
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
(defsubst compilation-buffer-p (buffer)
! (local-variable-p 'compilation-locs buffer))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
--- 1255,1270 ----
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+ ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
! "Test if BUFFER is a compilation buffer."
! (with-current-buffer buffer
! (compilation-buffer-internal-p)))
!
! ;;; test if a buffer is a compilation buffer, assuming we're in the buffer
! (defsubst compilation-buffer-internal-p ()
! "Test if inside a compilation buffer."
! (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
***************
*** 1289,1295 ****
(or (compilation-buffer-p (current-buffer))
(error "Not in a compilation buffer"))
(or pt (setq pt (point)))
- (setq compilation-last-buffer (current-buffer))
(let* ((msg (get-text-property pt 'message))
(loc (car msg))
last)
--- 1295,1300 ----
***************
*** 1327,1351 ****
(interactive "p")
(compilation-next-error (- n)))
- (defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move forwards (or
- backwards, if negative).
- Finds and highlights the source line like \\[next-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
- (defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
- Finds and highlights the source line like \\[previous-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
--- 1332,1337 ----
***************
*** 1383,1437 ****
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
- ;; If compilation-last-buffer is set to a live buffer, use that.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional n)
! "Visit next compilation error message and corresponding source code.
! Prefix arg N says how many error messages to move forwards (or
! backwards, if negative).
!
! \\[next-error] normally uses the most recently started compilation or
! grep buffer. However, it can operate on any buffer with output from
! the \\[compile] and \\[grep] commands, or, more generally, on any
! buffer in Compilation mode or with Compilation Minor mode enabled. To
! specify use of a particular buffer for error messages, type
! \\[next-error] in that buffer.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variable `compilation-error-regexp-alist' for customization ideas."
(interactive "p")
! (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
--- 1369,1385 ----
;; Return a compilation buffer.
;; If the current buffer is a compilation buffer, return it.
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
! (defun compilation-next-error-function (n &optional reset)
(interactive "p")
! (set-buffer (compilation-find-buffer))
! (when reset
! (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
***************
*** 1477,1503 ****
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
- (defun first-error (n)
- "Restart at the first error.
- Visit corresponding source code.
- With prefix arg N, visit the source code of the Nth error.
- This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- 1425,1430 ----
*** /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
--- /home/tzz/emacs/mine/replace.el Thu Apr 15 11:38:08 2004
***************
*** 538,543 ****
--- 538,544 ----
(set (make-local-variable 'revert-buffer-function) 'occur-revert-function)
(make-local-variable 'occur-revert-arguments)
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+ (setq next-error-function 'occur-next-error)
(run-hooks 'occur-mode-hook))
(defun occur-revert-function (ignore1 ignore2)
***************
*** 614,619 ****
--- 615,635 ----
"Move to the Nth (default 1) previous match in an Occur mode buffer."
(interactive "p")
(occur-find-match n #'previous-single-property-change "No earlier matches"))
+
+ (defun occur-next-error (&optional argp reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (occur-find-match
+ (prefix-numeric-value argp)
+ (if (> 0 (prefix-numeric-value argp))
+ #'previous-single-property-change
+ #'next-single-property-change)
+ "No more matches")
+ (occur-mode-goto-occurrence))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 816,824 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
*** /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
--- /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
***************
*** 66,71 ****
--- 66,202 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-variable-buffer-local 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ The RESET argument specifies that we should restart from the beginning
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also operate on any
+ buffer with output from the \\[compile], \\[grep] commands, or,
+ more generally, on any buffer in Compilation mode or with
+ Compilation Minor mode enabled, or any buffer in which
+ `next-error-function' is bound to an appropriate
+ function. To specify use of a particular buffer for error
+ messages, type \\[next-error] in that buffer.
+
+ Once \\[next-error] has chosen the buffer for error messages,
+ it stays with that buffer until you use it in some other buffer which
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+ (defun first-error (n)
+ "Restart at the first error.
+ Visit corresponding source code.
+ With prefix arg N, visit the source code of the Nth error.
+ This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+ (defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move forwards (or
+ backwards, if negative).
+ Finds and highlights the source line like \\[next-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+ (defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+ Finds and highlights the source line like \\[previous-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
*** /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
--- /home/tzz/emacs/mine/NEWS Thu Apr 15 14:25:18 2004
***************
*** 88,93 ****
--- 88,96 ----
\f
* Changes in Emacs 21.4
+ ** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
** New command line option -Q.
This is like using -q --no-site-file, but in addition it also disables
*** /local/share/src/emacs-cvs/lisp/ChangeLog Thu Apr 15 03:23:30 2004
--- /home/tzz/emacs/mine/ChangeLog Thu Apr 15 11:50:15 2004
***************
*** 1,3 ****
--- 1,32 ----
+ 2004-04-15 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * simple.el (next-error-last-buffer, next-error-function): new
+ variables for the next-error framework
+ (next-error-buffer-p): is a buffer capable of next-error?
+ (next-error-find-buffer): the functionality of
+ compilation-find-buffer, generalized
+ (next-error, previous-error, first-error, next-error-no-select)
+ (previous-error-no-select): next-error framework
+
+ * replace.el (occur-next-error, occur-1): support the next-error
+ framework
+
+ * compile.el (compilation-start): set next-error-last-buffer so
+ next-error knows where to jump
+ (compilation-setup): set the buffer-local variable
+ next-error-function to 'compilation-next-error-function
+ (compilation-buffer-p, compilation-buffer-internal-p): use an
+ alternate way to find if a buffer is a compilation buffer, for
+ next-error convenience
+ (next-error-no-select, previous-error-no-select, next-error)
+ (previous-error, first-error): moved to simple.el
+ (compilation-find-buffer): functionality moved to
+ next-error-find-buffer in simple.el
+ (compilation-last-buffer): removed
+ (compilation-start, compilation-next-error, compilation-setup)
+ (compilation-next-error-function, compilation-find-buffer):
+ remove compilation-last-buffer use
+
2004-04-14 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/bytecomp.el (batch-byte-compile-file):
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 101+ messages in thread