all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "rgb" <rbielaws@i1.net>
Subject: Re: Need help writing file-visiting macro
Date: 25 Jul 2005 10:52:07 -0700	[thread overview]
Message-ID: <1122313927.829340.226930@z14g2000cwz.googlegroups.com> (raw)
In-Reply-To: <dc2r60$o6n$1@panix2.panix.com>

Roy Smith wrote:
> I'm working in a software development system which has classes defined
> in foo.mdl files, with the corresponding implementation code in
> foo_Impl.c files I want to write a macro or function which lets you
> flip back and forth between the two.  If I'm looking at a .mdl file, I
> want it to construct the corresponding _Impl.c filename and visit that
> file.  Is that possible?
>
> I'm using GNU Emacs 21.3.1.

(defun my-open-complementary-file ()
  "If buffer-file-name ends in .h open .mdl and vise versa."
  (interactive)
  (if buffer-file-name
     (if (string-match "\\(\\`.*\\.\\)mdl\\'" (buffer-file-name))
         (find-file (concat (match-string 1 (buffer-file-name))"h"))
       (if (string-match ".*\\.h\\'" (buffer-file-name))
           (find-file (concat (match-string 1
(buffer-file-name))"mdl"))
         (message "Buffer's filename doesn't end in .mdl or .h")))
    (message "Buffer is not visiting a file")))

Don't expect to get this kind of service all the time!

  parent reply	other threads:[~2005-07-25 17:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-25 13:58 Need help writing file-visiting macro Roy Smith
2005-07-25 15:33 ` Thien-Thi Nguyen
2005-07-25 16:45   ` Roy Smith
2005-07-25 17:44     ` drkm
2005-07-25 16:50 ` Sergei Organov
2005-07-25 17:52 ` rgb [this message]
2005-07-25 21:02   ` drkm
2005-07-26 22:49     ` rgb
2005-07-25 18:05 ` Kevin Rodgers
2005-07-25 21:38 ` Martin Slouf
2005-07-26 15:52   ` Kevin Rodgers
2005-07-26 18:24     ` Martin Slouf

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1122313927.829340.226930@z14g2000cwz.googlegroups.com \
    --to=rbielaws@i1.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.