I'd like to add comments to a major mode that I use that doesn't currently support them. The only examples I can find online show how to write single-line comments, but I need paired delimiters.
What do I need to change?
I ended up digging in to the elisp of the package that I was working with. The problem is that if you add
(setq comment-start "FOO")
(setq comment-end "BAR")
to your-mode-hook
, then, when you switch to another language that defines comment-start
but not comment-end
, then you end up with comment-end
sticking from the other mode. For example, your python-mode
comments look like:
# def my_func(): BAR
which definitely isn't what you want. In order to fix that, use the following:
(add-hook 'your-mode-hook
(lambda ()
(set (make-local-variable 'comment-start) "FOO")
(set (make-local-variable 'comment-end) "BAR")))
and it won't clobber other modes' comment-end
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With