From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: naming convention based file toggling facility Date: Fri, 26 Sep 2003 15:03:36 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20030926.150336.173372132.jet@gyve.org> References: <1064473652.1354.41.camel@lan1> <20030925.162042.198212664.jet@gyve.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1064556339 1477 80.91.224.253 (26 Sep 2003 06:05:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 26 Sep 2003 06:05:39 +0000 (UTC) Cc: bug-cc-mode@gnu.org, rwa@alumni.princeton.edu, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Sep 26 08:05:37 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A2ljV-00047v-00 for ; Fri, 26 Sep 2003 08:05:37 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1A2lr0-0005F4-00 for ; Fri, 26 Sep 2003 08:13:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A2liz-0006IG-WA for emacs-devel@quimby.gnus.org; Fri, 26 Sep 2003 02:05:06 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 1A2lie-0006Hd-GA for emacs-devel@gnu.org; Fri, 26 Sep 2003 02:04:44 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 1A2lic-0006Gs-T6 for emacs-devel@gnu.org; Fri, 26 Sep 2003 02:04:43 -0400 Original-Received: from [210.130.136.40] (helo=r-maa.spacetown.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A2lhb-0006BY-Ms; Fri, 26 Sep 2003 02:03:39 -0400 Original-Received: from localhost (mx.jp.redhat.com [219.96.218.186]) by r-maa.spacetown.ne.jp (8.11.6) with ESMTP id h8Q63ba01047; Fri, 26 Sep 2003 15:03:37 +0900 (JST) Original-To: rms@gnu.org In-Reply-To: X-Mailer: Mew version 3.1.52 on Emacs 21.3 / Mule 5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 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:16660 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:16660 > > 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: .c and > > .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