[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: naming convention based file toggling facility
From: |
Masatake YAMATO |
Subject: |
Re: naming convention based file toggling facility |
Date: |
Fri, 26 Sep 2003 15:03:36 +0900 (JST) |
> > I've had a hackish little elisp function for years that always struck me
> > as a slightly surprising omission from emacs: the ability to toggle
> > between files based on a naming convention like: <source>.c and
> > <source>.h.
>
> M-x ff-find-other-file may be useful.
>
> If this does the job, maybe CC mode should provide bindings and menu
> bar entrie for it--or for some other clean interface to it.
ff-find-other-file is useful particularly in c-mode and c++-mode.
However it may be useful in other modes.
e.g. moving between *gud* buffer and .gdbinit.
Next patch is prosaic but it works.
Masatake YAMATO
Index: lisp/bindings.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.123
diff -u -r1.123 bindings.el
--- lisp/bindings.el 8 Sep 2003 08:02:45 -0000 1.123
+++ lisp/bindings.el 26 Sep 2003 05:56:23 -0000
@@ -371,6 +371,13 @@
(interactive)
(switch-to-buffer (other-buffer)))
+(defun mode-line-ff-other-file (event) "\
+Find the header or source file corresponding to the current buffer."
+ (interactive "e")
+ (save-selected-window
+ (select-window (posn-window (event-start event)))
+ (ff-find-the-other-file)))
+
(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
Menu of mode operations in the mode line.")
@@ -449,6 +456,7 @@
(define-key map [mode-line mouse-3] 'mode-line-bury-buffer)
(define-key map [header-line down-mouse-3] 'ignore)
(define-key map [header-line mouse-3] 'mode-line-bury-buffer)
+ (define-key map [mode-line mouse-2] 'mode-line-ff-other-file)
(setq mode-line-buffer-identification-keymap map))
(defun propertized-buffer-identification (fmt)
@@ -458,7 +466,7 @@
(list (propertize fmt
'face '(:weight bold)
'help-echo
- (purecopy "mouse-1: previous buffer, mouse-3: next buffer")
+ (purecopy "mouse-1: previous buffer, mouse-2: find related
file, mouse-3: next buffer")
'local-map mode-line-buffer-identification-keymap)))
(setq-default mode-line-buffer-identification