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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
45 views

How to execute Elisp code embedded in c++ comment?

While I found lots of sources, how to use Elisp in an org-mode document, what I try to do is not related to org-mode at all. My idea is to embed Elisp functions and calls of Elisp functions within ...
user avatar
0 votes
1 answer
29 views

To remove characters in the beginnings of lines

To add // in the beginnings of multiple lines I can use either string-insert-rectangle or string-rectangle (C-x r t). But how is it possible to remove these characters instead? This question is not ...
user avatar
0 votes
1 answer
31 views

Adjust how comments work in markdown-mode

How can I adjust how M-; (comment-dwim) works in markdown-mode? Specifically, I'd like for it to not use delimiters for each line. As an example, in Markdown mode, if I commend a line like This is a ...
user avatar
  • 1,482
0 votes
1 answer
35 views

Comments in org capture templates

I have a lot of org capture templates defined in my .emacs file. I'd like to be able to add a "comment" into some of them - how would I do that? For example when I'm capturing a new GTD ...
user avatar
  • 305
1 vote
1 answer
28 views

How do I match comments where the start and the end character are the same?

I have a programming language I want to make a major mode for where both the start and the end characters of a comment are the same. Specifically #. # This is a comment # As you can see it can match ...
user avatar
1 vote
0 answers
42 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 ...
user avatar
  • 111
0 votes
0 answers
54 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-...
user avatar
  • 159
1 vote
0 answers
27 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-...
user avatar
  • 37
2 votes
1 answer
29 views

How to hide comments and move them to a separate window?

I'm interested in hiding comments in code or structured text, but displaying them in another window; i.e. same buffer, two windows side-by-side, one showing the main text (code, or content), but ...
user avatar
  • 197
3 votes
1 answer
29 views

Is it possible for hideshow to display both the start and trailing comment characters?

Running hs-toggle-hiding converts a C-style multi-line comment from. /* * This is a comment. */ To: /* ... Is there a way to collepse the comment to: /* ... */ Instead?
user avatar
  • 7,179
0 votes
1 answer
49 views

Docstring - quotes or semicolons?

In the documentation I only see mention of using semicolons for comments and docstrings, but in elisp-documents I regularly see functions documented in double-quotes, such as in org.el: (defun org-...
user avatar
  • 224
0 votes
1 answer
12 views

IntelliJ style comment block cannot be recognized

In java-mode, I find the IntelliJ style comment block /** ... */ cannot be recognized correctly. And I have checked that the value of comment-start-skip variable (inherit from c-mode) is set as "\...
user avatar
1 vote
1 answer
38 views

After setting syntax-propertize-function, comment is not being fontified with comment face

I'm trying to build a major mode for xwiki, where I'm defining {{{ verbatim }}} as a comment. So far, I've done (eval-when-compile (defconst xwiki-syntax-propertize-rules (syntax-...
user avatar
1 vote
4 answers
683 views

How can I create block (multiline) comments in Lisp code?

How can I do multiline / block comments in Lisp code - e.g. in the init.el. In Python I would do it like this """Block comment """ In C/C++ like this /* Block comment */ ...
user avatar
  • 509
0 votes
1 answer
81 views

How to uncomment multiple expressions in Lisp code?

I am using Emacs, Slime, Paredit, and other packages to work on Common Lisp (SBCL). It is really useful to comment out multiple expressions while debugging. For instance, suppose I have these ...
user avatar
0 votes
1 answer
34 views

Why Emacs creates multiples whitespaces after I create a comment and jump to a new line?

I am using Emacs, Paredit, Slime to work on Common Lisp (SBCL). When I create a comment such as: ; test It is placed as expected. But if I press return in order to create a new line below ;test this ...
user avatar
0 votes
1 answer
35 views

Auctex change default comment style for latex-mode

I want a double %% to start my comments in latex documents. I'have found two solutions suggested ;; solution 1 (add-hook 'latex-mode-hook '(lambda() (setq comment-start "%% "))) ;; ...
user avatar
0 votes
2 answers
64 views

Commenting moves point unexpectedly

The usual behavior of comment-line is to move point to the next line. When commenting code within an Org source block, however, the point will jump to some previous line. For example, say that point ...
user avatar
  • 3,885
0 votes
1 answer
31 views

How add specifc string(ex: TODO) along with a comment character for a specifc mode?

Based on specific mode, by using a keybinding I want to add a TODO string that is preceded by an unique comment character. For example, (org-mode is exception since ** does not stands for comment and ...
user avatar
  • 1,066
4 votes
1 answer
111 views

How to convert single line comments to multiline comments?

I have a bunch of single line comment blocks in C-code that I want to change to multiline. Example: // foo // bar should become: /* foo * bar */ How can I do this easily in Emacs?
user avatar
  • 389
0 votes
0 answers
59 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 ...
user avatar
0 votes
0 answers
56 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 ...
user avatar
  • 131
4 votes
1 answer
150 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 /&...
user avatar
  • 574
2 votes
1 answer
206 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 ...
user avatar
  • 123
3 votes
1 answer
75 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 ...
user avatar
0 votes
1 answer
56 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 ...
user avatar
  • 1,330
0 votes
0 answers
80 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 ...
user avatar
  • 143
0 votes
0 answers
25 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?
user avatar
  • 249
0 votes
1 answer
102 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 ...
user avatar
0 votes
1 answer
85 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. ...
user avatar
  • 7,179
0 votes
2 answers
94 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 ...
user avatar
3 votes
2 answers
202 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 ...
user avatar
  • 1,173
1 vote
0 answers
105 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 ...
user avatar
  • 645
1 vote
2 answers
289 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?
user avatar
  • 7,179
1 vote
0 answers
99 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 ...
user avatar
  • 11
3 votes
0 answers
168 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-...
user avatar
  • 1,481
0 votes
0 answers
53 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:...
user avatar
  • 387
1 vote
0 answers
104 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: ...
user avatar
  • 845
0 votes
1 answer
121 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?
user avatar
1 vote
1 answer
158 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/...
user avatar
0 votes
1 answer
219 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 ...
user avatar
  • 1,154
2 votes
1 answer
55 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 /**/ ... ...
user avatar
1 vote
0 answers
54 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 (...
user avatar
4 votes
1 answer
279 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 ...
user avatar
5 votes
2 answers
359 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 ...
user avatar
  • 153
3 votes
1 answer
222 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 ...
user avatar
  • 167
2 votes
1 answer
585 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 ...
user avatar
0 votes
0 answers
54 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 ...
user avatar
6 votes
1 answer
185 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 ...
user avatar
  • 103
2 votes
0 answers
75 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 ...
user avatar