unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Need help writing file-visiting macro
Date: Mon, 25 Jul 2005 12:05:10 -0600	[thread overview]
Message-ID: <dc39kn$gib$1@sea.gmane.org> (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?

Of course.

(defun find-impl-file (&optional mdl-file)
   "When visiting a \".mdl\", visit the corresponding \"_Impl.c\" file."
   (interactive)
   (when (null mdl-file)
     (setq mdl-file buffer-file-name))
   (unless (and mdl-file (equal (file-name-extension mdl-file) "mdl"))
     (error "%s is not a \".mdl\" file" mdl-file))
   (find-file (concat (file-name-sans-extension mdl-file) "_Impl.c")))

-- 
Kevin Rodgers

  parent reply	other threads:[~2005-07-25 18:05 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
2005-07-25 21:02   ` drkm
2005-07-26 22:49     ` rgb
2005-07-25 18:05 ` Kevin Rodgers [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='dc39kn$gib$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /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.
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).