[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need help writing file-visiting macro
From: |
Kevin Rodgers |
Subject: |
Re: Need help writing file-visiting macro |
Date: |
Mon, 25 Jul 2005 12:05:10 -0600 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041105) |
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