From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: follow mode for occur Date: Fri, 4 Jun 2004 11:41:18 -0700 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200406041841.i54IfIU5017651@amrm2.ics.uci.edu> References: <200405270035.i4R0ZjGK017770@scanner2.ics.uci.edu> <877juxlyz3.fsf@mail.jurta.org> <200405281856.i4SIufGK022679@scanner2.ics.uci.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1086376418 14249 80.91.224.253 (4 Jun 2004 19:13:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 4 Jun 2004 19:13:38 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jun 04 21:13:31 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BWK8B-00035W-00 for ; Fri, 04 Jun 2004 21:13:31 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BWK8B-0003jL-00 for ; Fri, 04 Jun 2004 21:13:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BWK8a-0007zZ-5K for emacs-devel@quimby.gnus.org; Fri, 04 Jun 2004 15:13:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BWK8T-0007zJ-LB for emacs-devel@gnu.org; Fri, 04 Jun 2004 15:13:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BWK8T-0007z7-1U for emacs-devel@gnu.org; Fri, 04 Jun 2004 15:13:49 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BWK8S-0007z4-Vj for emacs-devel@gnu.org; Fri, 04 Jun 2004 15:13:49 -0400 Original-Received: from [128.195.11.175] (helo=amrm2.ics.uci.edu) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BWK7y-00037K-Oz for emacs-devel@gnu.org; Fri, 04 Jun 2004 15:13:19 -0400 Original-Received: from amrm2.ics.uci.edu (amrm2 [127.0.0.1]) by amrm2.ics.uci.edu (8.12.11/8.12.11) with ESMTP id i54JBcqc018294 for ; Fri, 4 Jun 2004 12:12:01 -0700 Original-Received: (from dann@localhost) by amrm2.ics.uci.edu (8.12.11/8.12.10/Submit) id i54IfIU5017651; Fri, 4 Jun 2004 11:41:18 -0700 Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:YQhV5Y0riw+BbTzm2jwJUSZp8l0= In-Reply-To: <200405281856.i4SIufGK022679@scanner2.ics.uci.edu> (Dan Nicolaescu's message of "Fri, 28 May 2004 11:56:43 -0700") Original-Lines: 63 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:24542 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24542 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)