unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Eglen <stephen@anc.ed.ac.uk>
Cc: emacs-devel@gnu.org
Subject: follow mode for occur
Date: Fri, 28 May 2004 13:44:55 +0100	[thread overview]
Message-ID: <16567.13383.354832.50770@bushmills.inf.ed.ac.uk> (raw)
In-Reply-To: <200405270035.i4R0ZjGK017770@scanner2.ics.uci.edu>

 > 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. 
 > 
A few years ago, I too wrote a "follow mode" based on the reftex
code.  You can get it from:
 http://www.anc.ed.ac.uk/~stephen/emacs/fm.el

Best wishes,
Stephen
[relevant doc appended below]

;;; Commentary:

;; As you move through the lines of an output buffer (such as from
;; `grep' or `occur'), another window highlights the corresponding
;; line of the source buffer.

;; This is inspired by the table of contents code from reftex.el.
;; http://www.strw.leidenuniv.nl/~dominik/Tools/

;;; Installation
;; To use the mode, do M-x fm-start in the output buffer.  Or just add
;; it to the mode hooks, e.g.:
;; (add-hook 'occur-mode-hook 'fm-start)
;; (add-hook 'compilation-mode-hook 'fm-start)
;; 

;;; Examples:
;;  
;; Do an occur for the word `package' in the NEWS file:
;; C-h n
;; M-x occur RTN package RTN

;; or test it on the current file:
;; (grep "grep -n 'def' fm.el")
;; (occur "def")

;; Once following is activated in a buffer, it can be toggled with the
;; "f" key in that buffer.

;; To extend this code to handle other types of output buffer, you
;; need to add an entry to the alist `fm-modes'.

;; If you want to use fm in a buffer that doesn't have a useful major
;; mode, you can always set the value of fm-defun yourself.  For
;; example, the cscope buffer is in fundamental mode, so in this case
;; we set fm-defun as a local variable to be the defun to use for
;; visiting the corresponding line of the source buffer.

(add-hook 'cscope-query-hook 'cscope-run-fm)

(defun cscope-run-fm ()
  "Run cscope in the fm buffer."
  (set (make-local-variable 'fm-defun) '(cscope-interpret-output-line))
  (fm-start))

;; If you are using this in the compile mode, you may find it easier
;; to use the key M-p to go to the previous error.  Otherwise, you may
;; find that if you go up one line, and this line doesn't have an
;; error on it, it goes down one line again, taking you back where you
;; started!

      parent reply	other threads:[~2004-05-28 12:44 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
2004-06-04 19:18       ` David Kastrup
2004-06-05 11:56       ` Robert J. Chassell
2004-05-28 12:44 ` Stephen Eglen [this message]

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=16567.13383.354832.50770@bushmills.inf.ed.ac.uk \
    --to=stephen@anc.ed.ac.uk \
    --cc=emacs-devel@gnu.org \
    /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).