I'm running Emacs 23.3.1 (Ubuntu, Oneiric package) and emacs doesn't appear to understand any of the new C++11 keywords, constexpr, thread_local, etc. Also it doesn't understand that '>>' is now permitted in template parameters, or the new 'enum class' syntax. Is there an updated or alternative module somewhere? Or failing that, some settings to make emacs more C++11 friendly in the mean time?
相关问题
- Sorting 3 numbers without branching [closed]
- Symbol's function definition is void: declare-
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- ess-rdired: I get this error “no ESS process is as
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
Have a look at the package : "Modern C++" font-lock for Emacs. It is also available on Melpa.
I am the maintainer of this minor mode. Any feedback is appreciated.
Replacing Andreas' floating point regexp with this will improve hilighting of floats.
Hope that helps someone.
For me, the two most pressing pain points with font-locking of modern C++ code have been
auto
is highlighted as a keyword (and not a type) and thus the following identifier would normally not higlight as a variable declaration, andsrc/ClangIndexer.cpp
) and then e.g fails to highlight top-level constructs such as function definitions.After a bit of experimentation, I arrived at a solution that works well for me and addresses both points.
The first one is achieved by modifying
lisp/progmodes/cc-langs.el
(copying to one'sload-path
and then modifying also works) to remove"auto"
fromand add it to
c++-font-lock-extra-types
(e.g. via Customize).For the second one, emptying
c++-font-lock-extra-types
(except for keeping"auto"
) helps.Well, I'm using 24.1. Some C++98 keywords are missing, and all new C++11 keywords. It does not even fontify number constants. It seems as if c++-mode hasn't been updated for a decade.
I'm using the following code for a long time now, and recently added C++11 keywords. Try putting it in your .emacs; it should fill some holes.
Hope this helps.
I've checked trunk version,
cc-mode
hasn't been updated yet, and AFAIK there's no alternative. If you really want it, but don't want to get your hands dirty, you should pay someone to implement it for you...According to a request by Mike Weller here an updated version for C++11 strings literals (incl. user-defined literals).
In the above implementation of user-defined strings literals, the delimiter tags are marked up separately as
font-lock-keyword-face
; another option would befont-lock-constant-face
. This implementation is not as efficient as it could be; but it works and does not slow down Emacs. Note that the regexps for user-defined strings literals have not been "stolen" from somehere; so I hope they work. Any comments are welcome.If you like to fontify the whole literal string as
font-lock-string-face
- including the delimiters - replace the three regexps by just one. Like this one:Have fun.