all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Add M-x occur to the menu-bar
@ 2003-09-11 16:11 Marshall, Simon
  0 siblings, 0 replies; 101+ messages in thread
From: Marshall, Simon @ 2003-09-11 16:11 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

It seems useful to add an entry for M-x occur to the Tools menu-bar,
alongside the entry for M-x grep.  

While I was at it, it seemed a good idea to change the use of the word
"search" for the entry for M-x grep, since that word is used for entries
(under the Edit menu-bar) that move point.  M-x occur and M-x grep are
different; they list matching lines rather than moving point.

So here's a patch.

 <<menu-bar.diff2>>  <<menu-bar.cl2>> 

[-- Attachment #2: menu-bar.diff2 --]
[-- Type: application/octet-stream, Size: 937 bytes --]

*** menu-bar.el.~3~	Mon Feb 17 10:30:04 2003
--- menu-bar.el	Thu Sep 11 17:04:05 2003
***************
*** 802,810 ****
    '(menu-item "Compile..." compile
  	      :help "Invoke compiler or Make, view compilation errors"))
  (define-key menu-bar-tools-menu [grep]
!   '(menu-item "Search Files (Grep)..." grep
! 	      :help "Search files for strings or regexps (with Grep)"))
! 
  \f
  ;; The "Help" menu items
  
--- 802,812 ----
    '(menu-item "Compile..." compile
  	      :help "Invoke compiler or Make, view compilation errors"))
  (define-key menu-bar-tools-menu [grep]
!   '(menu-item "List Matches in Files (Grep)..." grep
! 	      :help "List lines in files matching string or regular expression"))
! (define-key menu-bar-tools-menu [occur]
!   '(menu-item "List Matches in Buffer (Occur)..." occur
! 	      :help "List lines in buffer matching regular expression"))
  \f
  ;; The "Help" menu items
  

[-- Attachment #3: menu-bar.cl2 --]
[-- Type: application/octet-stream, Size: 172 bytes --]

2003-09-11  Simon Marshall  <simon@gnu.org>

	* menu-bar.el (menu-bar-tools-menu) <occur>: New entry.
	(menu-bar-tools-menu) <grep>: Change "search" to "list lines".


[-- 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
@ 2003-09-12 16:07 Marshall, Simon
  2003-09-13  9:36 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 101+ messages in thread
From: Marshall, Simon @ 2003-09-12 16:07 UTC (permalink / raw)
  Cc: 'Emacs Developers'

I must admit I don't have a strong preference; given the level of
ignorance here with many emacs users over (a) M-x grep and, in
particular, (b) M-x occur and (c) C-x ` etc., I had also thought of the
following.  Perhaps it's also worth throwing this suggestion in.  

I think M-x grep and M-x occur should have as similar a UI as possible.
I've always found it baffling that if you are in a *grep* buffer you get
a Compile menu with entries like "Next Error" to go to the next match.
I've always found it annoying that C-x ` works for *grep* but not for
*Occur*.  (I guess M-x grep is closer to M-x compile for historical
implementation reasons.)

Make the existing Grep entry into a submenu of Tools, like this:

Tools
	List Matching Lines
		In Buffer			# In Buffers... WBN one
day
		In Files...
		---
		Goto First Match
		Goto Previous Match
		Goto Next Match
		---
		Stop Searching

Where the Goto entries process either the current buffer (if a *grep* or
*Occur* buffer) or, otherwise, the most recently created/used *grep* or
*Occur*.  The Stop entry can be active only if a grep has been invoked.

WDYT?

-----Original Message-----
From: Richard Stallman [mailto:rms@gnu.org]
Sent: 12 September 2003 15:04
To: Marshall, Simon
Subject: Re: Add M-x occur to the menu-bar


I tend not to think that M-x occur is worth a space there, so I don't
want to add this.  However, if people generally think it should be
there,
I will go along.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-12 16:07 Marshall, Simon
@ 2003-09-13  9:36 ` Eli Zaretskii
  2003-09-13 13:57 ` Richard Stallman
  2003-09-18 17:10 ` Kevin Rodgers
  2 siblings, 0 replies; 101+ messages in thread
From: Eli Zaretskii @ 2003-09-13  9:36 UTC (permalink / raw)
  Cc: emacs-devel

> From: "Marshall, Simon" <simon.marshall@misys.com>
> Date: Fri, 12 Sep 2003 17:07:24 +0100
> 
> Tools
> 	List Matching Lines

I think this should be "Show Matching Lines" or maybe "Display
Matching Lines".

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-12 16:07 Marshall, Simon
  2003-09-13  9:36 ` Eli Zaretskii
@ 2003-09-13 13:57 ` Richard Stallman
  2003-09-18 17:21   ` Kevin Rodgers
  2003-09-18 17:10 ` Kevin Rodgers
  2 siblings, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2003-09-13 13:57 UTC (permalink / raw)
  Cc: emacs-devel

    I think M-x grep and M-x occur should have as similar a UI as possible.

All else being equal, I agree.  People have tried making interfaces
for grep that separate the arguments.  I think one such is actually
installed as an alternative.  But they are simply less convenient
than M-x grep.

    I've always found it baffling that if you are in a *grep* buffer you get
    a Compile menu with entries like "Next Error" to go to the next match.
    I've always found it annoying that C-x ` works for *grep* but not for
    *Occur*.

It might make sense for C-x ` to work with Occur.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: Add M-x occur to the menu-bar
@ 2003-09-16  8:16 Marshall, Simon
  0 siblings, 0 replies; 101+ messages in thread
From: Marshall, Simon @ 2003-09-16  8:16 UTC (permalink / raw)
  Cc: emacs-devel

I used the "List ..." idiom to match the "Edit/Text Properties/List
Properties" menu entry.  I don't have a preference one way or another,
"Show ..." perhaps, but I don't see a reason for them to be different.

-----Original Message-----
From: Eli Zaretskii [mailto:eliz@elta.co.il]
Sent: 13 September 2003 10:36
To: Simon Marshall
Cc: emacs-devel@gnu.org
Subject: Re: Add M-x occur to the menu-bar


> From: "Marshall, Simon" <simon.marshall@misys.com>
> Date: Fri, 12 Sep 2003 17:07:24 +0100
> 
> Tools
> 	List Matching Lines

I think this should be "Show Matching Lines" or maybe "Display
Matching Lines".

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: Add M-x occur to the menu-bar
@ 2003-09-16  8:30 Marshall, Simon
  2003-09-17 18:02 ` Richard Stallman
  0 siblings, 1 reply; 101+ messages in thread
From: Marshall, Simon @ 2003-09-16  8:30 UTC (permalink / raw)
  Cc: emacs-devel

Should something be added to TODO or would anyone like to volunteer to
try it?  I can volunteer, but I've no idea when I'd get a chance to do
anything.

(What is the alternative interface for grep?  I couldn't find anything
by poking around in the manual.)

Thanks, Simon.

-----Original Message-----
From: Richard Stallman [mailto:rms@gnu.org]
Sent: 13 September 2003 14:57
To: Marshall, Simon
Cc: emacs-devel@gnu.org
Subject: Re: Add M-x occur to the menu-bar


    I think M-x grep and M-x occur should have as similar a UI as
possible.

All else being equal, I agree.  People have tried making interfaces
for grep that separate the arguments.  I think one such is actually
installed as an alternative.  But they are simply less convenient
than M-x grep.

    I've always found it baffling that if you are in a *grep* buffer you
get
    a Compile menu with entries like "Next Error" to go to the next
match.
    I've always found it annoying that C-x ` works for *grep* but not
for
    *Occur*.

It might make sense for C-x ` to work with Occur.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-16  8:30 Marshall, Simon
@ 2003-09-17 18:02 ` Richard Stallman
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2003-09-17 18:02 UTC (permalink / raw)
  Cc: emacs-devel

I wrote:

    All else being equal, I agree.  People have tried making interfaces
    for grep that separate the arguments.  I think one such is actually
    installed as an alternative.  But they are simply less convenient
    than M-x grep.

You replied:

    Should something be added to TODO or would anyone like to volunteer to
    try it?

I am confused.  Try what?
Did you mean this idea?

    It might make sense for C-x ` to work with Occur.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-12 16:07 Marshall, Simon
  2003-09-13  9:36 ` Eli Zaretskii
  2003-09-13 13:57 ` Richard Stallman
@ 2003-09-18 17:10 ` Kevin Rodgers
  2003-09-18 17:27   ` Masatake YAMATO
  2004-01-27 15:34   ` Ted Zlatanov
  2 siblings, 2 replies; 101+ messages in thread
From: Kevin Rodgers @ 2003-09-18 17:10 UTC (permalink / raw)


Marshall, Simon wrote:

> I think M-x grep and M-x occur should have as similar a UI as possible.


I'm not sure I agree: grep is for searching many files (external to
Emacs) and occur is for searching a single buffer (internal to Emacs).

> I've always found it baffling that if you are in a *grep* buffer you get
> a Compile menu with entries like "Next Error" to go to the next match.
> I've always found it annoying that C-x ` works for *grep* but not for
> *Occur*.  (I guess M-x grep is closer to M-x compile for historical
> implementation reasons.)


Not that C-x ` works in all buffers, not just the *grep* buffer.  Making
*Occur* buffers just like *grep* and *compilation* buffers would be a
lot of work, but if you just want C-x ` to "do the right thing" in
*Occur* buffers, try this patch:

*** emacs-21.3/lisp/replace.el.orig	Fri Oct 18 19:21:09 2002
--- emacs-21.3/lisp/replace.el	Thu Sep 18 10:51:12 2003
***************
*** 421,426 ****
--- 421,427 ----
       (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence)
       (define-key map "\C-m" 'occur-mode-goto-occurrence)
       (define-key map "\M-n" 'occur-next)
+     (define-key map "\C-x`" 'occur-next) ; override global binding
       (define-key map "\M-p" 'occur-prev)
       (define-key map "g" 'revert-buffer)
       map)

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-13 13:57 ` Richard Stallman
@ 2003-09-18 17:21   ` Kevin Rodgers
  2003-09-18 18:40     ` Miles Bader
  2003-09-19 12:22     ` Richard Stallman
  0 siblings, 2 replies; 101+ messages in thread
From: Kevin Rodgers @ 2003-09-18 17:21 UTC (permalink / raw)


Richard Stallman wrote:
[quoting Simon Marshall;]

>     I think M-x grep and M-x occur should have as similar a UI as possible.
> 
> All else being equal, I agree.  People have tried making interfaces
> for grep that separate the arguments.  I think one such is actually
> installed as an alternative.  But they are simply less convenient
> than M-x grep.

As the author of igrep.el, I respectfully disagree.  By separating the
arguments, you can provide access to independent completion (primarily
for file names) and history (primarily for search strings/expressions).


-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-18 17:10 ` Kevin Rodgers
@ 2003-09-18 17:27   ` Masatake YAMATO
  2004-01-27 15:34   ` Ted Zlatanov
  1 sibling, 0 replies; 101+ messages in thread
From: Masatake YAMATO @ 2003-09-18 17:27 UTC (permalink / raw)
  Cc: emacs-devel

> Marshall, Simon wrote:
> 
> > I think M-x grep and M-x occur should have as similar a UI as possible.
I approve this idea. 

> I'm not sure I agree: grep is for searching many files (external to
> Emacs) and occur is for searching a single buffer (internal to Emacs).

M-x multi-occur runs `occur' on the multiple buffers. So C-x ` might be useful.

I think `tags-apropos' should have similar UI...

Masatake YAMATO

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-18 17:21   ` Kevin Rodgers
@ 2003-09-18 18:40     ` Miles Bader
  2003-09-21 12:11       ` Eli Zaretskii
  2003-09-21 13:55       ` Ehud Karni
  2003-09-19 12:22     ` Richard Stallman
  1 sibling, 2 replies; 101+ messages in thread
From: Miles Bader @ 2003-09-18 18:40 UTC (permalink / raw)
  Cc: emacs-devel

On Thu, Sep 18, 2003 at 11:21:11AM -0600, Kevin Rodgers wrote:
> As the author of igrep.el, I respectfully disagree.  By separating the
> arguments, you can provide access to independent completion (primarily
> for file names) and history (primarily for search strings/expressions).

Actually I have things setup so that I can do filename completion in the
normal grep input minibuffer (where of course the history stores both
expression and filename); I find this setup almost perfect...

   (define-key minibuffer-local-map "\t" 'comint-dynamic-complete)

[it's also handy for `shell-command' &c -- of course commands that read
strings that _don't_ involve filenames _also_ get filename completion, but I
haven't noticed any real problem with this; maybe it would be nice to have
minibuffer input for `commands' use a specific keymap though.]

I find multiple-prompt interfaces quite annoying by contrast.

-Miles
-- 
I'd rather be consing.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* RE: Add M-x occur to the menu-bar
@ 2003-09-19  9:10 Marshall, Simon
  2003-09-20  7:49 ` Richard Stallman
  0 siblings, 1 reply; 101+ messages in thread
From: Marshall, Simon @ 2003-09-19  9:10 UTC (permalink / raw)
  Cc: emacs-devel

I meant, to list the ideas explicitly:

- Make list-matching-lines and grep have the same UI (or wrapping grep
in a list-matching-lines-in-files) and their buffers have the same
major-mode.

- Add something like list-matching-lines-in-buffers, taking a regexp to
match buffer names.

- Replace Tools/Search Files menu entry with Tools/List Matching Lines
menu containing menu entries:
	In Buffer		# list-matching-lines
	In Buffers...	# list-matching-lines-in-buffers
	In Files...		# grep or list-matching-lines-in-files
	---
	Goto First Match
	Goto Previous Match
	Goto Next Match
	Goto Last Match
	---
	Stop Searching

- Add menu to the major-mode (occur or whatever it would be called)
containing menu entries:
	Goto First Match
	Goto Previous Match
	Goto Next Match
	Goto Last Match
	---
	Stop Searching

(OK, I never mentioned the last item before.)

I also asked what the alternative UI for grep was, the one you think may
already exist, because I couldn't find it.  If that bit has already been
done, or partly done, then all the better.  Do you know what the
alternative is?  (Maybe it was added for 21.4, in which case it's no
surprise I couldn't find it.)

Simon.

-----Original Message-----
From: Richard Stallman [mailto:rms@gnu.org]
Sent: 17 September 2003 19:03
To: Marshall, Simon
Cc: emacs-devel@gnu.org
Subject: Re: Add M-x occur to the menu-bar


I wrote:

    All else being equal, I agree.  People have tried making interfaces
    for grep that separate the arguments.  I think one such is actually
    installed as an alternative.  But they are simply less convenient
    than M-x grep.

You replied:

    Should something be added to TODO or would anyone like to volunteer
to
    try it?

I am confused.  Try what?
Did you mean this idea?

    It might make sense for C-x ` to work with Occur.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-18 17:21   ` Kevin Rodgers
  2003-09-18 18:40     ` Miles Bader
@ 2003-09-19 12:22     ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2003-09-19 12:22 UTC (permalink / raw)
  Cc: emacs-devel

    As the author of igrep.el, I respectfully disagree.  By separating the
    arguments, you can provide access to independent completion (primarily
    for file names) and history (primarily for search strings/expressions).

I find it less convenient.  I never use completion in file name
arguments to grep, because they are normally brief and have wildcards.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-19  9:10 Add M-x occur to the menu-bar Marshall, Simon
@ 2003-09-20  7:49 ` Richard Stallman
  2003-09-23  1:06   ` Miles Bader
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2003-09-20  7:49 UTC (permalink / raw)
  Cc: emacs-devel

    - Make list-matching-lines and grep have the same UI (or wrapping grep
    in a list-matching-lines-in-files) and their buffers have the same
    major-mode.

If this means changing M-x list-matching-lines or M-x grep, I would
object to it.

An alternative interface to grep was written, which uses a different
name.  (There was a message about it yesterday.)  It may not be
installed yet, but it's ok to install it.

    - Add something like list-matching-lines-in-buffers, taking a regexp to
    match buffer names.

That seems useful.  But it would be nice to have various ways to
specify which buffers to use.  Can you make this work with Filesets?

    - Replace Tools/Search Files menu entry with Tools/List Matching Lines
    menu containing menu entries:

That seems ok.

    - Add menu to the major-mode (occur or whatever it would be called)
    containing menu entries:

Ok.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-21 12:11       ` Eli Zaretskii
@ 2003-09-21 11:28         ` Miles Bader
  0 siblings, 0 replies; 101+ messages in thread
From: Miles Bader @ 2003-09-21 11:28 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel, Miles Bader

On Sun, Sep 21, 2003 at 02:11:09PM +0200, Eli Zaretskii wrote:
> > Date: Thu, 18 Sep 2003 14:40:17 -0400
> > From: Miles Bader <miles@gnu.org>
> > 
> >    (define-key minibuffer-local-map "\t" 'comint-dynamic-complete)
> > 
> > [it's also handy for `shell-command' &c -- of course commands that read
> > strings that _don't_ involve filenames _also_ get filename completion
> 
> I think you can do that by arranging for M-! to invoke eshell-command
> instead; see the variable eshell-prefer-to-shell.

Yeah, but then it used eshell, I don't want to use eshell, I just want
filename completion...

-Miles
-- 
"1971 pickup truck; will trade for guns"

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-18 18:40     ` Miles Bader
@ 2003-09-21 12:11       ` Eli Zaretskii
  2003-09-21 11:28         ` Miles Bader
  2003-09-21 13:55       ` Ehud Karni
  1 sibling, 1 reply; 101+ messages in thread
From: Eli Zaretskii @ 2003-09-21 12:11 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

> Date: Thu, 18 Sep 2003 14:40:17 -0400
> From: Miles Bader <miles@gnu.org>
> 
>    (define-key minibuffer-local-map "\t" 'comint-dynamic-complete)
> 
> [it's also handy for `shell-command' &c -- of course commands that read
> strings that _don't_ involve filenames _also_ get filename completion

I think you can do that by arranging for M-! to invoke eshell-command
instead; see the variable eshell-prefer-to-shell.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-18 18:40     ` Miles Bader
  2003-09-21 12:11       ` Eli Zaretskii
@ 2003-09-21 13:55       ` Ehud Karni
  1 sibling, 0 replies; 101+ messages in thread
From: Ehud Karni @ 2003-09-21 13:55 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 18 Sep 2003 14:40:17 -0400, Miles Bader <miles@gnu.org> wrote:
>
> Actually I have things setup so that I can do filename completion in the
> normal grep input minibuffer (where of course the history stores both
> expression and filename); I find this setup almost perfect...
>
>    (define-key minibuffer-local-map "\t" 'comint-dynamic-complete)

I have  (define-key global-map [?\A-f] 'PC-complete-as-file-name)
so I can do file completion in any buffer and within quotes too.
Note. For me Alt is Meta but NOT ESC, i.e. [?\M-f] is not "\ef".

Ehud.


- --
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 mailto:ehud@unix.mvs.co.il                  Better  Safe  Than  Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)

iD8DBQE/ba29LFvTvpjqOY0RApx8AJ49y8ImWkd0E/SCyYrcZKyuPZlqrgCfSZCF
3gPlncblj8qHSqFIGyIni8Q=
=6jsk
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-20  7:49 ` Richard Stallman
@ 2003-09-23  1:06   ` Miles Bader
  2003-09-23 18:50     ` Eli Zaretskii
  0 siblings, 1 reply; 101+ messages in thread
From: Miles Bader @ 2003-09-23  1:06 UTC (permalink / raw)


BTW, what do you think about making minibuffer input for `shell command'
commands (`grep', `shell-command', various dired equivalents, etc) use a
special keymap with TAB bound to an appropriate file-name completion
function?

-Miles
-- 
Love is a snowmobile racing across the tundra.  Suddenly it flips over,
pinning you underneath.  At night the ice weasels come.  --Nietzsche

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-23  1:06   ` Miles Bader
@ 2003-09-23 18:50     ` Eli Zaretskii
  2003-09-23 20:10       ` David Kastrup
  2003-09-24  8:40       ` Richard Stallman
  0 siblings, 2 replies; 101+ messages in thread
From: Eli Zaretskii @ 2003-09-23 18:50 UTC (permalink / raw)
  Cc: emacs-devel

> From: Miles Bader <miles@gnu.org>
> Date: 23 Sep 2003 10:06:35 +0900
> 
> BTW, what do you think about making minibuffer input for `shell command'
> commands (`grep', `shell-command', various dired equivalents, etc) use a
> special keymap with TAB bound to an appropriate file-name completion
> function?

I'm a comlpetion junkie, so I'm all in favor.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-23 18:50     ` Eli Zaretskii
@ 2003-09-23 20:10       ` David Kastrup
  2003-09-24  8:40       ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: David Kastrup @ 2003-09-23 20:10 UTC (permalink / raw)
  Cc: emacs-devel, Miles Bader

"Eli Zaretskii" <eliz@elta.co.il> writes:

> > From: Miles Bader <miles@gnu.org>
> > Date: 23 Sep 2003 10:06:35 +0900
> > 
> > BTW, what do you think about making minibuffer input for `shell command'
> > commands (`grep', `shell-command', various dired equivalents, etc) use a
> > special keymap with TAB bound to an appropriate file-name completion
> > function?
> 
> I'm a comlpetion junkie, so I'm all in favor.

Actually, I think it is quite a shortcoming that this has not yet been
done.  I often use shell-mode when I want to fire off just a single
command, and that's inconvenient because of buffer switching etc.

So do, please, do.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-23 18:50     ` Eli Zaretskii
  2003-09-23 20:10       ` David Kastrup
@ 2003-09-24  8:40       ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2003-09-24  8:40 UTC (permalink / raw)
  Cc: emacs-devel, miles

    > BTW, what do you think about making minibuffer input for `shell command'
    > commands (`grep', `shell-command', various dired equivalents, etc) use a
    > special keymap with TAB bound to an appropriate file-name completion
    > function?

That sounds good to me, at least worth trying.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2003-09-18 17:10 ` Kevin Rodgers
  2003-09-18 17:27   ` Masatake YAMATO
@ 2004-01-27 15:34   ` Ted Zlatanov
  2004-01-27 17:24     ` Benjamin Rutt
  2004-01-28  9:04     ` Richard Stallman
  1 sibling, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-01-27 15:34 UTC (permalink / raw)


On Thu, 18 Sep 2003, ihs_4664@yahoo.com wrote:

> Not that C-x ` works in all buffers, not just the *grep* buffer.
> Making *Occur* buffers just like *grep* and *compilation* buffers
> would be a lot of work, but if you just want C-x ` to "do the right
> thing" in *Occur* buffers, try this patch:
> 
> *** emacs-21.3/lisp/replace.el.orig	Fri Oct 18 19:21:09 2002
> --- emacs-21.3/lisp/replace.el	Thu Sep 18 10:51:12 2003
> ***************
> *** 421,426 ****
> --- 421,427 ----
>        (define-key map "\C-c\C-c" 'occur-mode-goto-occurrence)
>        (define-key map "\C-m" 'occur-mode-goto-occurrence)
>        (define-key map "\M-n" 'occur-next)
> +     (define-key map "\C-x`" 'occur-next) ; override global binding
>        (define-key map "\M-p" 'occur-prev)
>        (define-key map "g" 'revert-buffer)
>        map)

Kevin,

I like your patch, but would it be possible to have an intelligent
dwim-next that did the right thing in Emacs?  It would look for
*compilation* then *grep* then *occur*, and depending on which one it
found it could call the appropriate "next" function (maybe the order
would be customizable too).

Ditto for "prev", handled by dwim-prev.

I can write this code, including the customization definition for the
order.  I was just wondering if something similar already existed and
if anyone else would find it useful; also the right namespace of the
function is not clear to me.

Thanks
Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 15:34   ` Ted Zlatanov
@ 2004-01-27 17:24     ` Benjamin Rutt
  2004-01-27 18:46       ` Ted Zlatanov
  2004-01-27 19:04       ` Stefan Monnier
  2004-01-28  9:04     ` Richard Stallman
  1 sibling, 2 replies; 101+ messages in thread
From: Benjamin Rutt @ 2004-01-27 17:24 UTC (permalink / raw)
  Cc: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> I like your patch, but would it be possible to have an intelligent
> dwim-next that did the right thing in Emacs?  It would look for
> *compilation* then *grep* then *occur*, and depending on which one it
> found it could call the appropriate "next" function (maybe the order
> would be customizable too).

I'd prefer the default be to use whichever one (compilation, grep,
occur) was launched most recently.  Sometimes I have really old
compile buffers laying around (I never kill them typically).  And I
wouldn't want the presence of those old compilation buffers to mean
that I couldn't use this cool new 'C-x `' functionality for the M-x
occur I just ran a second ago.  I don't usually kill *grep* buffers
either.

In order to accomplish this, probably M-x compile, M-x occur and M-x
grep would have to set some variable like `next-error-follow-command'
to 'compile, 'occur or 'grep, respectively, inside those function
definitions.
-- 
Benjamin

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 17:24     ` Benjamin Rutt
@ 2004-01-27 18:46       ` Ted Zlatanov
  2004-01-27 19:02         ` Benjamin Rutt
  2004-01-27 19:04       ` Stefan Monnier
  1 sibling, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-01-27 18:46 UTC (permalink / raw)


On Tue, 27 Jan 2004, brutt+news@bloomington.in.us wrote:

> Ted Zlatanov <tzz@lifelogs.com> writes:
> 
>> I like your patch, but would it be possible to have an intelligent
>> dwim-next that did the right thing in Emacs?  It would look for
>> *compilation* then *grep* then *occur*, and depending on which one
>> it found it could call the appropriate "next" function (maybe the
>> order would be customizable too).
> 
> I'd prefer the default be to use whichever one (compilation, grep,
> occur) was launched most recently.  Sometimes I have really old
> compile buffers laying around (I never kill them typically).  And I
> wouldn't want the presence of those old compilation buffers to mean
> that I couldn't use this cool new 'C-x `' functionality for the M-x
> occur I just ran a second ago.  I don't usually kill *grep* buffers
> either.
> 
> In order to accomplish this, probably M-x compile, M-x occur and M-x
> grep would have to set some variable like
> `next-error-follow-command' to 'compile, 'occur or 'grep,
> respectively, inside those function definitions.

I think this can be done with hooks alone.  compilation-mode-hook,
grep-setup-hook, and occur-hook seem like the right places.  Tested
but probably in need of improvement code follows:

(defvar dwim-next-mode nil
  "Next mode to be followed.")

(add-hook 'compilation-mode-hook (lambda () (setq dwim-next-mode 'compile)))
(add-hook 'grep-setup-hook (lambda () (setq dwim-next-mode 'grep)))
(add-hook 'occur-hook (lambda () (setq dwim-next-mode 'occur)))

(defun dwim-next ()
  "Go to the next compile, grep, or occur place.
The next place is determined by which one of compile, grep, and
occur has been run most recently."
  (interactive)
  (cond 
   ((equal dwim-next-mode 'occur)
    ;; act like next-error - is this right?
    (set-buffer "*Occur*")
    (occur-next)
    (occur-mode-goto-occurrence))
   ;; next-error can handle the rest
   (t (next-error))))

I think this would be very nice for Emacs users in general.

Thanks
Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 18:46       ` Ted Zlatanov
@ 2004-01-27 19:02         ` Benjamin Rutt
  0 siblings, 0 replies; 101+ messages in thread
From: Benjamin Rutt @ 2004-01-27 19:02 UTC (permalink / raw)
  Cc: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> (defun dwim-next ()
>   "Go to the next compile, grep, or occur place.
> The next place is determined by which one of compile, grep, and
> occur has been run most recently."
>   (interactive)
>   (cond 
>    ((equal dwim-next-mode 'occur)
>     ;; act like next-error - is this right?
>     (set-buffer "*Occur*")
>     (occur-next)
>     (occur-mode-goto-occurrence))
>    ;; next-error can handle the rest
>    (t (next-error))))

Looks good, now you just need to accept the same prefix arguments that
next-error and occur-next take, and pass them on.

> I think this would be very nice for Emacs users in general.

I agree, using C-x ` for occur feels very natural.
-- 
Benjamin

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 17:24     ` Benjamin Rutt
  2004-01-27 18:46       ` Ted Zlatanov
@ 2004-01-27 19:04       ` Stefan Monnier
  2004-01-27 19:35         ` Ted Zlatanov
  1 sibling, 1 reply; 101+ messages in thread
From: Stefan Monnier @ 2004-01-27 19:04 UTC (permalink / raw)
  Cc: Ted Zlatanov, emacs-devel

> I'd prefer the default be to use whichever one (compilation, grep,
> occur) was launched most recently.  Sometimes I have really old
> compile buffers laying around (I never kill them typically).  And I
> wouldn't want the presence of those old compilation buffers to mean
> that I couldn't use this cool new 'C-x `' functionality for the M-x
> occur I just ran a second ago.  I don't usually kill *grep* buffers
> either.

`compile' and `grep' already do that.

> In order to accomplish this, probably M-x compile, M-x occur and M-x
> grep would have to set some variable like `next-error-follow-command'
> to 'compile, 'occur or 'grep, respectively, inside those function
> definitions.

The variable already exists and is called `compilation-last-buffer'.


        Stefan

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 19:04       ` Stefan Monnier
@ 2004-01-27 19:35         ` Ted Zlatanov
  2004-01-27 23:03           ` Miles Bader
  0 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-01-27 19:35 UTC (permalink / raw)


On 27 Jan 2004, monnier@iro.umontreal.ca wrote:

>> In order to accomplish this, probably M-x compile, M-x occur and
>> M-x grep would have to set some variable like
>> `next-error-follow-command' to 'compile, 'occur or 'grep,
>> respectively, inside those function definitions.
> 
> The variable already exists and is called `compilation-last-buffer'.

If you think the code I posted to interface with occur-mode is useful,
I can change it to set compilation-last-buffer to the *Occur* buffer
when occur-mode is called, and then I can rewrite dwim-next as
needed.  It should know that it's going to an occur-mode buffer
though, so just knowing the buffer may not be enough - once we get to
the buffer, the modes may need to be examined.

I also need to change it to take prefix args, so let me know if I
should bother or if this is better as a patch to next-error and
occur.el (so we don't bother with hooks).

Thanks
Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 19:35         ` Ted Zlatanov
@ 2004-01-27 23:03           ` Miles Bader
  2004-01-28  3:53             ` Ted Zlatanov
  0 siblings, 1 reply; 101+ messages in thread
From: Miles Bader @ 2004-01-27 23:03 UTC (permalink / raw)
  Cc: emacs-devel

On Tue, Jan 27, 2004 at 02:35:26PM -0500, Ted Zlatanov wrote:
> when occur-mode is called, and then I can rewrite dwim-next as
> needed.

I'm confused; since `next-error' already supports the desired functionality,
why is `dwim-next' needed at all???

-Miles
-- 
We are all lying in the gutter, but some of us are looking at the stars.
-Oscar Wilde

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 23:03           ` Miles Bader
@ 2004-01-28  3:53             ` Ted Zlatanov
  2004-01-28 14:30               ` Stefan Monnier
  0 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-01-28  3:53 UTC (permalink / raw)


On Tue, 27 Jan 2004, miles@gnu.org wrote:

On Tue, Jan 27, 2004 at 02:35:26PM -0500, Ted Zlatanov wrote:
>> when occur-mode is called, and then I can rewrite dwim-next as
>> needed.
> 
> I'm confused; since `next-error' already supports the desired
> functionality, why is `dwim-next' needed at all???

Two reasons:

1) next-error does not support the occur mode, which was what started
   the discussion in the firts place.  I tried to fix this with
   minimum changes to the Emacs sources.

2) next-error is IMHO a bad name for a function that finds the next
   match in grep mode, and the next occurrence in occur mode.

The second reason is no big deal, just my opinion.

Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-27 15:34   ` Ted Zlatanov
  2004-01-27 17:24     ` Benjamin Rutt
@ 2004-01-28  9:04     ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-01-28  9:04 UTC (permalink / raw)
  Cc: emacs-devel

    I like your patch, but would it be possible to have an intelligent
    dwim-next that did the right thing in Emacs?  It would look for
    *compilation* then *grep* then *occur*, and depending on which one it
    found it could call the appropriate "next" function (maybe the order
    would be customizable too).

It could be an idea worth exploring.  It will be necessary to put much
thought into little details, or users will find it annoying in new ways.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-28  3:53             ` Ted Zlatanov
@ 2004-01-28 14:30               ` Stefan Monnier
  2004-01-28 15:46                 ` Ted Zlatanov
  2004-01-29 17:51                 ` Richard Stallman
  0 siblings, 2 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-01-28 14:30 UTC (permalink / raw)
  Cc: emacs-devel

> 1) next-error does not support the occur mode, which was what started
>    the discussion in the firts place.  I tried to fix this with
>    minimum changes to the Emacs sources.

Minimizing the amount of changes is a worthy goal but it should not take
precedence over the goals of: - consistent behavior - maintainability What
this means is that it would be better to integrate the support for occur and
the support for grep and compile rather than add a layer on top of the
support for grep and compile.  That doesn't mean it has to be 100%
integration, but `next-error' could pay attention to a variable like
`compile-error-forward-function' or something like that which occur-mode
could set buffer-locally.  The idea is to keep as much of the code together:
at least the code that selects and displays the relevant buffer should
be shared, IMO.

> 2) next-error is IMHO a bad name for a function that finds the next
>    match in grep mode, and the next occurrence in occur mode.

That's probably tru.  If you can come up with a better name, maybe we
can change it.  I don't find dwim-next to be much btter.


        Stefan

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-28 14:30               ` Stefan Monnier
@ 2004-01-28 15:46                 ` Ted Zlatanov
  2004-01-28 22:45                   ` Kevin Rodgers
  2004-01-29 17:51                 ` Richard Stallman
  1 sibling, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-01-28 15:46 UTC (permalink / raw)


On 28 Jan 2004, monnier@iro.umontreal.ca wrote:

>> 1) next-error does not support the occur mode, which was what
>>    started the discussion in the firts place.  I tried to fix this
>>    with minimum changes to the Emacs sources.
> 
> Minimizing the amount of changes is a worthy goal but it should not
> take precedence over the goals of: - consistent behavior -
> maintainability What this means is that it would be better to
> integrate the support for occur and the support for grep and compile
> rather than add a layer on top of the support for grep and compile.
> That doesn't mean it has to be 100% integration, but `next-error'
> could pay attention to a variable like
> `compile-error-forward-function' or something like that which
> occur-mode could set buffer-locally.  The idea is to keep as much of
> the code together: at least the code that selects and displays the
> relevant buffer should be shared, IMO.

I'm OK with all this, and I can make a patch to next-error and to
occur to implement these changes.

>> 2) next-error is IMHO a bad name for a function that finds the next
>>    match in grep mode, and the next occurrence in occur mode.
> 
> That's probably tru.  If you can come up with a better name, maybe
> we can change it.  I don't find dwim-next to be much btter.

I would just defalias, since we're patching next-error anyhow.  Some
names I thought of:

(additive)
next-error-or-occurrence (hard to spell)
next-error-or-occur (but what if other modes are added?)
next-error-or-spot

(different altogether)
next-instance
next-place
next-interesting
next-dwim

Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-28 15:46                 ` Ted Zlatanov
@ 2004-01-28 22:45                   ` Kevin Rodgers
  2004-01-29  5:42                     ` Eli Zaretskii
  0 siblings, 1 reply; 101+ messages in thread
From: Kevin Rodgers @ 2004-01-28 22:45 UTC (permalink / raw)


Ted Zlatanov wrote:

> On 28 Jan 2004, monnier@iro.umontreal.ca wrote:
>>>2) next-error is IMHO a bad name for a function that finds the next
>>>   match in grep mode, and the next occurrence in occur mode.
>>
>>That's probably tru.  If you can come up with a better name, maybe
>>we can change it.  I don't find dwim-next to be much btter.
> 
> I would just defalias, since we're patching next-error anyhow.  Some
> names I thought of:
> 
> (additive)
> next-error-or-occurrence (hard to spell)
> next-error-or-occur (but what if other modes are added?)
> next-error-or-spot
> 
> (different altogether)
> next-instance
> next-place
> next-interesting
> next-dwim

(defalias 'next-match 'next-error)	; for grep
(defalias 'next-occurrence 'occur-next)	; for occur

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-28 22:45                   ` Kevin Rodgers
@ 2004-01-29  5:42                     ` Eli Zaretskii
  2004-01-29 15:19                       ` Stefan Monnier
  0 siblings, 1 reply; 101+ messages in thread
From: Eli Zaretskii @ 2004-01-29  5:42 UTC (permalink / raw)
  Cc: emacs-devel

> From: Kevin Rodgers <ihs_4664@yahoo.com>
> Date: Wed, 28 Jan 2004 15:45:53 -0700
> > 
> > (additive)
> > next-error-or-occurrence (hard to spell)
> > next-error-or-occur (but what if other modes are added?)
> > next-error-or-spot
> > 
> > (different altogether)
> > next-instance
> > next-place
> > next-interesting
> > next-dwim
> 
> (defalias 'next-match 'next-error)	; for grep
> (defalias 'next-occurrence 'occur-next)	; for occur

How about next-message for all of them (with a suitable defalias to
keep back-compatibility)?

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-29  5:42                     ` Eli Zaretskii
@ 2004-01-29 15:19                       ` Stefan Monnier
  2004-01-29 15:28                         ` Miles Bader
  2004-01-29 20:52                         ` Kai Grossjohann
  0 siblings, 2 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-01-29 15:19 UTC (permalink / raw)
  Cc: Kevin Rodgers, emacs-devel

>> (defalias 'next-match 'next-error)	; for grep
>> (defalias 'next-occurrence 'occur-next)	; for occur

This doesn't really help the question of what to use for *the* name,
i.e. the name bound to C-x `.

> How about next-message for all of them (with a suitable defalias to
> keep back-compatibility)?

`message' already has enough other meanings, that I'm rather uncomfortable
using it here.


        Stefan

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-29 15:19                       ` Stefan Monnier
@ 2004-01-29 15:28                         ` Miles Bader
  2004-01-29 15:41                           ` David Kastrup
  2004-01-29 20:52                         ` Kai Grossjohann
  1 sibling, 1 reply; 101+ messages in thread
From: Miles Bader @ 2004-01-29 15:28 UTC (permalink / raw)
  Cc: Eli Zaretskii, Kevin Rodgers, emacs-devel

On Thu, Jan 29, 2004 at 10:19:18AM -0500, Stefan Monnier wrote:
> This doesn't really help the question of what to use for *the* name,
> i.e. the name bound to C-x `.
> 
> > How about next-message for all of them (with a suitable defalias to
> > keep back-compatibility)?
> 
> `message' already has enough other meanings, that I'm rather uncomfortable
> using it here.

One idea is `next-hit'.

`next-match' seems pretty decent for most purposes, though for compilation
it's a bit shaky (and presumably that's the most common use!).

-Miles
-- 
I'd rather be consing.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-29 15:28                         ` Miles Bader
@ 2004-01-29 15:41                           ` David Kastrup
  0 siblings, 0 replies; 101+ messages in thread
From: David Kastrup @ 2004-01-29 15:41 UTC (permalink / raw)
  Cc: Eli Zaretskii, Kevin Rodgers, Stefan Monnier, emacs-devel

Miles Bader <miles@gnu.org> writes:

> On Thu, Jan 29, 2004 at 10:19:18AM -0500, Stefan Monnier wrote:
> > This doesn't really help the question of what to use for *the* name,
> > i.e. the name bound to C-x `.
> > 
> > > How about next-message for all of them (with a suitable defalias to
> > > keep back-compatibility)?
> 
> One idea is `next-hit'.
> 
> `next-match' seems pretty decent for most purposes, though for compilation
> it's a bit shaky (and presumably that's the most common use!).

Emacs hits again!  The hit bounces off your ASCII armor.
Your strike with your two-handed Control-Alt-Meta!
You miss!
The viper bites!
You drop your cursor keys!

Emacs hits again!
You feel enlightened.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-28 14:30               ` Stefan Monnier
  2004-01-28 15:46                 ` Ted Zlatanov
@ 2004-01-29 17:51                 ` Richard Stallman
  2004-01-30 19:00                   ` Ted Zlatanov
  1 sibling, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2004-01-29 17:51 UTC (permalink / raw)
  Cc: tzz, emacs-devel

    Minimizing the amount of changes is a worthy goal but it should not take
    precedence over the goals of: - consistent behavior - maintainability What
    this means is that it would be better to integrate the support for occur and
    the support for grep and compile rather than add a layer on top of the
    support for grep and compile.

You are probably right.  But I think the biggest problem here will be
finding th right rules for this command to follow, which will give
results that the users like and find natural.

    > 2) next-error is IMHO a bad name for a function that finds the next
    >    match in grep mode, and the next occurrence in occur mode.

    That's probably tru.  If you can come up with a better name, maybe we
    can change it.  I don't find dwim-next to be much btter.

dwim-next is not very good, because it is very vague about
what sort of thing it will do.

How about goto-next-locus?

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-29 15:19                       ` Stefan Monnier
  2004-01-29 15:28                         ` Miles Bader
@ 2004-01-29 20:52                         ` Kai Grossjohann
  1 sibling, 0 replies; 101+ messages in thread
From: Kai Grossjohann @ 2004-01-29 20:52 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> (defalias 'next-match 'next-error)	; for grep
>>> (defalias 'next-occurrence 'occur-next)	; for occur
>
> This doesn't really help the question of what to use for *the* name,
> i.e. the name bound to C-x `.

Maybe next-match works well for all of them.  We could (defalias
'match 'occur) ;-)

Kai

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-29 17:51                 ` Richard Stallman
@ 2004-01-30 19:00                   ` Ted Zlatanov
  2004-02-04 20:39                     ` Ted Zlatanov
  0 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-01-30 19:00 UTC (permalink / raw)


On Thu, 29 Jan 2004, rms@gnu.org wrote:

> You are probably right.  But I think the biggest problem here will
> be finding th right rules for this command to follow, which will
> give results that the users like and find natural.

I guess I'll produce something as a starting point and see how people
like it.  I'll patch next-error if needed, and occur definitely will
need to set the right variable.

> How about goto-next-locus?

OK, I'll defalias to goto-next-locus and next-match.

Thanks
Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-01-30 19:00                   ` Ted Zlatanov
@ 2004-02-04 20:39                     ` Ted Zlatanov
  2004-02-04 23:20                       ` Kim F. Storm
  0 siblings, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-04 20:39 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]

On Fri, 30 Jan 2004, tzz@lifelogs.com wrote:

On Thu, 29 Jan 2004, rms@gnu.org wrote:
> 
>> You are probably right.  But I think the biggest problem here will
>> be finding th right rules for this command to follow, which will
>> give results that the users like and find natural.
> 
> I guess I'll produce something as a starting point and see how
> people like it.  I'll patch next-error if needed, and occur
> definitely will need to set the right variable.
> 
>> How about goto-next-locus?
> 
> OK, I'll defalias to goto-next-locus and next-match.

Attached is a patch for replace.el (occur) and compile.el
(next-error).  I also defalias as mentioned above.

It tries to be smart about the current buffer, to simulate what
next-error does already.  It also handles negative and positive
arguments as usual.  It does not handle the universal prefix
argument.

If occur has not been loaded at all (checked by soft-intern of
"occur-last-buffer") next-error behaves exactly as before, looking at
grep and compile output.

I'm sure the code needs corrections, so feel free to critique.  The
diff should have been done at the same, level too...  It should be
enough to get the idea across.

Thanks
Ted


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error+occur.patch --]
[-- Type: text/x-patch, Size: 4529 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	Wed Feb  4 15:35:28 2004
@@ -31,12 +31,15 @@
 
 ;;; Code:
 
+;; autoload occur-next when needed
+(eval-and-compile
+  (autoload 'occur-next "replace"))
+
 (defgroup compilation nil
   "Run compiler as inferior of Emacs, parse error messages."
   :group 'tools
   :group 'processes)
 
-
 ;;;###autoload
 (defcustom compilation-mode-hook nil
   "*List of hook functions run by `compilation-mode' (see `run-hooks')."
@@ -1406,12 +1409,13 @@
 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.
+\\[next-error] normally uses the most recently started occur,
+compilation or grep buffer.  However, it can operate on any
+buffer with output from the \\[compile], \\[grep], and \\[occur]
+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
@@ -1420,14 +1424,38 @@
 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))))
+  (if (and (intern-soft "occur-last-buffer") ; has this been defvar'd?
+	   ;; special case for running next-error in a compile/grep buffer
+	   (not (equal (current-buffer) (compilation-find-buffer)))
+	   ;; occur sets compilation-last-buffer to occur-last-buffer
+	   ;; also, allow for running next-error in an occur buffer
+	   (or
+	    (equal occur-last-buffer (current-buffer))
+	    (equal occur-last-buffer compilation-last-buffer)))
+      ;; do the right thing for occur
+      (progn
+	(set-buffer compilation-last-buffer)
+	(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)
+	(setq compilation-last-buffer occur-last-buffer))
+    ;; otherwise, grep/compile behavior
+    (progn
+      (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)
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
 
 (defun previous-error (argp)
   "Visit previous compilation error message and corresponding source code.

--- /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	Wed Feb  4 14:54:14 2004
@@ -522,6 +522,14 @@
   :type 'hook
   :group 'matching)
 
+;; override compilation-last-buffer
+(defvar occur-last-buffer nil
+  "The most recent occur buffer.
+An occur buffer becomes most recent when its process is started
+or when it is used with \\[occur-next].
+Notice that using \\[next-error] or \\[compile-goto-error] modifies
+`complation-last-buffer' rather than `occur-last-buffer'.")
+
 (put 'occur-mode 'mode-class 'special)
 (defun occur-mode ()
   "Major mode for output from \\[occur].
@@ -800,7 +808,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 occur-last-buffer occur-buf)
+	      (setq compilation-last-buffer occur-buf))
 	  (kill-buffer occur-buf)))
       (run-hooks 'occur-hook))))
 

[-- Attachment #3: 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-04 20:39                     ` Ted Zlatanov
@ 2004-02-04 23:20                       ` Kim F. Storm
  2004-02-05 17:27                         ` Ted Zlatanov
  0 siblings, 1 reply; 101+ messages in thread
From: Kim F. Storm @ 2004-02-04 23:20 UTC (permalink / raw)
  Cc: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> On Fri, 30 Jan 2004, tzz@lifelogs.com wrote:
> 
> I'm sure the code needs corrections, so feel free to critique.  The
> diff should have been done at the same, level too...  It should be
> enough to get the idea across.

Maybe a more generic approach could be used:

Let compile.el define a buffer-local compilation-next-error-function
variable (default value nil) which can be bound in the *occur* buffer
to #'occur-next (or whatever).

Then (the original) next-error function is modified to do this:

  (setq compilation-last-buffer (compilation-find-buffer))
  (if (buffer-local-value 'compilation-next-error-function compilation-last-buffer)
      (funcall compilation-next-error-function argp)
    ... do what next-error used to do ... )

With this approach, compile.el doesn't need to know anything about
occur mode, and future similar modes can hook themselves into
next-error without modifying compile.el any further.

With this change, occur need to set compilation-last-buffer to the
*occur* buffer and bind compilation-next-error-function in that buffer
to #'occur-next. 


BTW, here are some comments on your patch:

> 
> If occur has not been loaded at all (checked by soft-intern of
> "occur-last-buffer") next-error behaves exactly as before, looking at
> grep and compile output.

IMO, it would be cleaner to add (provide 'occur) to replace.el and just
test with (featurep 'occur).

You can then add (defvar occur-last-buffer) to compile.el to avoid
byte-compiler warnings.

The autoload of occur-next should be done as an autoload cookie in occur.el
But I don't see why do you need it at all?

-- 
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-04 23:20                       ` Kim F. Storm
@ 2004-02-05 17:27                         ` Ted Zlatanov
  2004-02-06 23:57                           ` Kim F. Storm
  2004-02-07  9:00                           ` Richard Stallman
  0 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-05 17:27 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1469 bytes --]

On 05 Feb 2004, storm@cua.dk wrote:

> Maybe a more generic approach could be used:
> 
> Let compile.el define a buffer-local compilation-next-error-function
> variable (default value nil) which can be bound in the *occur*
> buffer to #'occur-next (or whatever).
[...]
> With this approach, compile.el doesn't need to know anything about
> occur mode, and future similar modes can hook themselves into
> next-error without modifying compile.el any further.

I see, that is indeed a much better solution.  I've reworked the patch
to do what you suggest; only the universal-prefix is not handled by
occur-next-error.  It is much better from the perspective of
occur-mode, but I had to modify compilation-find-buffer and
compilation-buffer-p to avoid complicating next-error.  Anyhow, see
what you think.

multi-occur should be handled, I don't know if I need to do anything
there.  It works exactly like occur, according to the docs.

> IMO, it would be cleaner to add (provide 'occur) to replace.el and
> just test with (featurep 'occur).

OK, with the change you suggested above I don't need to do this
anymore, but I'll keep it in mind.  By the way, why doesn't
replace.el (provide 'occur)?  No one needed it?

> The autoload of occur-next should be done as an autoload cookie in
> occur.el But I don't see why do you need it at all?

I was calling occur-next explicitly, so I wanted to make sure there
were no compiler warnings.  I see it's unnecessary.

Thanks
Ted


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error+occur.patch --]
[-- Type: text/x-patch, Size: 7795 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	Thu Feb  5 12:25:00 2004
@@ -36,7 +36,6 @@
   :group 'tools
   :group 'processes)
 
-
 ;;;###autoload
 (defcustom compilation-mode-hook nil
   "*List of hook functions run by `compilation-mode' (see `run-hooks')."
@@ -133,6 +132,15 @@
 A buffer becomes most recent when its compilation is started
 or when it is used with \\[next-error] or \\[compile-goto-error].")
 
+(defvar compilation-next-error-function nil
+  "The next-error analogue for other modes.
+This variable can be bound to a function by a mode.  It is
+buffer-local by default.  Together with
+`compilation-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'compilation-next-error-function)
+
 (defvar compilation-in-progress nil
   "List of compilation processes now running.")
 (or (assq 'compilation-in-progress minor-mode-alist)
@@ -1056,11 +1064,20 @@
       (setq errors (cdr errors)))
     errors))
 
-(defsubst compilation-buffer-p (buffer)
+(defsubst compilation-buffer-p (buffer &optional allow-with-next-error-function)
+  "Test if BUFFER is a compilation buffer.
+With ALLOW-WITH-NEXT-ERROR-FUNCTION, allow buffer if it has
+`compilation-next-error-function' bound.  This is for use by
+\\[next-error] only."
   (save-excursion
     (set-buffer buffer)
-    (or compilation-shell-minor-mode compilation-minor-mode
-	(eq major-mode 'compilation-mode))))
+    (or compilation-shell-minor-mode 
+	compilation-minor-mode
+	(eq major-mode 'compilation-mode)
+	(and allow-with-next-error-function
+	     (buffer-local-value
+	      'compilation-next-error-function
+	      buffer)))))
 
 (defun compilation-next-error (n)
   "Move point to the next error in the compilation buffer.
@@ -1368,25 +1385,31 @@
 ;; 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)
+(defun compilation-find-buffer (&optional other-buffer allow-with-next-error)
   (if (and (not other-buffer)
-	   (compilation-buffer-p (current-buffer)))
+	   (compilation-buffer-p (current-buffer) allow-with-next-error))
       ;; 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)
+	     (compilation-buffer-p
+	      compilation-last-buffer
+	      allow-with-next-error)
 	     (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)))
+	(while (and buffers (or (not (compilation-buffer-p 
+				      (car buffers) 
+				      allow-with-next-error))
 				(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))
+		   (compilation-buffer-p 
+		    (current-buffer) 
+		    allow-with-next-error)
 		   ;; The current buffer is a compilation buffer.
 		   (progn
 		     (if other-buffer
@@ -1406,12 +1429,14 @@
 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.
+\\[next-error] normally uses the most recently started
+compilation or grep buffer.  However, it can 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
+`compilation-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
@@ -1420,14 +1445,29 @@
 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))))
+  (setq compilation-last-buffer 
+	(or
+	 ;; if compilation-last-buffer was set by an external mode, get that
+	 (compilation-find-buffer compilation-last-buffer t)
+	 ;; otherwise find a real compilation buffer
+	 (compilation-find-buffer)))
+  (if (buffer-local-value 
+       'compilation-next-error-function 
+       compilation-last-buffer)
+      ;; do the right thing for modes that bind compilation-next-error-function
+      (progn
+	(set-buffer compilation-last-buffer)
+	(funcall compilation-next-error-function argp))
+    (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)
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
 
 (defun previous-error (argp)
   "Visit previous compilation error message and corresponding source code.

--- /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	Thu Feb  5 12:05:06 2004
@@ -522,6 +522,14 @@
   :type 'hook
   :group 'matching)
 
+;; override compilation-last-buffer
+(defvar occur-last-buffer nil
+  "The most recent occur buffer.
+An occur buffer becomes most recent when its process is started
+or when it is used with \\[occur-next].
+Notice that using \\[next-error] or \\[compile-goto-error] modifies
+`complation-last-buffer' rather than `occur-last-buffer'.")
+
 (put 'occur-mode 'mode-class 'special)
 (defun occur-mode ()
   "Major mode for output from \\[occur].
@@ -614,6 +622,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 +821,11 @@
 	(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 occur-last-buffer occur-buf)
+	      (setq compilation-last-buffer occur-buf)
+	      (setq compilation-next-error-function 'occur-next-error))
 	  (kill-buffer occur-buf)))
       (run-hooks 'occur-hook))))
 

[-- Attachment #3: 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-06 23:57                           ` Kim F. Storm
@ 2004-02-06 23:10                             ` Stefan Monnier
  2004-02-07  0:52                               ` David Kastrup
  2004-02-09 18:44                               ` Ted Zlatanov
  2004-02-09 18:43                             ` Ted Zlatanov
  1 sibling, 2 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-02-06 23:10 UTC (permalink / raw)
  Cc: Ted Zlatanov, emacs-devel

>   (save-excursion
>     (set-buffer buffer)

Also known as (with-current buffer buffer


        Stefan

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-05 17:27                         ` Ted Zlatanov
@ 2004-02-06 23:57                           ` Kim F. Storm
  2004-02-06 23:10                             ` Stefan Monnier
  2004-02-09 18:43                             ` Ted Zlatanov
  2004-02-07  9:00                           ` Richard Stallman
  1 sibling, 2 replies; 101+ messages in thread
From: Kim F. Storm @ 2004-02-06 23:57 UTC (permalink / raw)
  Cc: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> I see, that is indeed a much better solution.  I've reworked the patch
> to do what you suggest; 

Yes, it is much cleaner now, and you are almost there.

>                         only the universal-prefix is not handled by
> occur-next-error.  It is much better from the perspective of
> occur-mode, but I had to modify compilation-find-buffer and
> compilation-buffer-p to avoid complicating next-error.  Anyhow, see
> what you think.

I haven't thought a lot about it, but I don't understand why you need
that extra allow-with-next-error-function arg to compilation-buffer-p
and compilation-find-buffer.

If you simply change compilation-buffer-p to

(defsubst compilation-buffer-p (buffer)
  (save-excursion
    (set-buffer buffer)
    (or compilation-shell-minor-mode compilation-minor-mode
	(eq major-mode 'compilation-mode)
        compilation-next-error-function)))

it will always consider an occur buffer (and other buffers which have
a non-nil compilation-next-error-function) as a compilation buffer.

To me that would seem logical, but I'm probably overlooking something.

Can you mention the commands where is that behaviour NOT desireable,
and why?


In any case, here are some comments on your latest patch:

>  
>    (save-excursion
>      (set-buffer buffer)
> -    (or compilation-shell-minor-mode compilation-minor-mode
> -	(eq major-mode 'compilation-mode))))
> +    (or compilation-shell-minor-mode 
> +	compilation-minor-mode
> +	(eq major-mode 'compilation-mode)
> +	(and allow-with-next-error-function
> +	     (buffer-local-value
> +	      'compilation-next-error-function
> +	      buffer)))))

For the last four lines, you can just write

        (and allow-with-next-error-function
             compilation-next-error-function)

as you already did a (set-buffer buffer), so there's no reason to use
buffer-local-value here.


>  
> +;; override compilation-last-buffer
> +(defvar occur-last-buffer nil
> +  "The most recent occur buffer.
> +An occur buffer becomes most recent when its process is started
> +or when it is used with \\[occur-next].
> +Notice that using \\[next-error] or \\[compile-goto-error] modifies
> +`complation-last-buffer' rather than `occur-last-buffer'.")
> +

You no longer need the occur-last-buffer variable.


> +	      (setq occur-last-buffer occur-buf)

Likewise.

-- 
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-06 23:10                             ` Stefan Monnier
@ 2004-02-07  0:52                               ` David Kastrup
  2004-02-07 22:39                                 ` Stefan Monnier
  2004-02-09 18:44                               ` Ted Zlatanov
  1 sibling, 1 reply; 101+ messages in thread
From: David Kastrup @ 2004-02-07  0:52 UTC (permalink / raw)
  Cc: Ted Zlatanov, emacs-devel, Kim F. Storm

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> >   (save-excursion
> >     (set-buffer buffer)
> 
> Also known as (with-current buffer buffer

It's not the same if buffer is already selected.  In that case the
first version restores the cursor position afterwards and the second
doesn't.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-05 17:27                         ` Ted Zlatanov
  2004-02-06 23:57                           ` Kim F. Storm
@ 2004-02-07  9:00                           ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-02-07  9:00 UTC (permalink / raw)
  Cc: emacs-devel

    > IMO, it would be cleaner to add (provide 'occur) to replace.el and
    > just test with (featurep 'occur).

That is not necessary.  replace.el is preloaded.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-07  0:52                               ` David Kastrup
@ 2004-02-07 22:39                                 ` Stefan Monnier
  0 siblings, 0 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-02-07 22:39 UTC (permalink / raw)
  Cc: Ted Zlatanov, emacs-devel, Kim F. Storm

>> >   (save-excursion
>> >     (set-buffer buffer)
>> 
>> Also known as (with-current buffer buffer

> It's not the same if buffer is already selected.  In that case the
> first version restores the cursor position afterwards and the second
> doesn't.

Indeed, it's not 100% equivalent.  My experience is that in practice, in
98% of the cases, you can replace the first with the second, as for the
remaining 2% it's probably equally split between cases where it would
introduce a bug and cases where it makes an existing bug a bit more obvious
to the programmer.  This last case is when people do for example:

   (save-excursion
     (set-buffer foo)
     (re-search-forward "bar")
     (match-string 1))
     
where they should have done

   (with-current-buffer foo
     (save-excursion
       (re-search-forward "bar")
       (match-string 1)))


-- Stefan

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-06 23:57                           ` Kim F. Storm
  2004-02-06 23:10                             ` Stefan Monnier
@ 2004-02-09 18:43                             ` Ted Zlatanov
  2004-02-10 12:44                               ` Richard Stallman
  1 sibling, 1 reply; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-09 18:43 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]

On 07 Feb 2004, storm@cua.dk wrote:

> I haven't thought a lot about it, but I don't understand why you
> need that extra allow-with-next-error-function arg to
> compilation-buffer-p and compilation-find-buffer.

I was trying to draw a distinction between "find a compilation
buffer" in compile.el and "find a buffer where next-error will
work."  I'll leave it without that distinction for now, and I
don't think it will make a difference (based on my understanding
of the code).

> Can you mention the commands where is that behaviour NOT desireable,
> and why?

I was trying to preserve the *meaning* of compilation-find-buffer,
by making it select an Occur buffer only if specifically
requested.

> For the last four lines, you can just write
> 
>         (and allow-with-next-error-function
>              compilation-next-error-function)
> 
> as you already did a (set-buffer buffer), so there's no reason to
> use buffer-local-value here.

I originally had that code in replace.el, where I didn't want to
rely on the existence of the compilation-next-error-function
symbol.  My mistake.

> You no longer need the occur-last-buffer variable.

Done.

Attached is latest patch.  Thanks for your help.

Ted


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error+occur.patch --]
[-- Type: text/x-patch, Size: 5141 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  9 13:35:00 2004
@@ -36,7 +36,6 @@
   :group 'tools
   :group 'processes)
 
-
 ;;;###autoload
 (defcustom compilation-mode-hook nil
   "*List of hook functions run by `compilation-mode' (see `run-hooks')."
@@ -133,6 +132,15 @@
 A buffer becomes most recent when its compilation is started
 or when it is used with \\[next-error] or \\[compile-goto-error].")
 
+(defvar compilation-next-error-function nil
+  "The next-error analogue for other modes.
+This variable can be bound to a function by a mode.  It is
+buffer-local by default.  Together with
+`compilation-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'compilation-next-error-function)
+
 (defvar compilation-in-progress nil
   "List of compilation processes now running.")
 (or (assq 'compilation-in-progress minor-mode-alist)
@@ -1057,10 +1065,12 @@
     errors))
 
 (defsubst compilation-buffer-p (buffer)
-  (save-excursion
-    (set-buffer buffer)
-    (or compilation-shell-minor-mode compilation-minor-mode
-	(eq major-mode 'compilation-mode))))
+  "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)))
 
 (defun compilation-next-error (n)
   "Move point to the next error in the compilation buffer.
@@ -1406,12 +1416,14 @@
 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.
+\\[next-error] normally uses the most recently started
+compilation or grep buffer.  However, it can 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
+`compilation-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
@@ -1421,13 +1433,23 @@
 \`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))))
+  (if (buffer-local-value 
+       'compilation-next-error-function 
+       compilation-last-buffer)
+      ;; do the right thing for modes that bind compilation-next-error-function
+      (progn
+	(set-buffer compilation-last-buffer)
+	(funcall compilation-next-error-function argp))
+    (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)
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
 
 (defun previous-error (argp)
   "Visit previous compilation error message and corresponding source code.

--- /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  9 13:36:30 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 compilation-last-buffer occur-buf)
+	      (setq compilation-next-error-function 'occur-next-error))
 	  (kill-buffer occur-buf)))
       (run-hooks 'occur-hook))))
 

[-- Attachment #3: 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-06 23:10                             ` Stefan Monnier
  2004-02-07  0:52                               ` David Kastrup
@ 2004-02-09 18:44                               ` Ted Zlatanov
  1 sibling, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-09 18:44 UTC (permalink / raw)


On 06 Feb 2004, monnier@iro.umontreal.ca wrote:

>>   (save-excursion
>>     (set-buffer buffer)
> 
> Also known as (with-current buffer buffer

I made the change, thanks.  I know about with-current-buffer, I just
didn't realize I could use it.

Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-09 18:43                             ` Ted Zlatanov
@ 2004-02-10 12:44                               ` Richard Stallman
  2004-02-10 14:50                                 ` Kim F. Storm
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2004-02-10 12:44 UTC (permalink / raw)
  Cc: emacs-devel

    +  (if (buffer-local-value 
    +       'compilation-next-error-function 
    +       compilation-last-buffer)
    +      ;; do the right thing for modes that bind compilation-next-error-function

It is cleaner to check for a non-nil value than to
check for a local binding.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-10 12:44                               ` Richard Stallman
@ 2004-02-10 14:50                                 ` Kim F. Storm
  2004-02-10 16:51                                   ` Ted Zlatanov
  2004-02-12 14:57                                   ` Richard Stallman
  0 siblings, 2 replies; 101+ messages in thread
From: Kim F. Storm @ 2004-02-10 14:50 UTC (permalink / raw)
  Cc: Ted Zlatanov, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     +  (if (buffer-local-value 
>     +       'compilation-next-error-function 
>     +       compilation-last-buffer)
>     +      ;; do the right thing for modes that bind compilation-next-error-function
> 
> It is cleaner to check for a non-nil value than to
> check for a local binding.

I don't follow...  

We need to check if the buffer-local value of the variable
compilation-next-error-function is non-nil in the
compilation-last-buffer buffer.

Is this what you suggest to use instead?

        (if (with-current-buffer compilation-last-buffer
               compilation-next-error-function)
          ...

If so, what's the difference?

-- 
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-10 14:50                                 ` Kim F. Storm
@ 2004-02-10 16:51                                   ` Ted Zlatanov
  2004-02-12 14:57                                   ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-10 16:51 UTC (permalink / raw)


On 10 Feb 2004, storm@cua.dk wrote:

> I don't follow...  
> 
> We need to check if the buffer-local value of the variable
> compilation-next-error-function is non-nil in the
> compilation-last-buffer buffer.
> 
> Is this what you suggest to use instead?
> 
>         (if (with-current-buffer compilation-last-buffer
>                compilation-next-error-function)
>           ...
> 
> If so, what's the difference?

I don't understand the problem either, but I'll be happy to
change the patch to whatever RMS and you prefer.

Ted

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-10 14:50                                 ` Kim F. Storm
  2004-02-10 16:51                                   ` Ted Zlatanov
@ 2004-02-12 14:57                                   ` Richard Stallman
  2004-02-12 16:46                                     ` Ted Zlatanov
  1 sibling, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2004-02-12 14:57 UTC (permalink / raw)
  Cc: tzz, emacs-devel

    > It is cleaner to check for a non-nil value than to
    > check for a local binding.

    I don't follow...  

I confused buffer-local-value with local-variable-p when looking at
the code.  Sorry.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-02-12 14:57                                   ` Richard Stallman
@ 2004-02-12 16:46                                     ` Ted Zlatanov
  2004-02-12 19:48                                       ` Stefan Monnier
                                                         ` (14 more replies)
  0 siblings, 15 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-02-12 16:46 UTC (permalink / raw)


If there are no objections, can the next-error patch I posted
previously go in?

I saw some discussion of a compile.el update, I hope the new version
preserves this patch's behavior.

Thanks
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
@ 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: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-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-13 20:58                                             ` Andreas Schwab
@ 2004-02-13 21:04                                               ` Stefan Monnier
  2004-02-14 17:17                                               ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-02-13 21:04 UTC (permalink / raw)
  Cc: Ted Zlatanov, emacs-devel

> This can be fixed with
> ;;;###autoload (make-variable-buffer-local 'compilation-next-error-function)

Sure.  But it still won't work if some code does a setq on this variable
before loaddefs.el is loaded ;-)

Anyway, my only point is that it's more delicate to use and has
non-obvious pitfalls, so it's better to keep it for the cases where it's
really "the right thing".


        Stefan

^ 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-12 23:19                                           ` Kim F. Storm
@ 2004-02-14 17:15                                             ` Richard Stallman
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-02-14 17:15 UTC (permalink / raw)
  Cc: tzz, monnier, emacs-devel

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?

^ 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-13 20:58                                             ` Andreas Schwab
  2004-02-13 21:04                                               ` Stefan Monnier
@ 2004-02-14 17:17                                               ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-02-14 17:17 UTC (permalink / raw)
  Cc: tzz, monnier, emacs-devel

It is better to use make-local-variable in specific modes
in any complicated case.

^ 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-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-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
       [not found]                                         ` <4n8yikpjcz.fsf@collins.bwh.harvard.edu>
@ 2004-03-02 15:51                                           ` Richard Stallman
  2004-03-02 17:30                                             ` Ted Zlatanov
  2004-03-08 20:20                                           ` Ted Zlatanov
  1 sibling, 1 reply; 101+ messages in thread
From: Richard Stallman @ 2004-03-02 15:51 UTC (permalink / raw)
  Cc: emacs-devel

      But (and this
    is the important part) M-x occur needs to be run before this can
    happen.

Indeed, the issue is what happens after the user has typed M-x occur.

      An Occur buffer will be picked if next-error is run inside the
    Occur buffer; if next-error-last-buffer is set to the Occur buffer (so
    a grep or a compile has not been run meanwhile); 

I think that will do the right thing in simple cases.

       or if an Occur buffer
    is the first usable buffer found in the buffer list.

Perhaps this will work well, but we should keep our eyes open
for cases where users don't like it.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-03-02 15:51                                           ` Richard Stallman
@ 2004-03-02 17:30                                             ` Ted Zlatanov
  2004-03-03  1:40                                               ` Miles Bader
  2004-03-03 15:19                                               ` Richard Stallman
  0 siblings, 2 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-03-02 17:30 UTC (permalink / raw)
  Cc: Kim F. Storm, emacs-devel

On Tue, 02 Mar 2004, rms@gnu.org wrote:

>       An Occur buffer will be picked if next-error is run inside the
>     Occur buffer; if next-error-last-buffer is set to the Occur
>     buffer (so a grep or a compile has not been run meanwhile);
> 
> I think that will do the right thing in simple cases.
> 
>        or if an Occur buffer
>     is the first usable buffer found in the buffer list.
> 
> Perhaps this will work well, but we should keep our eyes open
> for cases where users don't like it.

Of course.  I'm willing to be the designated maintainer of the
next-error framework, in charge of extending it to other packages and
verifying user satisfaction by tracking bug reports and
newsgroups/mailing lists.

If there are no other objections to the next-error patch, can it go
into CVS so we can see if users like it?  emacs-devel seems to be down
so I've cc-ed Kim Storm for help.

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
                                                         ` (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 17:30                                             ` Ted Zlatanov
@ 2004-03-03  1:40                                               ` Miles Bader
  2004-03-03 20:41                                                 ` Mike Hearn
  2004-03-03 21:57                                                 ` Kim F. Storm
  2004-03-03 15:19                                               ` Richard Stallman
  1 sibling, 2 replies; 101+ messages in thread
From: Miles Bader @ 2004-03-03  1:40 UTC (permalink / raw)
  Cc: emacs-devel, rms, Kim F. Storm

Ted Zlatanov <tzz@lifelogs.com> writes:
> emacs-devel seems to be down so I've cc-ed Kim Storm for help.

I got your message, and am not personally on the CC list, so it isn't down.
[Maybe it's slow delivering to some hosts.]

-Miles
-- 
Quidquid latine dictum sit, altum viditur.

^ 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 17:30                                             ` Ted Zlatanov
  2004-03-03  1:40                                               ` Miles Bader
@ 2004-03-03 15:19                                               ` Richard Stallman
  1 sibling, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-03-03 15:19 UTC (permalink / raw)
  Cc: storm, emacs-devel

We need to get papers before actually installing this.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-03-03  1:40                                               ` Miles Bader
@ 2004-03-03 20:41                                                 ` Mike Hearn
  2004-03-03 21:57                                                 ` Kim F. Storm
  1 sibling, 0 replies; 101+ messages in thread
From: Mike Hearn @ 2004-03-03 20:41 UTC (permalink / raw)
  Cc: Ted Zlatanov, Kim F. Storm, rms, emacs-devel

There's definately something wrong with it - I suspect the accounts were
somehow reset. I shouldn't be receiving this mail, I disabled mail
delivery and read via gmane, yet here it is in my inbox :)

On Wed, 2004-03-03 at 01:40, Miles Bader wrote:
> Ted Zlatanov <tzz@lifelogs.com> writes:
> > emacs-devel seems to be down so I've cc-ed Kim Storm for help.
> 
> I got your message, and am not personally on the CC list, so it isn't down.
> [Maybe it's slow delivering to some hosts.]
> 
> -Miles

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
  2004-03-03  1:40                                               ` Miles Bader
  2004-03-03 20:41                                                 ` Mike Hearn
@ 2004-03-03 21:57                                                 ` Kim F. Storm
  2004-03-07 16:04                                                   ` Richard Stallman
  1 sibling, 1 reply; 101+ messages in thread
From: Kim F. Storm @ 2004-03-03 21:57 UTC (permalink / raw)
  Cc: Ted Zlatanov, Kim F. Storm, rms, emacs-devel

Miles Bader <miles@lsi.nec.co.jp> writes:

> Ted Zlatanov <tzz@lifelogs.com> writes:
> > emacs-devel seems to be down so I've cc-ed Kim Storm for help.
> 
> I got your message, and am not personally on the CC list, so it isn't down.
> [Maybe it's slow delivering to some hosts.]

I that case, you may be the only one receiving emacs-devel messages.  
Did you see the two messages I (re)sent today ??  It is 8 hours ago,
and I haven't seen them on the list yet.


One thing I noticed is that the user names have now returned as the
author of the CVS commits -- coincidentally(?) that happened
last Wednesday too...

++kfs

^ 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-03 21:57                                                 ` Kim F. Storm
@ 2004-03-07 16:04                                                   ` Richard Stallman
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Stallman @ 2004-03-07 16:04 UTC (permalink / raw)
  Cc: tzz, storm, emacs-devel, miles

I have received several messages through emacs-devel recently.
I think the sysadmins reset it.

^ permalink raw reply	[flat|nested] 101+ messages in thread

* Re: Add M-x occur to the menu-bar
       [not found]                                         ` <4n8yikpjcz.fsf@collins.bwh.harvard.edu>
  2004-03-02 15:51                                           ` Richard Stallman
@ 2004-03-08 20:20                                           ` Ted Zlatanov
  1 sibling, 0 replies; 101+ messages in thread
From: Ted Zlatanov @ 2004-03-08 20:20 UTC (permalink / raw)


On Wed, 03 Mar 2004, rms@gnu.org wrote:

> We need to get papers before actually installing this.

The FSF assignment form is in the mail.

Thanks
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

* 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-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-04-14 18:04                                       ` Ted Zlatanov
@ 2004-04-14 21:57                                         ` Stefan Monnier
  0 siblings, 0 replies; 101+ messages in thread
From: Stefan Monnier @ 2004-04-14 21:57 UTC (permalink / raw)
  Cc: emacs-devel

>>> +	      (setq next-error-function 'occur-next-error))
>> This should be placed in occur-mode.
> It's in replace.el, where occur-mode is defined.

I meant, in the `occur-mode' function.

> Thank you very much for the thorough review.  All the changes are
> in the latest patch I just posted.

I'll try to find time to install it soon,


        Stefan

^ 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-15  0:20                                         ` Kim F. Storm
@ 2004-04-15  1:29                                           ` Kim F. Storm
  0 siblings, 0 replies; 101+ messages in thread
From: Kim F. Storm @ 2004-04-15  1:29 UTC (permalink / raw)
  Cc: emacs-devel

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.

-- 
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
                                                         ` (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-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
                                                         ` (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

end of thread, other threads:[~2004-04-15 18:43 UTC | newest]

Thread overview: 101+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-19  9:10 Add M-x occur to the menu-bar Marshall, Simon
2003-09-20  7:49 ` Richard Stallman
2003-09-23  1:06   ` Miles Bader
2003-09-23 18:50     ` Eli Zaretskii
2003-09-23 20:10       ` David Kastrup
2003-09-24  8:40       ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2003-09-16  8:30 Marshall, Simon
2003-09-17 18:02 ` Richard Stallman
2003-09-16  8:16 Marshall, Simon
2003-09-12 16:07 Marshall, Simon
2003-09-13  9:36 ` Eli Zaretskii
2003-09-13 13:57 ` Richard Stallman
2003-09-18 17:21   ` Kevin Rodgers
2003-09-18 18:40     ` Miles Bader
2003-09-21 12:11       ` Eli Zaretskii
2003-09-21 11:28         ` Miles Bader
2003-09-21 13:55       ` Ehud Karni
2003-09-19 12:22     ` Richard Stallman
2003-09-18 17:10 ` Kevin Rodgers
2003-09-18 17:27   ` Masatake YAMATO
2004-01-27 15:34   ` Ted Zlatanov
2004-01-27 17:24     ` Benjamin Rutt
2004-01-27 18:46       ` Ted Zlatanov
2004-01-27 19:02         ` Benjamin Rutt
2004-01-27 19:04       ` Stefan Monnier
2004-01-27 19:35         ` Ted Zlatanov
2004-01-27 23:03           ` Miles Bader
2004-01-28  3:53             ` Ted Zlatanov
2004-01-28 14:30               ` Stefan Monnier
2004-01-28 15:46                 ` Ted Zlatanov
2004-01-28 22:45                   ` Kevin Rodgers
2004-01-29  5:42                     ` Eli Zaretskii
2004-01-29 15:19                       ` Stefan Monnier
2004-01-29 15:28                         ` Miles Bader
2004-01-29 15:41                           ` David Kastrup
2004-01-29 20:52                         ` Kai Grossjohann
2004-01-29 17:51                 ` Richard Stallman
2004-01-30 19:00                   ` Ted Zlatanov
2004-02-04 20:39                     ` Ted Zlatanov
2004-02-04 23:20                       ` Kim F. Storm
2004-02-05 17:27                         ` Ted Zlatanov
2004-02-06 23:57                           ` Kim F. Storm
2004-02-06 23:10                             ` Stefan Monnier
2004-02-07  0:52                               ` David Kastrup
2004-02-07 22:39                                 ` Stefan Monnier
2004-02-09 18:44                               ` Ted Zlatanov
2004-02-09 18:43                             ` Ted Zlatanov
2004-02-10 12:44                               ` Richard Stallman
2004-02-10 14:50                                 ` Kim F. Storm
2004-02-10 16:51                                   ` Ted Zlatanov
2004-02-12 14:57                                   ` Richard Stallman
2004-02-12 16:46                                     ` Ted Zlatanov
2004-02-12 19:48                                       ` Stefan Monnier
2004-02-12 20:34                                         ` Ted Zlatanov
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
2004-02-12 23:19                                           ` Kim F. Storm
2004-02-14 17:15                                             ` Richard Stallman
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
2004-02-25 13:24                                         ` Richard Stallman
2004-02-23 20:33                                       ` Ted Zlatanov
2004-02-24  0:37                                         ` Kim F. Storm
2004-02-24 17:23                                           ` 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
2004-03-11 20:19                                         ` Richard Stallman
2004-03-14  2:04                                           ` Kim F. Storm
     [not found]                                       ` <jwvr7x06q95.fsf-monnier+emacs <E1Avz1R-0001M2-Df@fencepost.gnu.org>
     [not found]                                         ` <4n1xohpsvt.fsf@collins.bwh.harvard.edu>
     [not found]                                         ` <4n8yikpjcz.fsf@collins.bwh.harvard.edu>
2004-03-02 15:51                                           ` Richard Stallman
2004-03-02 17:30                                             ` Ted Zlatanov
2004-03-03  1:40                                               ` Miles Bader
2004-03-03 20:41                                                 ` Mike Hearn
2004-03-03 21:57                                                 ` Kim F. Storm
2004-03-07 16:04                                                   ` Richard Stallman
2004-03-03 15:19                                               ` Richard Stallman
2004-03-08 20:20                                           ` Ted Zlatanov
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
2004-04-07 21:50                                         ` Stefan Monnier
2004-04-08 14:57                                         ` Richard Stallman
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  1:29                                           ` Kim F. Storm
2004-04-15 16:44                                         ` Richard Stallman
2004-04-14 18:04                                       ` Ted Zlatanov
2004-04-14 21:57                                         ` Stefan Monnier
2004-04-15 15:40                                       ` Ted Zlatanov
2004-04-15 15:59                                       ` Ted Zlatanov
2004-04-15 18:43                                       ` Ted Zlatanov
2004-02-07  9:00                           ` Richard Stallman
2004-01-28  9:04     ` Richard Stallman
2003-09-11 16:11 Marshall, Simon

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.