Emacs: ff-find-other-file

For quite some time I was using some code I wrote (based on another author) to toggle between header and implementation files for c and c++ when in emacs. Today I learned that feature already is in emacs and so my code isn’t needed. The wonderful function is ff-find-other-file. This thing is sort of a mind reader. If you call it in a header file it will open the corresponding implementation file. If you call it in an implementation file it will open the corresponding header file. It gets better! If you call it while on a #include line it will open that include file by searching the directories in cc-search-directories.

Advertisements
This entry was posted in Geek, Tips. Bookmark the permalink.

One Response to Emacs: ff-find-other-file

  1. motonari says:

    Thank you, it helped me a lot, because the original toggle-source.el is not available anymore for some reason.

    I also found how to define the header and implementation filename rule. Just in case it might help other people…

    (setq cc-other-file-alist
    ‘((“\.cpp$” (“.hpp” “.h”))
    (“\.h$” (“.c” “.cpp”))
    (“\.hpp$” (“.cpp” “.c”))
    ))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s