[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] follow mode for occur, compilation and diff
From: |
Dan Nicolaescu |
Subject: |
Re: [patch] follow mode for occur, compilation and diff |
Date: |
Sun, 29 Aug 2004 10:21:15 -0700 |
Stefan <address@hidden> writes:
> > + (define-minor-mode next-error-follow-minor-mode
>
> I wouldn't bother with the "-minor".
OK
> What is this for? Toggling is almost never ever used when called from
You're right.
An updated patch is attached. It also contains a patch to grep.el that
was accidentally left out.
Please apply if OK.
Thanks!
2004-08-29 Dan Nicolaescu <address@hidden>
* simple.el (next-error-follow-mode)
(next-error-follow-mode-post-command-hook): New functions.
* diff-mode.el (diff-mode-map): Bind
toggle-next-error-follow-mode.
* progmodes/compile.el (compilation-mode-map): Likewise.
* progmodes/grep.el (grep-mode-map): Likewise.
* replace.el (occur-mode-map): Likewise.
Index: etc/NEWS
===================================================================
RCS file: /cvsroot/emacs/emacs/etc/NEWS,v
retrieving revision 1.1014
diff -c -3 -p -r1.1014 NEWS
*** etc/NEWS 26 Aug 2004 01:47:55 -0000 1.1014
--- etc/NEWS 29 Aug 2004 16:56:09 -0000
*************** The new file etc/compilation.txt gives e
*** 243,248 ****
--- 243,254 ----
Hits are fontified in green, and hits in binary files in orange. Grep buffers
can be saved and automatically revisited with the new Grep mode.
+ ** A new minor mode `next-error-follow-mode' can be used in
+ compilation-mode, grep-mode, occur-mode, and diff-mode (i.e. all the modes
+ that can use `next-error') to associate cursor movements in
+ compilation, grep, occur or diff buffers with cursor movements in the
+ target buffers. This minor mode can be toggled with C-c C-f.
+
** M-x diff uses diff-mode instead of compilation-mode.
** M-x compare-windows now can automatically skip non-matching text to
Index: simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.653
diff -c -3 -p -r1.653 simple.el
*** simple.el 22 Aug 2004 16:59:57 -0000 1.653
--- simple.el 29 Aug 2004 16:56:18 -0000
*************** select the source buffer."
*** 212,217 ****
--- 212,242 ----
(interactive "p")
(next-error-no-select (- n)))
+ ;;; Internal variable for `next-error-follow-mode-post-command-hook'.
+ (defvar next-error-follow-last-line nil)
+
+ (define-minor-mode next-error-follow-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-mode)
+ (remove-hook 'post-command-hook
'next-error-follow-mode-post-command-hook t)
+ (add-hook 'post-command-hook 'next-error-follow-mode-post-command-hook
nil t)
+ (make-variable-buffer-local 'next-error-follow-last-line)))
+
+ ;;; Used as a `post-command-hook' by `next-error-follow-mode'
+ ;;; for the *Compilation* *grep* and *Occur* buffers.
+ (defun next-error-follow-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 fundamental-mode ()
Index: replace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v
retrieving revision 1.187
diff -c -3 -p -r1.187 replace.el
*** replace.el 1 Aug 2004 12:59:09 -0000 1.187
--- replace.el 29 Aug 2004 16:56:18 -0000
*************** end of the buffer."
*** 618,623 ****
--- 618,624 ----
(define-key map "g" 'revert-buffer)
(define-key map "q" 'quit-window)
(define-key map "z" 'kill-this-buffer)
+ (define-key map "\C-c\C-f" 'next-error-follow-mode)
map)
"Keymap for `occur-mode'.")
Index: diff-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/diff-mode.el,v
retrieving revision 1.65
diff -c -3 -p -r1.65 diff-mode.el
*** diff-mode.el 13 Jun 2004 16:49:55 -0000 1.65
--- diff-mode.el 29 Aug 2004 16:56:19 -0000
*************** when editing big diffs)."
*** 139,145 ****
("\C-c\C-r" . diff-refine-hunk)
("\C-c\C-s" . diff-split-hunk)
("\C-c\C-a" . diff-apply-hunk)
! ("\C-c\C-t" . diff-test-hunk))
"Keymap for `diff-mode'. See also `diff-mode-shared-map'.")
(easy-menu-define diff-mode-menu diff-mode-map
--- 139,146 ----
("\C-c\C-r" . diff-refine-hunk)
("\C-c\C-s" . diff-split-hunk)
("\C-c\C-a" . diff-apply-hunk)
! ("\C-c\C-t" . diff-test-hunk)
! ("\C-c\C-f" . next-error-follow-mode))
"Keymap for `diff-mode'. See also `diff-mode-shared-map'.")
(easy-menu-define diff-mode-menu diff-mode-map
Index: progmodes/compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.323
diff -c -3 -p -r1.323 compile.el
*** progmodes/compile.el 16 Aug 2004 22:44:56 -0000 1.323
--- progmodes/compile.el 29 Aug 2004 16:56:19 -0000
*************** exited abnormally with code %d\n"
*** 1052,1057 ****
--- 1052,1058 ----
(set-keymap-parent map compilation-minor-mode-map)
(define-key map " " 'scroll-up)
(define-key map "\^?" 'scroll-down)
+ (define-key map "\C-c\C-f" 'next-error-follow-mode)
;; Set up the menu-bar
(define-key map [menu-bar compilation]
Index: progmodes/grep.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/grep.el,v
retrieving revision 1.19
diff -c -3 -p -r1.19 grep.el
*** progmodes/grep.el 28 Aug 2004 15:31:20 -0000 1.19
--- progmodes/grep.el 29 Aug 2004 16:56:19 -0000
*************** See `compilation-error-screen-columns'"
*** 166,171 ****
--- 166,172 ----
(let ((map (cons 'keymap compilation-minor-mode-map)))
(define-key map " " 'scroll-up)
(define-key map "\^?" 'scroll-down)
+ (define-key map "\C-c\C-f" 'next-error-follow-mode)
;; This is intolerable -- rms
;;; (define-key map [remap next-line] 'compilation-next-error)