unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* follow mode for occur
@ 2004-05-27  0:35 Dan Nicolaescu
  2004-05-27 15:16 ` Sun Yi Ming
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Dan Nicolaescu @ 2004-05-27  0:35 UTC (permalink / raw)



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)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-06-05 11:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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).