changeset 56918:2e166bd5683b

(next-error-follow-mode, next-error-follow-mode-post-command-hook): New functions. (next-error-follow-last-line): New defvar.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 04 Sep 2004 12:45:26 +0000
parents 0827d2cd1a66
children 34b22fc9d0ed
files lisp/simple.el
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Sat Sep 04 12:35:28 2004 +0000
+++ b/lisp/simple.el	Sat Sep 04 12:45:26 2004 +0000
@@ -249,6 +249,32 @@
                  (const :tag "Fringe arrow" 'fringe-arrow))
   :group 'next-error
   :version "21.4")
+
+;;; Internal variable for `next-error-follow-mode-post-command-hook'.
+(defvar next-error-follow-last-line nil)
+
+(define-minor-mode next-error-follow-mode
+  "Minor mode for compilation, occur and diff modes.
+When turned on, cursor motion in the compilation, occur or diff
+buffer determines the cursor in the corresponding buffer to move
+to the corresponding position.  "
+  nil " Fol" nil
+  (if (not next-error-follow-mode)
+      (remove-hook 'post-command-hook 'next-error-follow-mode-post-command-hook t)
+    (add-hook 'post-command-hook 'next-error-follow-mode-post-command-hook nil t)
+    (make-variable-buffer-local 'next-error-follow-last-line)))
+
+;;; Used as a `post-command-hook' by `next-error-follow-mode'
+;;; for the *Compilation* *grep* and *Occur* buffers.
+(defun next-error-follow-mode-post-command-hook ()
+  (unless (equal next-error-follow-last-line (line-number-at-pos))
+    (setq next-error-follow-last-line (line-number-at-pos))
+    (condition-case nil
+	(let ((compilation-context-lines nil))
+	  (setq compilation-current-error (point))
+	  (next-error-no-select 0))
+      (error t))))
+
 
 ;;;