From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Add M-x occur to the menu-bar
Date: Wed, 14 Apr 2004 13:57:27 -0400 [thread overview]
Message-ID: <4n4qrmxx14.fsf@lifelogs.com> (raw)
In-Reply-To: 4nwu6sp7ni.fsf@collins.bwh.harvard.edu
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
After playing catch-up with the changes of compile.el and others,
here's the Latest Next-Error Patch(tm).
I'll address Simon Josefsson's concerns in a followup, and I provide
NEWS and ChangeLog entries.
Please test - it seems to work fine for me.
Thanks
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error patch --]
[-- Type: text/x-patch, Size: 16402 bytes --]
--- /local/share/src/emacs-cvs/lisp/progmodes/compile.el Wed Apr 14 03:23:50 2004
+++ /home/tzz/emacs/mine/compile.el Wed Apr 14 13:46:41 2004
@@ -949,6 +949,7 @@
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
+ (setq next-error-last-buffer outbuf)
(setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
@@ -1141,6 +1142,10 @@
;; jit-lock might fontify some things too late.
(set (make-local-variable 'font-lock-support-mode) nil)
(set (make-local-variable 'font-lock-maximum-size) nil)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(let ((fld font-lock-defaults))
(if (and minor fld)
(font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
@@ -1249,8 +1254,16 @@
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
- (local-variable-p 'compilation-locs buffer))
+ "Test if BUFFER is a compilation buffer."
+ (with-current-buffer buffer
+ (compilation-buffer-internal-p)))
+
+;;; test if a buffer is a compilation buffer, assuming we're in the buffer
+(defsubst compilation-buffer-internal-p ()
+ "Test if inside a compilation buffer."
+ (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
@@ -1319,25 +1332,6 @@
(interactive "p")
(compilation-next-error (- n)))
-(defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-Finds and highlights the source line like \\[next-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
-(defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-Finds and highlights the source line like \\[previous-error], but does not
-select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
@@ -1379,51 +1373,14 @@
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
- (if (and (not other-buffer)
- (compilation-buffer-p (current-buffer)))
- ;; The current buffer is a compilation buffer.
- (current-buffer)
- (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
- (compilation-buffer-p compilation-last-buffer)
- (or (not other-buffer) (not (eq compilation-last-buffer
- (current-buffer)))))
- compilation-last-buffer
- (let ((buffers (buffer-list)))
- (while (and buffers (or (not (compilation-buffer-p (car buffers)))
- (and other-buffer
- (eq (car buffers) (current-buffer)))))
- (setq buffers (cdr buffers)))
- (if buffers
- (car buffers)
- (or (and other-buffer
- (compilation-buffer-p (current-buffer))
- ;; The current buffer is a compilation buffer.
- (progn
- (if other-buffer
- (message "This is the only compilation buffer."))
- (current-buffer)))
- (error "No compilation started!")))))))
+ (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
-(defun next-error (&optional n)
- "Visit next compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move forwards (or
-backwards, if negative).
-
-\\[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.
-
-Once \\[next-error] has chosen the buffer for error messages,
-it stays with that buffer until you use it in some other buffer which
-uses Compilation mode or Compilation Minor mode.
-
-See variable `compilation-error-regexp-alist' for customization ideas."
+(defun compilation-next-error-function (n &optional reset)
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
@@ -1469,27 +1426,6 @@
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
-;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
-(defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
-Prefix arg N says how many error messages to move backwards (or
-forwards, if negative).
-
-This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
-(defun first-error (n)
- "Restart at the first error.
-Visit corresponding source code.
-With prefix arg N, visit the source code of the Nth error.
-This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
+++ /home/tzz/emacs/mine/replace.el Wed Apr 14 13:53:47 2004
@@ -614,6 +614,21 @@
"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 reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (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))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
@@ -800,7 +815,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 next-error-last-buffer occur-buf)
+ (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
+++ /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
@@ -66,6 +66,137 @@
(setq list (cdr list)))
(switch-to-buffer found)))
+;;; next-error support framework
+(defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+A buffer becomes most recent when its compilation, grep, or
+similar mode is started, or when it is used with \\[next-error]
+or \\[compile-goto-error].")
+
+(defvar next-error-function nil
+ "The next-error vehicle for other modes.
+This variable can be bound to a function by a mode. It is
+buffer-local by default. Together with
+`next-error-last-buffer', this variable lets modes hook into
+\\[next-error].")
+
+(make-variable-buffer-local 'next-error-function)
+
+(defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+;; Return a next-error capable buffer.
+;; If the current buffer is such, return it.
+;; If next-error-last-buffer is set to a live buffer, use that.
+;; Otherwise, look for a next-error capable buffer and signal an error
+;; if there are none.
+(defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+(defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+If all the error messages parsed so far have been processed already,
+the message buffer is checked for new ones.
+
+A prefix ARGP specifies how many error messages to move;
+negative means move back to previous error messages.
+Just \\[universal-argument] as a prefix means reparse the error message buffer
+and start at the first error.
+
+The RESET argument specifies that we should restart from the beginning
+
+\\[next-error] normally uses the most recently started
+compilation, grep, or occur buffer. It can also 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
+`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
+uses Compilation mode or Compilation Minor mode.
+
+See variables `compilation-parse-errors-function' and
+\`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+(defalias 'goto-next-locus 'next-error)
+(defalias 'next-match 'next-error)
+
+(define-key ctl-x-map "`" 'next-error)
+
+(defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+
+This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+(defun first-error (n)
+ "Restart at the first error.
+Visit corresponding source code.
+With prefix arg N, visit the source code of the Nth error.
+This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+(defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move forwards (or
+backwards, if negative).
+Finds and highlights the source line like \\[next-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+(defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+Prefix arg N says how many error messages to move backwards (or
+forwards, if negative).
+Finds and highlights the source line like \\[previous-error], but does not
+select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
--- /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
+++ /home/tzz/emacs/mine/NEWS Tue Apr 13 17:04:54 2004
@@ -14,6 +14,14 @@
\f
* Installation Changes in Emacs 21.4
+** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
+
+** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
---
** A Bulgarian translation of the Emacs Tutorial is available.
@@ -87,12 +95,6 @@
\f
* Changes in Emacs 21.4
-
-** New command line option -Q.
-
-This is like using -q --no-site-file, but in addition it also disables
-the menu-bar, the tool-bar, the scroll-bars, tool tips, the blinking
-cursor, and the fancy startup screen.
** C-h v and C-h f commands now include a hyperlink to the C source for
variables and functions defined in C (if the C source is available).
--- /local/share/src/emacs-cvs/lisp/ChangeLog Wed Apr 14 03:23:43 2004
+++ /home/tzz/emacs/mine/ChangeLog Wed Apr 14 14:06:05 2004
@@ -1,28 +1,27 @@
-2004-04-14 Daniel Pfeiffer <occitan@esperanto.org>
+2004-04-14 Teodor Zlatanov <tzz@lifelogs.com>
- * progmodes/compile.el (compilation-setup): Localize
- overlay-arrow-position.
- (compilation-sentinel): Restructure code equivalently.
- (compilation-next-error): Find message on same line after point if
- not found before point.
- (compile-mouse-goto-error): Restore function so that compilation
- buffer need not be current and use compile-goto-error.
- (compile-goto-error): Restore function.
- (next-error): Set overlay-arrow-position.
- (compilation-forget-errors): Don't localize already local
- compilation-locs and remove FIXME about refontifying.
+ * simple.el (next-error-last-buffer, next-error-function): new
+ variables for the next-error framework
+ (next-error-buffer-p): is a buffer capable of next-error?
+ (next-error-find-buffer): the functionality of
+ compilation-find-buffer, generalized
+ (next-error, previous-error, first-error, next-error-no-select)
+ (previous-error-no-select): next-error framework
-2004-04-14 Kim F. Storm <storm@cua.dk>
+ * replace.el (occur-next-error, occur-1): support the next-error
+ framework
- * startup.el (emacs-quick-startup): New defvar (set by -Q).
- (command-line): New option -Q. Like -q --no-site-file, but
- in addition it also disables menu-bar, tool-bar, scroll-bars,
- tool-tips, and the blinking cursor.
- (command-line-1): Skip startup screen if -Q.
- (fancy-splash-head): Use :align-to center prop to center splash image.
-
- * emulation/cua-base.el (cua-read-only-cursor-color)
- (cua-overwrite-cursor-color, cua-global-mark-cursor-color): Doc fix.
+ * compile.el (compilation-start): set next-error-last-buffer so
+ next-error knows where to jump
+ (compilation-setup): set the buffer-local variable
+ next-error-function to 'compilation-next-error-function
+ (compilation-buffer-p, compilation-buffer-internal-p): use an
+ alternate way to find if a buffer is a compilation buffer, for
+ next-error convenience
+ (next-error-no-select, previous-error-no-select, next-error)
+ (previous-error, first-error): moved to simple.el
+ (compilation-find-buffer): functionality moved to
+ next-error-find-buffer in simple.el
2004-04-13 Dave Love <fx@gnu.org>
[-- Attachment #3: context patch for RMS --]
[-- Type: text/plain, Size: 17979 bytes --]
*** /local/share/src/emacs-cvs/lisp/progmodes/compile.el Wed Apr 14 03:23:50 2004
--- /home/tzz/emacs/mine/compile.el Wed Apr 14 13:46:41 2004
***************
*** 949,954 ****
--- 949,955 ----
(select-window outwin)
(goto-char (point-max))))
;; Make it so the next C-x ` will use this buffer.
+ (setq next-error-last-buffer outbuf)
(setq compilation-last-buffer outbuf)))
(defun compilation-set-window-height (window)
***************
*** 1141,1146 ****
--- 1142,1151 ----
;; jit-lock might fontify some things too late.
(set (make-local-variable 'font-lock-support-mode) nil)
(set (make-local-variable 'font-lock-maximum-size) nil)
+ ;; note that compilation-next-error-function is for interfacing
+ ;; with the next-error function in simple.el, and it's only
+ ;; coincidentally named similarly to compilation-next-error
+ (setq next-error-function 'compilation-next-error-function)
(let ((fld font-lock-defaults))
(if (and minor fld)
(font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
***************
*** 1249,1256 ****
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
(defsubst compilation-buffer-p (buffer)
! (local-variable-p 'compilation-locs buffer))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
--- 1254,1269 ----
(insert-before-markers string)
(run-hooks 'compilation-filter-hook))))))
+ ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p
(defsubst compilation-buffer-p (buffer)
! "Test if BUFFER is a compilation buffer."
! (with-current-buffer buffer
! (compilation-buffer-internal-p)))
!
! ;;; test if a buffer is a compilation buffer, assuming we're in the buffer
! (defsubst compilation-buffer-internal-p ()
! "Test if inside a compilation buffer."
! (local-variable-p 'compilation-locs))
(defmacro compilation-loop (< property-change 1+ error)
`(while (,< n 0)
***************
*** 1319,1343 ****
(interactive "p")
(compilation-next-error (- n)))
- (defun next-error-no-select (n)
- "Move point to the next error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move forwards (or
- backwards, if negative).
- Finds and highlights the source line like \\[next-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error n)
- (pop-to-buffer compilation-last-buffer))
-
- (defun previous-error-no-select (n)
- "Move point to the previous error in the compilation buffer and highlight match.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
- Finds and highlights the source line like \\[previous-error], but does not
- select the source buffer."
- (interactive "p")
- (next-error-no-select (- n)))
-
(defun compilation-next-file (n)
"Move point to the next error for a different file than the current one.
Prefix arg N says how many files to move forwards (or backwards, if negative)."
--- 1332,1337 ----
***************
*** 1379,1429 ****
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (if (and (not other-buffer)
! (compilation-buffer-p (current-buffer)))
! ;; The current buffer is a compilation buffer.
! (current-buffer)
! (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
! (compilation-buffer-p compilation-last-buffer)
! (or (not other-buffer) (not (eq compilation-last-buffer
! (current-buffer)))))
! compilation-last-buffer
! (let ((buffers (buffer-list)))
! (while (and buffers (or (not (compilation-buffer-p (car buffers)))
! (and other-buffer
! (eq (car buffers) (current-buffer)))))
! (setq buffers (cdr buffers)))
! (if buffers
! (car buffers)
! (or (and other-buffer
! (compilation-buffer-p (current-buffer))
! ;; The current buffer is a compilation buffer.
! (progn
! (if other-buffer
! (message "This is the only compilation buffer."))
! (current-buffer)))
! (error "No compilation started!")))))))
;;;###autoload
! (defun next-error (&optional n)
! "Visit next compilation error message and corresponding source code.
! Prefix arg N says how many error messages to move forwards (or
! backwards, if negative).
!
! \\[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.
!
! Once \\[next-error] has chosen the buffer for error messages,
! it stays with that buffer until you use it in some other buffer which
! uses Compilation mode or Compilation Minor mode.
!
! See variable `compilation-error-regexp-alist' for customization ideas."
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
--- 1373,1386 ----
;; Otherwise, look for a compilation buffer and signal an error
;; if there are none.
(defun compilation-find-buffer (&optional other-buffer)
! (next-error-find-buffer other-buffer 'compilation-buffer-internal-p))
;;;###autoload
! (defun compilation-next-error-function (n &optional reset)
(interactive "p")
(set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
+ (when reset
+ (setq compilation-current-error nil))
(let* ((columns compilation-error-screen-columns) ; buffer's local value
(last 1)
(loc (compilation-next-error (or n 1) nil
***************
*** 1469,1495 ****
(setcdr (nthcdr 2 col) `(,(point-marker)))))))))
(compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
(setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
-
- ;;;###autoload (define-key ctl-x-map "`" 'next-error)
-
- (defun previous-error (n)
- "Visit previous compilation error message and corresponding source code.
- Prefix arg N says how many error messages to move backwards (or
- forwards, if negative).
-
- This operates on the output from the \\[compile] and \\[grep] commands."
- (interactive "p")
- (next-error (- n)))
-
- (defun first-error (n)
- "Restart at the first error.
- Visit corresponding source code.
- With prefix arg N, visit the source code of the Nth error.
- This operates on the output from the \\[compile] command."
- (interactive "p")
- (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
- (setq compilation-current-error nil)
- (next-error n))
(defcustom compilation-context-lines next-screen-context-lines
"*Display this many lines of leading context before message."
--- 1426,1431 ----
*** /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004
--- /home/tzz/emacs/mine/replace.el Wed Apr 14 13:53:47 2004
***************
*** 614,619 ****
--- 614,634 ----
"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 reset)
+ "Move to the Nth (default 1) next match in an Occur mode buffer.
+ Compatibility function for \\[next-error] invocations."
+ (interactive "p")
+ (when reset
+ (occur-find-match 0 #'next-single-property-change "No first match"))
+ (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))
+
\f
(defcustom list-matching-lines-default-context-lines 0
"*Default number of context lines included around `list-matching-lines' matches.
***************
*** 800,806 ****
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (display-buffer occur-buf)
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
--- 815,824 ----
(setq occur-revert-arguments (list regexp nlines bufs)
buffer-read-only t)
(if (> count 0)
! (progn
! (display-buffer occur-buf)
! (setq next-error-last-buffer occur-buf)
! (setq next-error-function 'occur-next-error))
(kill-buffer occur-buf)))
(run-hooks 'occur-hook))))
*** /local/share/src/emacs-cvs/lisp/simple.el Fri Mar 26 03:23:15 2004
--- /home/tzz/emacs/mine/simple.el Tue Apr 13 16:59:33 2004
***************
*** 66,71 ****
--- 66,202 ----
(setq list (cdr list)))
(switch-to-buffer found)))
+ ;;; next-error support framework
+ (defvar next-error-last-buffer nil
+ "The most recent next-error buffer.
+ A buffer becomes most recent when its compilation, grep, or
+ similar mode is started, or when it is used with \\[next-error]
+ or \\[compile-goto-error].")
+
+ (defvar next-error-function nil
+ "The next-error vehicle for other modes.
+ This variable can be bound to a function by a mode. It is
+ buffer-local by default. Together with
+ `next-error-last-buffer', this variable lets modes hook into
+ \\[next-error].")
+
+ (make-variable-buffer-local 'next-error-function)
+
+ (defsubst next-error-buffer-p (buffer &optional extra-test)
+ "Test if BUFFER is a next-error capable buffer."
+ (with-current-buffer buffer
+ (or (and extra-test (funcall extra-test))
+ next-error-function)))
+
+ ;; Return a next-error capable buffer.
+ ;; If the current buffer is such, return it.
+ ;; If next-error-last-buffer is set to a live buffer, use that.
+ ;; Otherwise, look for a next-error capable buffer and signal an error
+ ;; if there are none.
+ (defun next-error-find-buffer (&optional other-buffer extra-test)
+ (if (and (not other-buffer)
+ (next-error-buffer-p (current-buffer) extra-test))
+ ;; The current buffer is a next-error capable buffer.
+ (current-buffer)
+ (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
+ (next-error-buffer-p next-error-last-buffer extra-test)
+ (or (not other-buffer) (not (eq next-error-last-buffer
+ (current-buffer)))))
+ next-error-last-buffer
+ (let ((buffers (buffer-list)))
+ (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
+ (and other-buffer
+ (eq (car buffers) (current-buffer)))))
+ (setq buffers (cdr buffers)))
+ (if buffers
+ (car buffers)
+ (or (and other-buffer
+ (next-error-buffer-p (current-buffer) extra-test)
+ ;; The current buffer is a next-error capable buffer.
+ (progn
+ (if other-buffer
+ (message "This is the only next-error capable buffer."))
+ (current-buffer)))
+ (error "No next-error capable buffer found!")))))))
+
+ (defun next-error (argp &optional reset)
+ "Visit next next-error message and corresponding source code.
+
+ If all the error messages parsed so far have been processed already,
+ the message buffer is checked for new ones.
+
+ A prefix ARGP specifies how many error messages to move;
+ negative means move back to previous error messages.
+ Just \\[universal-argument] as a prefix means reparse the error message buffer
+ and start at the first error.
+
+ The RESET argument specifies that we should restart from the beginning
+
+ \\[next-error] normally uses the most recently started
+ compilation, grep, or occur buffer. It can also 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
+ `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
+ uses Compilation mode or Compilation Minor mode.
+
+ See variables `compilation-parse-errors-function' and
+ \`compilation-error-regexp-alist' for customization ideas."
+ (interactive "P")
+ (when (setq next-error-last-buffer (next-error-find-buffer))
+ ;; we know here that next-error-function is a valid symbol we can funcall
+ (with-current-buffer next-error-last-buffer
+ (funcall next-error-function argp reset))))
+
+ (defalias 'goto-next-locus 'next-error)
+ (defalias 'next-match 'next-error)
+
+ (define-key ctl-x-map "`" 'next-error)
+
+ (defun previous-error (n)
+ "Visit previous next-error message and corresponding source code.
+
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+
+ This operates on the output from the \\[compile] and \\[grep] commands."
+ (interactive "p")
+ (next-error (- n)))
+
+ (defun first-error (n)
+ "Restart at the first error.
+ Visit corresponding source code.
+ With prefix arg N, visit the source code of the Nth error.
+ This operates on the output from the \\[compile] command, for instance."
+ (interactive "p")
+ (next-error n t))
+
+ (defun next-error-no-select (n)
+ "Move point to the next error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move forwards (or
+ backwards, if negative).
+ Finds and highlights the source line like \\[next-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error n)
+ (pop-to-buffer (next-error-last-buffer)))
+
+ (defun previous-error-no-select (n)
+ "Move point to the previous error in the next-error buffer and highlight match.
+ Prefix arg N says how many error messages to move backwards (or
+ forwards, if negative).
+ Finds and highlights the source line like \\[previous-error], but does not
+ select the source buffer."
+ (interactive "p")
+ (next-error-no-select (- n)))
+
+ ;;;
+
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
*** /local/share/src/emacs-cvs/etc/NEWS Wed Apr 14 03:23:40 2004
--- /home/tzz/emacs/mine/NEWS Tue Apr 13 17:04:54 2004
***************
*** 14,19 ****
--- 14,27 ----
\f
* Installation Changes in Emacs 21.4
+ ** next-error and previous-error were moved from compile.el to
+ simple.el, and are always loaded. Also, the way that next-error
+ finds the buffer in which to advance has changed; occur-mode uses
+ the new interface.
+
+ ** occur-mode can advance to the next/previous error with next-error
+ and previous-error
+
---
** A Bulgarian translation of the Emacs Tutorial is available.
***************
*** 87,98 ****
\f
* Changes in Emacs 21.4
-
- ** New command line option -Q.
-
- This is like using -q --no-site-file, but in addition it also disables
- the menu-bar, the tool-bar, the scroll-bars, tool tips, the blinking
- cursor, and the fancy startup screen.
** C-h v and C-h f commands now include a hyperlink to the C source for
variables and functions defined in C (if the C source is available).
--- 95,100 ----
*** /local/share/src/emacs-cvs/lisp/ChangeLog Wed Apr 14 03:23:43 2004
--- /home/tzz/emacs/mine/ChangeLog Wed Apr 14 14:06:05 2004
***************
*** 1,28 ****
! 2004-04-14 Daniel Pfeiffer <occitan@esperanto.org>
! * progmodes/compile.el (compilation-setup): Localize
! overlay-arrow-position.
! (compilation-sentinel): Restructure code equivalently.
! (compilation-next-error): Find message on same line after point if
! not found before point.
! (compile-mouse-goto-error): Restore function so that compilation
! buffer need not be current and use compile-goto-error.
! (compile-goto-error): Restore function.
! (next-error): Set overlay-arrow-position.
! (compilation-forget-errors): Don't localize already local
! compilation-locs and remove FIXME about refontifying.
! 2004-04-14 Kim F. Storm <storm@cua.dk>
! * startup.el (emacs-quick-startup): New defvar (set by -Q).
! (command-line): New option -Q. Like -q --no-site-file, but
! in addition it also disables menu-bar, tool-bar, scroll-bars,
! tool-tips, and the blinking cursor.
! (command-line-1): Skip startup screen if -Q.
! (fancy-splash-head): Use :align-to center prop to center splash image.
!
! * emulation/cua-base.el (cua-read-only-cursor-color)
! (cua-overwrite-cursor-color, cua-global-mark-cursor-color): Doc fix.
2004-04-13 Dave Love <fx@gnu.org>
--- 1,27 ----
! 2004-04-14 Teodor Zlatanov <tzz@lifelogs.com>
! * simple.el (next-error-last-buffer, next-error-function): new
! variables for the next-error framework
! (next-error-buffer-p): is a buffer capable of next-error?
! (next-error-find-buffer): the functionality of
! compilation-find-buffer, generalized
! (next-error, previous-error, first-error, next-error-no-select)
! (previous-error-no-select): next-error framework
! * replace.el (occur-next-error, occur-1): support the next-error
! framework
! * compile.el (compilation-start): set next-error-last-buffer so
! next-error knows where to jump
! (compilation-setup): set the buffer-local variable
! next-error-function to 'compilation-next-error-function
! (compilation-buffer-p, compilation-buffer-internal-p): use an
! alternate way to find if a buffer is a compilation buffer, for
! next-error convenience
! (next-error-no-select, previous-error-no-select, next-error)
! (previous-error, first-error): moved to simple.el
! (compilation-find-buffer): functionality moved to
! next-error-find-buffer in simple.el
2004-04-13 Dave Love <fx@gnu.org>
[-- Attachment #4: Type: text/plain, Size: 141 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2004-04-14 17:57 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
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
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
[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-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 [this message]
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=4n4qrmxx14.fsf@lifelogs.com \
--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).