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: Mon, 09 Feb 2004 13:43:28 -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: <4n8yjcccvj.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> <4noese37h0.fsf@collins.bwh.harvard.edu> <4nbrodxwqm.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 1076352953 23631 80.91.224.253 (9 Feb 2004 18:55:53 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Feb 2004 18:55:53 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Feb 09 19:55:36 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 1AqGZD-0004dv-00 for ; Mon, 09 Feb 2004 19:55:35 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AqGZC-00052h-01 for ; Mon, 09 Feb 2004 19:55:35 +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 1AqGVo-0007Ll-8L for emacs-devel@quimby.gnus.org; Mon, 09 Feb 2004 13:52:04 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AqGUP-0006rr-UK for emacs-devel@gnu.org; Mon, 09 Feb 2004 13:50:37 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AqGTs-0006hx-8P for emacs-devel@gnu.org; Mon, 09 Feb 2004 13:50:35 -0500 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AqGP4-000359-CQ for emacs-devel@gnu.org; Mon, 09 Feb 2004 13:45:06 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AqGP1-0002H5-00 for ; Mon, 09 Feb 2004 19:45:03 +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 ; Mon Feb 9 18:45:03 2004 Original-Received: from tzz by collins.bwh.harvard.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon Feb 9 18:45:03 2004 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 177 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:LmWaLwJgXdY2hNLSRS3BeBbY6M8= 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:19837 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19837 --=-=-= 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 --=-=-= 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 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)) + (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)))) --=-=-= 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 --=-=-=--