aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2004-09-04 12:45:26 +0000
committerEli Zaretskii <[email protected]>2004-09-04 12:45:26 +0000
commit282d6eaec09020e5923c15baf000d20565093716 (patch)
tree0de7865dd1b67a7e6a44873b34e9c124e7716dde /lisp/simple.el
parentf5e9cb97050fc4591f2cb7f269665bfcaba1faf6 (diff)
(next-error-follow-mode, next-error-follow-mode-post-command-hook):
New functions. (next-error-follow-last-line): New defvar.
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 271a07ee53..edf94cfd7d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -249,6 +249,32 @@ If `fringe-arrow', indicate the locus by the fringe arrow."
(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))))
+
;;;