Friday, May 6, 2011

Is there a way to enable both Objective-C mode and C++-mode at the same time in emacs?

I'm working with some Objective-C++ code (.mm files), and I'm curious if it's possible to get emacs to use proper syntax highlighting for both the Objective-C parts and the C++ parts. objc-mode and c++-mode are both major modes (built on top of cc-mode), so they can't be used at the same time.

Are there any minor modes or elisp hacks available to enable both Objective-C and C++ syntax highlighting at the same time?

From stackoverflow
  • I have not done this myself, but since all those modes are based around cc-mode it seems as though you could get the source code for objc-mode styles and c++-mode and combine them.

    Another possibility would be to try out an alternate objc-mode that it supposed to be more advanced, perhaps it would better take c++ into account:

    http://www.foldr.org/~michaelw/objective-c/

    (scroll to the end and look for obj-c-mode.el)

  • Here's a page that has information about running multiple major modes. As far as I know it's mostly used for doing web-type stuff where you might have several different languages in a single document, but It could probably work for others as well.

0 comments:

Post a Comment