Questions tagged [comment]

is for distinguishing comment lines from code. Emacs uses the same key bindings for manipulating comments in different modes. Emacs handles all the different ways of inserting comments for each of the major modes. Use additional tags to indicate language-specific modes for questions about comments.

41 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
113 views

Code blocks in font-lock comments

I'm developing a major mode for a language that has doc comments. They look like this: (** Foos three bars. Better call this as [foo 1 b c]. Though of course [foo a b 1] works as well. **) ...
Clément's user avatar
  • 3,953
5 votes
0 answers
424 views

How to setup comment-start and comment-start-skip?

Haskell has line comments starting with -- and multiline comments of the form {- ... -}. I'd like to make auto-fill-mode work for both of those. Currently line comments are auto-filled correctly: -- ...
Gracjan Polak's user avatar
4 votes
1 answer
438 views

How do I teach Emacs to re-wrap /* */ comments?

Is there an existing function, and if not how would I write one, that turns this: /* asdasdasd asdasdasd asdasdasd */ /* asdasdasd asdasdasd asdasdasd asdasdasd asdasdasd */ /* asdasdasd asdasdasd ...
Clément's user avatar
  • 3,953
3 votes
1 answer
45 views

Can you mark the end of 'compilation' in an eLisp source file?

In all of my source files, in whatever language, I use some trick or other to end compilation and then add a documentation trailer in perldoc format from which I can generate a man page. I always keep ...
Dale Amon's user avatar
3 votes
0 answers
251 views

Can I use "comment-column" for comments in other modes than emacs-lisp-mode?

Emacs-lisp-mode distinguishes multiple kinds of comments. ; is an "end of line" comment when following code, or a "right-margin" comment obeying comment-column when indented with indent-for-tab-...
kdb's user avatar
  • 1,561
3 votes
1 answer
321 views

How to set web-mode to use single-line comment style instead of multi-line for JavaScript

When commenting C-style code like C++, JavaScript etc., I use single-line comments to be able to uncomment a previously commented region selectively, i.e // This // is // a single-line style // ...
osolmaz's user avatar
  • 435
2 votes
0 answers
31 views

What is (setq comment-style 'aligned) supposed to do?

First let me show a few things that work correctly. I am doing everything shown below using emacs -q foo.txt in a text buffer. I make these settings first: (setq comment-start "<<") (...
Lone Learner's user avatar
2 votes
0 answers
77 views

Strange comment indentation results

I am working with a simple major mode. The format has one single line comment delimiter, i.e., %. However, I get strange results when running fill-paragraph on a comment. Specifically, the result I ...
chaosape's user avatar
  • 121
2 votes
0 answers
125 views

org-fill-paragraph leaves a comma at end of C style comment

In a src block when there is a C style comment /* ... */ doing an org-fill-paragraph would always put a comma just before the last star, like this: /* Some comment ,*/ Is there a way to stop it from ...
SFbay007's user avatar
  • 554
2 votes
0 answers
103 views

How to modify behavior of syntax highlighting without editing the original source?

There is a bug in C/C++ comment highlighting (bug 11865) Where the fix appears to be to modify the value of c-font-lock-doc-comments Is there a way to do this in my emacs config, instead of having ...
ideasman42's user avatar
  • 8,406
2 votes
0 answers
75 views

How to protect LaTeX comment lines from indentation?

When I type <TAB> in a LaTeX file anywhere on a comment line, the comment symbol is moved to the beginning of the previous non-blank line. This also occurs with M-x indent-region. Is there a ...
Michel Fioc's user avatar
2 votes
0 answers
705 views

`insert-file-contents` without the comments

The below command insert the contents of the file myfile.txt. (insert-file-contents "~/myfile.txt") Is there a way to tell emacs to not insert the comments (assuming the comment syntax is known to ...
Name's user avatar
  • 7,719
1 vote
1 answer
79 views

how to break apart text into lines of a specified max width

I am writing long, descriptive text above a line of code and would like to format it into comment lines of a specified max width, while not splitting text mid-word. How can I do this? For example, I ...
mark's user avatar
  • 273
1 vote
1 answer
124 views

No comment syntax defined when tangling lua or vimrc code blocks

Resolution With help from commenters, I have things kind of working. I removed :comments link from Properties. I manually added comments to the top of every code block to replicate what :comments ...
Jason's user avatar
  • 111
1 vote
0 answers
74 views

How to properly use modify-syntax-entry flags to syntax highlight comments in Lua?

I made my own Lua major mode about a month back. There is one thing that is still not working: highlighting comments. At first, I simply added ("--.*" . font-lock-comment-face) to lua-font-...
Alan's user avatar
  • 37
1 vote
0 answers
138 views

Org mode link in comments

Is there a way to make links work in comments? # Comment with [[link]] link Error Message: edmacro-parse-keys: C-M- must prefix a single character, not up The link would work only when separated ...
Sati's user avatar
  • 775
1 vote
0 answers
144 views

Emacs `captain-mode` auto-capitalization in comment

I installed captain-mode, and it worked as expected in org/text modes, but not so quite in programming modes' comment lines. The problem is it can auto-capitalize the first word from the second ...
Sean's user avatar
  • 11
1 vote
0 answers
170 views

Set font family for comments

In coq mode I have ligatures being used: instead of "fun", it shows λ in the programming code. But in the comments lambda transformed into a character I can't even copy, so I'll attach a screenshot: ...
user4035's user avatar
  • 1,059
1 vote
0 answers
67 views

Why does sql-mode think -* starts a block comment?

While typing in a SQL mode buffer, I noticed that -* starts a block comment. Why? It happens whenever I type an asterisk/star character (ASCII 42) directly after a simple dash/hyphen/minus character (...
Michel de Ruiter's user avatar
1 vote
0 answers
72 views

EMACS doesn't grey out comments

When I comment out code with combination of /* and */ in JavaScript nothing happens with text and it stays the same color. (You can see it in second part of code, one that is not grayed out but is ...
guber90's user avatar
  • 11
1 vote
0 answers
69 views

Enable `cc-mode` documentation highlightning per minor mode

I am writing a minor mode for enabling support for JML within Java files. I realized the syntax highlighting with cc-mode's support for documentation comments. It works if I set c-doc-comment-style ...
wadoon's user avatar
  • 11
1 vote
0 answers
72 views

Font-locking for text inside org-mode COMMENT blocks

While other sorts of #+BEGIN ... #+END blocks seem to get font-locking applied to them (potentially changing foreground and background colours etc.), #+BEGIN_COMMENT ... #+END_COMMENT blocks do not. ...
emacsomancer's user avatar
  • 1,021
1 vote
0 answers
636 views

How to add additional comment syntax to a mode?

In general, given a major mode with a defined comment syntax, what do I have to define or change to add a new comment syntax? By "adding", I mean setting some new characters so that they work with ...
phipsgabler's user avatar
1 vote
0 answers
90 views

Keyword as comment ender (and starter)

In my previous question I asked about complex comment-start sequence and I think I figured it out, but now I have another problem. Let say we have this mode: (defconst test-font-lock-keywords '(("\\...
vonaka's user avatar
  • 171
1 vote
0 answers
91 views

auto-fill-mode fails in comment with empty second line

Consider the following comments: ;; This is the first line of a comment. ;; ;; This is the second line, which begins a paragraph. If I have ;;auto-fill-mode enabled, I lose the leading space! ;; ...
Resigned June 2023's user avatar
1 vote
0 answers
38 views

Navigation ignores comment blocks in (La)TeX mode

I sometimes leave large blocks of comments in LaTeX source code: Text text text text. % Comments comments comments comments. % Six lines of comments. % More comments. % Separate comment block. % ...
Tom Zych's user avatar
  • 111
0 votes
0 answers
23 views

Need an emacs function that reformats a comment, left and right padded

Context When writing a long text file that has some structure (program, TeX/LaTeX document, whatever programming or markup language), it can be handy to make structure visually salient into visible ...
Stéphane Gourichon's user avatar
0 votes
0 answers
32 views

Keeping specific comments with bold weight

I am using a bold typeface, but for comments I am using normal weight. But I would like that some specific comments to remain displayed with bold weight. The specific comments are those that start ...
Dilna's user avatar
  • 1,183
0 votes
0 answers
33 views

Setting file-local comment character

I am trying to set the comments character to * in conf-mode with this file-local line: * -*- mode: conf; comment-start: "*" ; comment-start-skip: "\\* [ ]*" -*- normal line * ...
quazgar's user avatar
  • 341
0 votes
0 answers
49 views

ess font-lock-add-keywords not working

For several years I have been using this bit of code in my init.el file to organize comments. Here is the code ` (defgroup ess-jb-faces nil "Faces used by cutomized ess-mode" :group '...
Jacob's user avatar
  • 21
0 votes
0 answers
123 views

Inheritance of font-lock-comment-delimiter-face

How does inheritance of font-lock-comment-delimiter-face work with font-lock-comment-face? The following uses a different colour for the comment delimiter by setting the foreground colour to font-lock-...
Dilna's user avatar
  • 1,183
0 votes
0 answers
100 views

Uncommenting not working on Javascript file

I am trying to use the block un-comment command C-x C-; but I am getting the error message "Can't find the comment end". I am writing Javascript code in an .html file. The block comment ...
Lucas Myers's user avatar
0 votes
0 answers
68 views

in Fundamental mode, give certain marked text a different face

I am trying to add a new comment character in fundamental mode, but I can't get it to work. Let me rephrase that, because I think it's an xy-problem. What I really would like to have is the ...
Roadowl's user avatar
  • 131
0 votes
0 answers
146 views

Custom comment with comment-line and comment-dwim

Basically, what I want to do is to customize comment-start and comment-end when invoking different commands to then call comment-dwim or comment-line with them. What I managed to do so far is the ...
Lhooq's user avatar
  • 230
0 votes
0 answers
31 views

AUCTeX highlight contents of comment environment as a comment

I sometimes use comment environment in my LaTeX documents. Is there a way to make AUCTeX display contents of this environment as a comment?
Sergey's user avatar
  • 249
0 votes
0 answers
73 views

writegood mode in code

I like to use writegood-mode for my source code comments. I feel that there should be a way to make it check comments only. However, my python files display that kind of things: and so does bash mode:...
Gauthier's user avatar
  • 499
0 votes
1 answer
168 views

comment-kill for entire region

Is there a similar command to comment-kill that kills all comments in a given region and saves them to the kill ring?
Conor Taylor's user avatar
0 votes
0 answers
64 views

unexpected long indent after colon in web-mode

I have some trouble locating the source of 8 tabs and 3 spaces more than the previous indentation when I'm inside js inside web-mode. These appear after a line that ends with a colon. Example (note ...
Sjoerd Timmer's user avatar
0 votes
0 answers
268 views

How to change the command for comment toggling

spacemacs with Evil uses gcc to toggle whether a line is commented or not. I'd like to change it to ,cc. How should I go about this in my .spacemacs file?
user2891462's user avatar
0 votes
1 answer
871 views

How to toggle multi-line comment blocks?

Is it possible to configure multi-line comments to comment/uncomment selected text? For example C/C++'s preprocessor could be toggled like this. eg: Before: // a comment Some(code); /* ...
ideasman42's user avatar
  • 8,406
0 votes
0 answers
383 views

Non-Indentation of only C++ comments in C++ mode

How can I configure my ~/.emacs so as to get the following effect? In C++ mode, I want C++ comments (but not C-style comments), to always be unindented, i.e., the double slashes should always be ...
Jérôme Kunegis's user avatar