ludwigpacifici / modern-cpp-font-lock Goto Github PK
View Code? Open in Web Editor NEWC++ font-lock for Emacs
Home Page: https://melpa.org/#/modern-cpp-font-lock
License: GNU General Public License v3.0
C++ font-lock for Emacs
Home Page: https://melpa.org/#/modern-cpp-font-lock
License: GNU General Public License v3.0
std::string empty = R"EOF({
"test1": {},
"test2": [],
"test3": [],
"test4": []
}
)EOF";
The line above did not appear correctly.
Installed version: 20180110.1231
The documentation suggests that raw strings should be properly highlighted, but this does not seem to work. To reproduce this, I started from a completely clean .emacs file and then ran:
(package-initialize)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-refresh-contents)
(package-install 'modern-cpp-font-lock)
(modern-c++-font-lock-global-mode t)
I then opened a new C++ file, verified that modern-c++-string-literal
was indeed t
, but unfortunately still do not get proper highlighting:
The regexs here seem to work once you apply the correction from the comments, so something like:
(font-lock-add-keywords
nil
'(
("\\(\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\)" 1 font-lock-keyword-face t) ; start delimiter
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\([[:ascii:][:nonascii:]]*?\\))[^\\s-\\\\()]\\{0,16\\}\"" 1 font-lock-string-face t) ; actual string
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}([[:ascii:][:nonascii:]]*?\\()[^\\s-\\\\()]\\{0,16\\}\"\\)" 1 font-lock-keyword-face t) ; end delimiter
))
Thanks for this package. Could you add the concept
keyword at your convenience? Thank you
I'm using stock Ubuntu 18.04, which has this version of emacs. When I do the following:
M-x package-install [RET] modern-cpp-font-lock [RET]
I get this in the Messages buffer.
Contacting host: melpa.org:80
package-install-from-archive: http://melpa.org/packages/modern-cpp-font-lock-20180110.2031.el: Not found
Highlighting template parameters have been one thing that have never worked consistently for me in emacs. I tried installing modern-cpp-font-lock
, but I'm still getting the following hightlighting:
The template paramters Features
and Model
are not hightlighted, but above State
is.
Any ideas for how to fix this?
Compiling file /home/[[redacted]]/.emacs.d/elpa/modern-cpp-font-lock-20160527.1440/modern-cpp-font-lock.el at Wed Jun 1 11:43:53 2016
modern-cpp-font-lock.el:129:188:Error: Symbol's function definition is void: modern-c++-string-lenght>
The Github repository seems to have commits after the Melpa date, so I'm not sure if this is still current.
From c++ 17, if constexpr
statement is introduced but its indentation looks collapsed like this.
if constexpr (true) {
f();
}
Maybe your mode does not support indentation. I wonder if you have any solution for this problem (adding keywords or something).
Raw string literal isn't handled correctly (especially with embedded double quote character). Example:
int main(int argc, char** argv) {
std::cout << R"(foo"bar)" << std::endl; // "(foo" is highlighted as string, plus everything after )"
std::cout << R"foo(foo"bar)foo" << std::endl; // everything up to R" is highlighted, and "bar)foo"
return 0;
}
Using emacs version 25.3.1.
When I give a function an attribute, the function name is no longer fontified.
When I write a function:
int myfunction() { /*...*/ }
it is fontified correctly. But if I add any attribute:
[[nodiscard]] int myfunction() { /*...*/ }
the function name myfunction
is now just the default text color. This happens with multiple
I'm using stock Ubuntu 18.04. I creates a simple setup without any of my init, and I cannot get the color of this small c++ program to work correctly.
#include <string>
std::string a = R"raw(Hi there I'm a Qoute " guy)raw";
int main(){}
Everything after the end double quote on line 2 is colored as if it were inside a string. It does not seem to recognize the double quote before guy as being inside the string.
I'm running emacs like this:
emacs -q --load testinit.el
the contents of my init file (testinit.el) are:
(add-to-list 'load-path "/home/mat/tmp/cppfl/modern-cpp-font-lock")
(require 'modern-cpp-font-lock)
(modern-c++-font-lock-global-mode t)
I've cloned a copy or your repo here, at revision 02f1047. The test directory, /home/mat/tmp/cppfl, looks like:
a.out
modern-cpp-font-lock/
t.cpp
t.cpp~
testinit.el
I'm on emacs 25.2.2.
I am opening this issue after seeing the reddit post below. https://www.reddit.com/r/emacs/comments/94j39z/modern_c_font_lock_in_emacs/
Could you make the effort and email the emacs mailing list for your plugin to be included in the Emacs core?
Any plans for ObjC(++)
as well (because based on same libClang
?
constexpr auto operator""m(unsigned long long l) { return quantity<metre, std::int64_t>(l); }
which is trying to define a UDL in this library
Example code:
void f() { aut s = R"EOF("a)EOF"; }
If I set fundamental-mode and enable modern-c++-font-lock-mode then the raw string is highlighted perfectly so the modern fontifying is working. However if I set c++-mode then modern-c++-font-lock-mode then it is highlighted the old C++ way - it looks like the built-in c++ fontification is over-riding the modern rules.
To reduce uncertainty I ran this with emacs --no-init so no other ealpa packages are loaded:
(load-library "~/.emacs.d/elpa/modern-cpp-font-lock-0.1.3/modern-cpp-font-lock.el")
Using CC Mode version 5.32.99
GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.26) of 2018-01-12
I can try to debug this but I'd like some hints where to look. I'm familar with elisp programming but not the font-lock stuff specifically.
Hi Ludwig, I'm back again!
I just saw this thread Andersbakken/rtags#677 and am really curious to know if there has been any progress to integrate modern-cpp-font-lock
and rtags
. This would be a fantastic feature!
It can be reproduced using the following init.el
with emacs -Q -l init.el
.
(require 'package)
(setq package-archives
'(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(package-initialize)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(use-package modern-cpp-font-lock
:ensure t
:hook (c++-mode . modern-c++-font-lock-mode))
(provide 'init)
emacs --version
GNU Emacs 28.0.50
Copyright (C) 2020 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
cc-mode version
;; Version: 5.33.1
After reading the source, it seems like a feature but a bug.
https://github.com/ludwigpacifici/modern-cpp-font-lock/blob/master/modern-cpp-font-lock.el#L186
The function declarations below highlight ABC as a function variable instead of a type
void foo(std::string&, ABC);
void foo(string s, ABC abc)
However
void foo(string&, ABC);
and
void foo(std::string, ABC);
correctly hightlight ABC as a type.
My modern-cpp-font-lock version is 0.1.3 installed from Melpa, emacs version is 24.5.1 the system is emacs Would you please investigate this problem? Thank you!
I am completely tired of Emacs messing up auto-indentation with some of the modern C++ features, such as strongly-typed enums (ie. "enum class ..."). It's highly annoying. Therefore I was hoping that this font-lock would fix those issues, but does not.
Would it be possible to fix the indentation problems that the current official cc-mode has?
When attempting to install the latest version from MELPA, I get an error because it tries to load faceup.el from ~/.emacs.d/faceup/faceup.el
which AFAIK is because of the recent inclusion of tests. I think perhaps the test files need to be excluded from the MELPA definition for the package?
(I am not a native English speaker, so my problem may be due to lack of knowledge on my part.)
When I read the primary description of what this package is about:
Syntax highlighting support for "Modern C++" - until C++20 and Technical Specification.
I am left with the question whether or not this package supports C++20 language features. The semantics of the English word "until" seems to be exclusive and not inclusive (according to Dictionary.com).
This would mean that this package does not support C++20 features. Is that indeed the intended reading of this package description?
test file https://github.com/yandex/ClickHouse/blob/master/dbms/programs/obfuscator/Obfuscator.cpp
env:
emacs 27.0.50 (master branch)
centos 7
First off, I should say, this has been a really helpful package. Really nice to have the improved highlighting. Makes editing that much easier!
When there are numerical characters in a function name or variable name, if they follow an underscore, start with zero, and have at least one additional digit then they are highlighted as a literal.
You can see that it doesn't happen without the underscore. Also, if it is just a zero or if there is no zero then it is also okay.
Are there plans to support to support digit separators in this library? C++14 supports using single quotes as digit separators but this messes up the font-locking quite badly when using the default C++ mode or this library.
I tried looking int he source code but it doesn't seem function "calls" from inside other functions has an option for a highlight.
is that correct? or did I miss something?
If it is the case, is it possible to add this support? I feel that highlighting function calls in specific helps great deal in understanding any new code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.