unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
Subject: Re: follow mode for occur
Date: Fri, 4 Jun 2004 11:41:18 -0700	[thread overview]
Message-ID: <200406041841.i54IfIU5017651@amrm2.ics.uci.edu> (raw)
In-Reply-To: <200405281856.i4SIufGK022679@scanner2.ics.uci.edu> (Dan Nicolaescu's message of "Fri, 28 May 2004 11:56:43 -0700")


Here is a new incarnation of this code. It is a minor mode now. 
It works with very well occur, compile, grep and diff-mode. 
It is _not_ turned on by default.

Now there's the question of defaults. 

Should this mode be on by default? 
IMVHO it would be nice to have it on by default at least in  occur-mode
and diff-mode. 

How should it be turned on? Using a menu entry? 

Feedback would be appreciated. 

;;; Internal variable for `next-error-minor-mode-post-command-hook'.
(defvar next-error-follow-last-line nil)

;;;###autoload
(define-minor-mode next-error-follow-minor-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-minor-mode)
      (remove-hook 'post-command-hook 'next-error-minor-mode-post-command-hook t)
    (add-hook 'post-command-hook 'next-error-minor-mode-post-command-hook nil t)
    (make-variable-buffer-local 'next-error-follow-last-line) 
    ))

;;; Used as a post-command-hook for the *Compilation* *grep* 
;;; and *Occur* buffers.
(defun next-error-minor-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))))

(defun toggle-next-error-follow-mode ()
  (interactive)
  (next-error-follow-minor-mode (not next-error-follow-minor-mode)))

;;; All this stuff will be put in the corresponding files: compile.el
;;; grep.el diff-mode.el and simple.el

;;; FIXME: Should there be a menu entry for the toggle? 
(eval-after-load "compile"
  '(define-key compilation-mode-map "\C-c\C-f" 'toggle-next-error-follow-mode))

(eval-after-load "grep"
  '(define-key grep-mode-map "\C-c\C-f" 'toggle-next-error-follow-mode))


(eval-after-load "diff-mode"
  '(define-key diff-mode-map "\C-c\C-f" 'toggle-next-error-follow-mode))


(define-key occur-mode-map "\C-c\C-f" 'toggle-next-error-follow-mode)

  reply	other threads:[~2004-06-04 18:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-27  0:35 follow mode for occur Dan Nicolaescu
2004-05-27 15:16 ` Sun Yi Ming
2004-05-27 16:48   ` Dan Nicolaescu
2004-05-28  8:43     ` Emacs-devel list IS slow [was Re: follow mode for occur] Kim F. Storm
2004-05-29 14:16       ` Eli Zaretskii
2004-05-28 10:37     ` follow mode for occur Sun Yi Ming
2004-05-28  8:47 ` Juri Linkov
2004-05-28 18:56   ` Dan Nicolaescu
2004-06-04 18:41     ` Dan Nicolaescu [this message]
2004-06-04 19:18       ` David Kastrup
2004-06-05 11:56       ` Robert J. Chassell
2004-05-28 12:44 ` Stephen Eglen

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=200406041841.i54IfIU5017651@amrm2.ics.uci.edu \
    --to=dann@ics.uci.edu \
    /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).