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.
149 questions
0
votes
0
answers
83
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 ...
5
votes
2
answers
375
views
Commenting out some JSX code section with Emacs 27 js-mode
When I comment out (M-x comment-dwim) some section of JSX code with the new js-mode in Emacs 27, it gives:
// <Grid rows={rows} columns={columns}>
// <Table />
// <TableHeaderRow /&...
5
votes
1
answer
585
views
Emacs auto-indenting comments in an unhelpful manner
New Emacs user here. Hitting enter after a semicolon commented line in any file type (.el and .lisp at the very least) indents the comment in a very unhelpful way that I have to assume is not intended ...
3
votes
1
answer
248
views
Continue comment while editing lisp and when hitting enter
If I'm writing a comment
;; this is a comment
;; this is its second line
And I hit enter, I get a new line like this:
;; this is a comment
;; this is its second line
Instead of getting a new line ...
0
votes
1
answer
95
views
Comment code using elisp
Input and desired output
Original code Commented out code:
C %% MODULE %% module_name C~ CPR C ## MODULE ## module_name
lines of code ...
0
votes
0
answers
177
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 ...
0
votes
0
answers
35
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?
0
votes
1
answer
178
views
Comment out / uncomment source blocks on state change in org-mode config file
I started to move my config file to an org-file just recently.
I wondered if it was possible to use the TODO state to activate or deactivate source blocks in the entry under the heading. This way it ...
0
votes
1
answer
190
views
How to highlight a single word in comments, which matches a function call?
While there are packages that handle this, I would like to highlight a single word in source code comments, using for example the warning face, when a function call returns t, using the word as input.
...
0
votes
2
answers
140
views
How do I get Emacs to accept a # (hash) sign as a comment starter in a new mode?
I am attempting to develop an Emacs major mode for writing Tecplot macros. The Tecplot macro language has lots of peculiar constructs, such as a # sign for comments and $! for the beginning of a macro ...
3
votes
2
answers
337
views
Change behaviour of "comment-region" in org-mode tangled source blocks?
I am experimenting with using org-mode for some of my startup config, and adding (org-babel-load-file (concat user-emacs-directory "config.org")) to my .emacs.
Then I use a structure like the ...
1
vote
0
answers
150
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 ...
1
vote
2
answers
351
views
How to change the company complete backend based on the current syntax?
I would like to have natural language completion (company-ispell for e.g.) but only when editing comments.
How should the company back-end be swapped out when editing commensts?
1
vote
0
answers
171
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 ...
3
votes
0
answers
288
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-...
0
votes
0
answers
82
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:...
1
vote
0
answers
291
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:
...
0
votes
1
answer
207
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?
1
vote
1
answer
324
views
(goto-char (region-end)) doesn't set the point to the end of the region
I have written a small elisp script which should put oneline or multiline comments based on the current buffer's major mode. The source file is here: https://github.com/amirteymuri/Com/blob/master/...
0
votes
1
answer
367
views
How to align "end of line comments" in sh-mode?
I moved to column 60 of the first line and evaluated set-comment-column. Then I moved to the second column and called indent-for-comment, but it indents the comment randomly but not at column 60.
How ...
2
votes
1
answer
73
views
Are comment style flags insufficient to separate SQL comments?
I am trying to understand why SQL mode accepts -* as a comment block start.
In sql.el, I read:
(defvar sql-mode-syntax-table
(let ((table (make-syntax-table)))
;; C-style comments /**/ ...
...
1
vote
0
answers
73
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 (...
4
votes
1
answer
395
views
Can I make "comment-region" comment empty lines?
In LaTeX code I can have:
Lorem ipsum dolor sit amet, consectetur
\begin{comment}
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis ...
6
votes
2
answers
787
views
Is there an emacs command to go to end of code line (before line comment and whitespaces start)
say you have that:
stuff
indented stuff # commented stuff
We already got move-beginning-of-line and back-to-indentation for the left side. Now, for the right side...
I'd love to know if you ...
3
votes
1
answer
329
views
How to prettify symbols inside comments?
I'm using prettify-symbol mode together with Pragmata Pro.el.
Ligatures work perfectly fine in the source code but for some reason with comments they don't. I think I'm missing something since it's ...
2
votes
1
answer
983
views
Emacs custom major mode with multiple comment types
I'm trying to write my first (very simple) major mode for Emacs. My goal is to have multiple comment types, but I can't find a way to implement this. Basically, I want my major mode to make ...
0
votes
0
answers
65
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 ...
6
votes
1
answer
237
views
How to prevent emacs from fontifying empty part of the line?
As an example, if I start a one line comment:
;; Comment⏎
Emacs will fontify the the whole line, from the beginning of line, occupying the entire width of the window, as comment. This can be made ...
2
votes
0
answers
78
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 ...
1
vote
0
answers
82
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 ...
1
vote
0
answers
70
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 ...
0
votes
1
answer
234
views
align doesn't indent multiple lines of C code correctly
This is my simple C code block:
int main() { // the enty function
in x = 100; // my new variable
for(int i=1; i<2012; ++i) { // loop a lot
x -= i;
}
} /* ...
3
votes
2
answers
817
views
How to align both of comments and macro of multiple lines with space instead tabs for C/C++ code?
This is my configuration in init.el for C/C++ code which is default value in linux kernel:
(setq indent-tabs-mode t)
I'm using this style and won't change it to nil.
And indentation and alignment ...
3
votes
1
answer
153
views
Move point to just before end of a comment
Given that the point is right in front of a comment, how do I move it to the end of the comment, but before the comment end markers?
For example:
for a C++ // xxx comment, I would like to move the ...
0
votes
1
answer
190
views
Why does emacs put a black background on comments?
For some reason emacs shows comments on a black background. The image shows an example from my emacs with the otherwise amazing color theme "aalto-dark" from the color-theme-modern package. I don't ...
0
votes
1
answer
81
views
Elisp-Function to always insert "*/" in C-Mode when "/*" was typed
I want to implement the functionality, that i wrote about in the title. Since searching the web for existing solutions didn't give me anything useful, i figured i would just try and implement it ...
1
vote
1
answer
863
views
How to fold / collapse the first comment block on file load?
Is there a way to fold the first comment of a file on load?
While I don't like code folding in general, it can be handy in this one instance when every file has a boiler plate header which isn't ...
6
votes
2
answers
586
views
C++ mode: smartly use /*...*/ for comment-dwim
I want to adjust the behavior of comment-dwim when editing c++ files:
When a region is selected that either starts or ends in the middle of a line I would prefer /* ... */ comments. For the other ...
1
vote
0
answers
78
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. ...
2
votes
0
answers
867
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 ...
1
vote
1
answer
249
views
Elisp: Inserting Comments
I'm trying to write an elisp program that will insert a section header and footer as a comment. For example, if I need a section called "intro" for my LaTeX document, the following would be inserted:
...
4
votes
6
answers
538
views
Search for "foo bar" ignoring comments and newlines
How do I search for "foo bar" ignoring comments and newlines in emacs? For example, given the tex file fragment
blah blah foo % comment 1
% comment 2
bar blah blah
I'd like to be able to type "foo ...
4
votes
2
answers
633
views
White space being inserted before a semicolon in asm-mode
When I try to insert a semicolon in my code (in asm-mode) it seems to indent a certain number of tabs like this (usually 4 it seems):
D ;
And if I put another semicolon on the next ...
2
votes
2
answers
349
views
indentation (with multiline comments) in batch processing
i'm trying to indent a couple of C++-files (and untabify them; and remove trailing whitespace), so i thought about using emacs in batch mode.
Since I'm pretty much a noob when it comes to elpa (or ...
2
votes
1
answer
251
views
command to mark a block comment as region
Is there an existing EMACS command to select a block comment? That is, I have
/**
* A Comment
*/
I want to set the mark ahead of the /** and set the point after */.
I realize there are several ...
2
votes
2
answers
868
views
Hide only comments
In hs-mode, is there a way to only hide the comments (C-style, delimited by /* ...*/), and no other blocks of code?
(there was nothing obvious in M-x customize-group hideshow)
3
votes
0
answers
141
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 ...
2
votes
1
answer
827
views
Indenting within block comments in C-mode Emacs
After writing functions in C/C++, I like to format my block comments that explain a function's purpose, parameters, use, and so on.
(See example below)
However, to indent my comments in emacs, I ...
3
votes
1
answer
130
views
disable strange comment behavior in AUCTeX
When I have a commented line in my TeX file, eg
some text that is not commented
|%% here is a comment
followed by more uncommented text
(the | represents point), and I hit RET, point is moved past ...
0
votes
0
answers
283
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?