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: follow mode for occur Date: Wed, 26 May 2004 17:35:47 -0700 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200405270035.i4R0ZjGK017770@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 1085639409 23881 80.91.224.253 (27 May 2004 06:30:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 27 May 2004 06:30:09 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu May 27 08:30:01 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 1BTEOu-0002OH-00 for ; Thu, 27 May 2004 08:30:00 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BTEOu-0006R1-00 for ; Thu, 27 May 2004 08:30:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BTEDA-00065o-8t for emacs-devel@quimby.gnus.org; Thu, 27 May 2004 02:17:52 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BTC3C-0001LB-IQ for emacs-devel@gnu.org; Wed, 26 May 2004 23:59:26 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BTBli-0006Xp-2j for emacs-devel@gnu.org; Wed, 26 May 2004 23:41:53 -0400 Original-Received: from [128.195.1.36] (helo=scanner2.ics.uci.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BT8sl-0001eh-Pq for emacs-devel@gnu.org; Wed, 26 May 2004 20:36:28 -0400 Original-Received: from vino.ics.uci.edu (vino.ics.uci.edu [128.195.11.198]) by scanner2.ics.uci.edu (8.12.10/8.12.10) with ESMTP id i4R0ZjGK017770 for ; Wed, 26 May 2004 17:35:45 -0700 (PDT) Original-To: emacs-devel@gnu.org Original-Lines: 48 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=-100, required 5, USER_IN_WHITELIST) 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:24001 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24001 The code below implements a follow mode for the *Occur*, this was inspired by `reftex-toc-follow-mode'. Pointer motion in the *Occur* buffer determines motion in the original buffer. This allows one to quickly browse the *Occur* buffer while seeing the corresponding matches in the original buffer. To try this out just evaluate the elisp code below. C-c C-f toggles the follow mode. Is there an interest to have something like this included in Emacs? If there is I can provide a patch acceptable for inclusion. How about implementing something similar for compile.el? I can provide code for that too. Please let me know what do you think about this. Thanks. --dan (defcustom occur-follow-mode t "*Non-nil means that poing motion in the Occur buffer causes the file to follow.") ;;; Internal variable for `occur-mode-post-command-hook'. (defvar occur-follow-last-line nil) ;;; Used as a post-command-hook for the *Occur* buffer. (defun occur-mode-post-command-hook () (when occur-follow-mode (unless (equal occur-follow-last-line (line-number-at-pos)) (setq occur-follow-last-line (line-number-at-pos)) (condition-case nil (occur-mode-display-occurrence) (error t))))) (add-hook 'occur-mode-hook (lambda () (add-hook 'post-command-hook 'occur-mode-post-command-hook))) (defun toggle-occur-follow-mode () (interactive) (setq occur-follow-mode (not occur-follow-mode))) (define-key occur-mode-map "\C-c\C-f" 'toggle-occur-follow-mode)