From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: Add M-x occur to the menu-bar Date: Tue, 27 Jan 2004 13:46:13 -0500 Organization: =?koi8-r?q?=F4=C5=CF=C4=CF=D2=20=FA=CC=C1=D4=C1=CE=CF=D7?= @ Cienfuegos Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <4nd695kz62.fsf@collins.bwh.harvard.edu> References: <3F69E6FF.9050702@yahoo.com> <4n8yjto16h.fsf@collins.bwh.harvard.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1075229504 31334 80.91.224.253 (27 Jan 2004 18:51:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Jan 2004 18:51:44 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Jan 27 19:51:39 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AlYJH-00058c-00 for ; Tue, 27 Jan 2004 19:51:39 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AlYJH-0002Bd-00 for ; Tue, 27 Jan 2004 19:51:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AlYII-0005qm-3B for emacs-devel@quimby.gnus.org; Tue, 27 Jan 2004 13:50:38 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AlYGv-0004sB-Hn for emacs-devel@gnu.org; Tue, 27 Jan 2004 13:49:13 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AlYGF-00047I-Aq for emacs-devel@gnu.org; Tue, 27 Jan 2004 13:49:02 -0500 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AlYFP-0003XS-Gi for emacs-devel@gnu.org; Tue, 27 Jan 2004 13:47:39 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AlYFO-0002gf-00 for ; Tue, 27 Jan 2004 19:47:38 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AlYFM-0002gX-00 for ; Tue, 27 Jan 2004 19:47:36 +0100 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AlYFM-0007zo-00 for ; Tue, 27 Jan 2004 19:47:36 +0100 Original-Lines: 52 Original-X-Complaints-To: usenet@sea.gmane.org X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (usg-unix-v) Cancel-Lock: sha1:QyrksR5peX0cdQxgb+Lrzv7PoaE= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:19512 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19512 On Tue, 27 Jan 2004, brutt+news@bloomington.in.us wrote: > Ted Zlatanov 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