Subject: bug#60034: comment character for org and python includes a space

From: Stefan Kangas <[email-masked]>
Date: Sun, 10 Sep 2023 11:47:47 -0700

Heime <[email-masked]> writes:

>> Heime via "Bug reports for GNU Emacs, the Swiss army knife of text
>> editors" [email-masked] writes:
>>
>> > How is it that the comment character for org and python include a
>> > space "# ", when for all other languages it is only a single
>> > character?
>>
>> Could you explain which variable(s) you are looking at?
>>
>> Are you reporting a bug in the behavior of python-mode and org-mode?
>> If so, what is it?
>
> It is about "comment-start".  I am constructing a "regexp" for use
> with hi-lock mode to highlight certain comments.
>
> For elisp I am matching ";; [Text] More"
>
> The regex is adapted for the particular programming mode.

It seems like we do it both ways in our sources, so I'm not sure if it
matters, or what is the correct way.  It's not documented in the
`comment-start' docstring either.

Perhaps it's better to just leave it out unless it is a part of the
language grammar, but I don't know if it would have any adverse effects.

Stefan, what do you think?

> Another difficulty has been that in "c-mode", "comment-start" returns
> "/*" with no possibility to get the alternative "//".

Please report this as a separate bug report, and include the use case
you're looking at with all the details.

> (defun tegor ()
>   "TODO."  (interactive)
>   (let ( (fm (format "%s%s" comment-start comment-start)) )
>     (message "fm: %s" fm) (message "kmcategor: %s"
>        (format "%s%s%s" "^\s*" fm "\s\\(\\[.+\\]\\).*$"))))