Removing the leading asterisk from JavaScript comments in Emacs
The default behaviour of Emacs' JavaScript mode, js.el
, is, when doing fill-paragraph
on a "traditional C comment" of the form
/* Set whether the user wants to open search results in a new window. */
is to format it into the form
/* Set whether the user wants to open search results in a new * window. */
The following Emacs lisp alters this behaviour to give you
/* Set whether the user wants to open search results in a new window. */
without the leading asterisk.
(add-hook 'js-mode-hook (lambda () (setq c-block-comment-prefix " " c-comment-prefix-regexp "//+\\|\\**")))
This is necessary because Emacs' JavaScript mode actually uses
c-mode.el
to do its formatting, but it overrides your C mode
settings with its own version of c-block-comment-prefix
, so
setting the value of c-block-comment-prefix
by itself doesn't
work, you need to re-set it to undo what js.el
does.
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com) or use the discussion group at Google Groups.
/
Privacy /
Disclaimer