[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add M-x occur to the menu-bar

From: Ted Zlatanov
Subject: Re: Add M-x occur to the menu-bar
Date: Tue, 27 Jan 2004 13:46:13 -0500
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (usg-unix-v)

On Tue, 27 Jan 2004, address@hidden wrote:

> Ted Zlatanov <address@hidden> 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."
   ((equal dwim-next-mode 'occur)
    ;; act like next-error - is this right?
    (set-buffer "*Occur*")
   ;; next-error can handle the rest
   (t (next-error))))

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]