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: Wed, 04 Feb 2004 15:39:07 -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: <4noese37h0.fsf@collins.bwh.harvard.edu> References: <3F69E6FF.9050702@yahoo.com> <4n8yjto16h.fsf@collins.bwh.harvard.edu> <4nisixjibl.fsf@collins.bwh.harvard.edu> <20040127230323.GB5407@fencepost> <4n7jzc919v.fsf@collins.bwh.harvard.edu> <4nn085i7nl.fsf@collins.bwh.harvard.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1075927318 24732 80.91.224.253 (4 Feb 2004 20:41:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 4 Feb 2004 20:41:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Feb 04 21:41:51 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 1AoTqJ-0000tD-00 for ; Wed, 04 Feb 2004 21:41:51 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AoTqJ-0001jg-00 for ; Wed, 04 Feb 2004 21:41:51 +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 1AoTpq-0001WQ-JQ for emacs-devel@quimby.gnus.org; Wed, 04 Feb 2004 15:41:22 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AoTpj-0001VL-2E for emacs-devel@gnu.org; Wed, 04 Feb 2004 15:41:15 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AoTpC-0001NN-Nr for emacs-devel@gnu.org; Wed, 04 Feb 2004 15:41:13 -0500 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AoTpC-0001N1-3v for emacs-devel@gnu.org; Wed, 04 Feb 2004 15:40:42 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AoTp9-00078v-00 for ; Wed, 04 Feb 2004 21:40:39 +0100 Original-Received: from collins.bwh.harvard.edu ([134.174.9.80]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed Feb 4 20:40:39 2004 Original-Received: from tzz by collins.bwh.harvard.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed Feb 4 20:40:39 2004 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 159 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: collins.bwh.harvard.edu 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:ToT5CKTpoDW7oPZ02zYYIldQ01M= 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:19714 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19714 --=-=-= 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=next-error+occur.patch --- /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)))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --=-=-=--