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: Thu, 15 Apr 2004 14:43:24 -0400 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: <4n65c1ccab.fsf@b2-25-3.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> <4n8yjcccvj.fsf@collins.bwh.harvard.edu> <4nwu6sp7ni.fsf@collins.bwh.harvard.edu> Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BEC5C-0008HP-00 for ; Thu, 15 Apr 2004 20:59:30 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BEC5B-0008Ol-00 for ; Thu, 15 Apr 2004 20:59:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BEBwz-0000Gn-SF for emacs-devel@quimby.gnus.org; Thu, 15 Apr 2004 14:51:01 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BEBog-00065h-N0 for emacs-devel@gnu.org; Thu, 15 Apr 2004 14:42:26 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BEBo2-0005sR-V9 for emacs-devel@gnu.org; Thu, 15 Apr 2004 14:42:18 -0400 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BEBo1-0005rV-C5 for emacs-devel@gnu.org; Thu, 15 Apr 2004 14:41:45 -0400 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1BEBo0-0005dQ-00 for ; Thu, 15 Apr 2004 20:41:44 +0200 Original-Received: from b2-25-3.bwh.harvard.edu ([134.174.54.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Apr 2004 20:41:44 +0200 Original-Received: from tzz by b2-25-3.bwh.harvard.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Apr 2004 20:41:44 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 921 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: b2-25-3.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 (usg-unix-v) Cancel-Lock: sha1:oWgfQPPI9CF4I3VYTqxjwQF9izg= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 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:21712 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21712 --=-=-= On Thu, 15 Apr 2004, rms@gnu.org wrote: > * Installation Changes in Emacs 21.4 > + ** next-error and previous-error were moved from compile.el to... > > That is internal, not worth mentioning in NEWS. > > + ** occur-mode can advance to the next/previous error with next-error > + and previous-error > > That is the feature worth mentioning. It should be in the following > section, "Changes in Emacs 21.4", not in the Installation Changes > section. Both changes were done. Latest patch attached. Ted --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=next-error.patch --- /local/share/src/emacs-cvs/lisp/progmodes/compile.el Thu Apr 15 03:23:34 2004 +++ /home/tzz/emacs/mine/compile.el Thu Apr 15 11:54:19 2004 @@ -125,11 +125,6 @@ Each function is called with two arguments: the compilation buffer, and a string describing how the process finished.") -(defvar compilation-last-buffer nil - "The most recent compilation buffer. -A buffer becomes most recent when its compilation is started -or when it is used with \\[next-error] or \\[compile-goto-error].") - (defvar compilation-in-progress nil "List of compilation processes now running.") (or (assq 'compilation-in-progress minor-mode-alist) @@ -950,7 +945,7 @@ (select-window outwin) (goto-char (point-max)))) ;; Make it so the next C-x ` will use this buffer. - (setq compilation-last-buffer outbuf))) + (setq next-error-last-buffer outbuf))) (defun compilation-set-window-height (window) "Set the height of WINDOW according to `compilation-window-height'." @@ -1081,6 +1076,10 @@ (set (make-local-variable 'page-delimiter) compilation-page-delimiter) (compilation-setup) + ;; 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) (run-mode-hooks 'compilation-mode-hook)) (defmacro define-compilation-mode (mode name doc &rest body) @@ -1140,7 +1139,6 @@ (make-local-variable 'compilation-current-error) (make-local-variable 'compilation-error-screen-columns) (make-local-variable 'overlay-arrow-position) - (setq compilation-last-buffer (current-buffer)) (set (make-local-variable 'font-lock-extra-managed-props) '(directory message help-echo mouse-face debug)) (set (make-local-variable 'compilation-locs) @@ -1257,8 +1255,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) @@ -1289,7 +1295,6 @@ (or (compilation-buffer-p (current-buffer)) (error "Not in a compilation buffer")) (or pt (setq pt (point))) - (setq compilation-last-buffer (current-buffer)) (let* ((msg (get-text-property pt 'message)) (loc (car msg)) last) @@ -1327,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)." @@ -1383,55 +1369,17 @@ ;; Return a compilation buffer. ;; If the current buffer is a compilation buffer, return it. -;; If compilation-last-buffer is set to a live buffer, use that. ;; 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))) + (set-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 @@ -1477,27 +1425,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 Thu Apr 15 11:38:08 2004 @@ -538,6 +538,7 @@ (set (make-local-variable 'revert-buffer-function) 'occur-revert-function) (make-local-variable 'occur-revert-arguments) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) + (setq next-error-function 'occur-next-error) (run-hooks 'occur-mode-hook)) (defun occur-revert-function (ignore1 ignore2) @@ -614,6 +615,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)) + (defcustom list-matching-lines-default-context-lines 0 "*Default number of context lines included around `list-matching-lines' matches. @@ -800,7 +816,9 @@ (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)) (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 Thu Apr 15 14:25:18 2004 @@ -88,6 +88,9 @@ * Changes in Emacs 21.4 +** occur-mode can advance to the next/previous error with next-error + and previous-error + ** New command line option -Q. This is like using -q --no-site-file, but in addition it also disables --- /local/share/src/emacs-cvs/lisp/ChangeLog Thu Apr 15 03:23:30 2004 +++ /home/tzz/emacs/mine/ChangeLog Thu Apr 15 11:50:15 2004 @@ -1,3 +1,32 @@ +2004-04-15 Teodor Zlatanov + + * 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 + (compilation-last-buffer): removed + (compilation-start, compilation-next-error, compilation-setup) + (compilation-next-error-function, compilation-find-buffer): + remove compilation-last-buffer use + 2004-04-14 Stefan Monnier * emacs-lisp/bytecomp.el (batch-byte-compile-file): --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=next-error.patch2 Content-Description: context patch for RMS *** /local/share/src/emacs-cvs/lisp/progmodes/compile.el Thu Apr 15 03:23:34 2004 --- /home/tzz/emacs/mine/compile.el Thu Apr 15 11:54:19 2004 *************** *** 125,135 **** Each function is called with two arguments: the compilation buffer, and a string describing how the process finished.") - (defvar compilation-last-buffer nil - "The most recent compilation buffer. - A buffer becomes most recent when its compilation is started - or when it is used with \\[next-error] or \\[compile-goto-error].") - (defvar compilation-in-progress nil "List of compilation processes now running.") (or (assq 'compilation-in-progress minor-mode-alist) --- 125,130 ---- *************** *** 950,956 **** (select-window outwin) (goto-char (point-max)))) ;; Make it so the next C-x ` will use this buffer. ! (setq compilation-last-buffer outbuf))) (defun compilation-set-window-height (window) "Set the height of WINDOW according to `compilation-window-height'." --- 945,951 ---- (select-window outwin) (goto-char (point-max)))) ;; Make it so the next C-x ` will use this buffer. ! (setq next-error-last-buffer outbuf))) (defun compilation-set-window-height (window) "Set the height of WINDOW according to `compilation-window-height'." *************** *** 1081,1086 **** --- 1076,1085 ---- (set (make-local-variable 'page-delimiter) compilation-page-delimiter) (compilation-setup) + ;; 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) (run-mode-hooks 'compilation-mode-hook)) (defmacro define-compilation-mode (mode name doc &rest body) *************** *** 1140,1146 **** (make-local-variable 'compilation-current-error) (make-local-variable 'compilation-error-screen-columns) (make-local-variable 'overlay-arrow-position) - (setq compilation-last-buffer (current-buffer)) (set (make-local-variable 'font-lock-extra-managed-props) '(directory message help-echo mouse-face debug)) (set (make-local-variable 'compilation-locs) --- 1139,1144 ---- *************** *** 1257,1264 **** (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) --- 1255,1270 ---- (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) *************** *** 1289,1295 **** (or (compilation-buffer-p (current-buffer)) (error "Not in a compilation buffer")) (or pt (setq pt (point))) - (setq compilation-last-buffer (current-buffer)) (let* ((msg (get-text-property pt 'message)) (loc (car msg)) last) --- 1295,1300 ---- *************** *** 1327,1351 **** (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 ---- *************** *** 1383,1437 **** ;; Return a compilation buffer. ;; If the current buffer is a compilation buffer, return it. - ;; If compilation-last-buffer is set to a live buffer, use that. ;; 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 --- 1369,1385 ---- ;; Return a compilation buffer. ;; If the current buffer is a compilation buffer, return it. ;; 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 (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 *************** *** 1477,1503 **** (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." --- 1425,1430 ---- *** /local/share/src/emacs-cvs/lisp/replace.el Sun Apr 11 03:24:23 2004 --- /home/tzz/emacs/mine/replace.el Thu Apr 15 11:38:08 2004 *************** *** 538,543 **** --- 538,544 ---- (set (make-local-variable 'revert-buffer-function) 'occur-revert-function) (make-local-variable 'occur-revert-arguments) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) + (setq next-error-function 'occur-next-error) (run-hooks 'occur-mode-hook)) (defun occur-revert-function (ignore1 ignore2) *************** *** 614,619 **** --- 615,635 ---- "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)) + (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)))) --- 816,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)) (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 Thu Apr 15 14:25:18 2004 *************** *** 88,93 **** --- 88,96 ---- * Changes in Emacs 21.4 + ** occur-mode can advance to the next/previous error with next-error + and previous-error + ** New command line option -Q. This is like using -q --no-site-file, but in addition it also disables *** /local/share/src/emacs-cvs/lisp/ChangeLog Thu Apr 15 03:23:30 2004 --- /home/tzz/emacs/mine/ChangeLog Thu Apr 15 11:50:15 2004 *************** *** 1,3 **** --- 1,32 ---- + 2004-04-15 Teodor Zlatanov + + * 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 + (compilation-last-buffer): removed + (compilation-start, compilation-next-error, compilation-setup) + (compilation-next-error-function, compilation-find-buffer): + remove compilation-last-buffer use + 2004-04-14 Stefan Monnier * emacs-lisp/bytecomp.el (batch-byte-compile-file): --=-=-= 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 --=-=-=--