unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Add M-x occur to the menu-bar
Date: Wed, 04 Feb 2004 15:39:07 -0500	[thread overview]
Message-ID: <4noese37h0.fsf@collins.bwh.harvard.edu> (raw)
In-Reply-To: 4nn085i7nl.fsf@collins.bwh.harvard.edu

[-- 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

  reply	other threads:[~2004-02-04 20:39 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-12 16:07 Add M-x occur to the menu-bar 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 [this message]
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
     [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-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
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
  -- strict thread matches above, loose matches on Subject: below --
2003-09-19  9:10 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
2003-09-16  8:30 Marshall, Simon
2003-09-17 18:02 ` Richard Stallman
2003-09-16  8:16 Marshall, Simon
2003-09-11 16:11 Marshall, Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4noese37h0.fsf@collins.bwh.harvard.edu \
    --to=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).