* bug#60034: comment character for org and python includes a space
@ 2022-12-13 15:27 Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 18:36 ` Stefan Kangas
0 siblings, 1 reply; 6+ messages in thread
From: Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-13 15:27 UTC (permalink / raw)
To: 60034
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#60034: comment character for org and python includes a space
2022-12-13 15:27 bug#60034: comment character for org and python includes a space Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-13 18:36 ` Stefan Kangas
2022-12-14 2:35 ` Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2022-12-13 18:36 UTC (permalink / raw)
To: Heime, 60034
tags 60034 + moreinfo
thanks
Heime via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs@gnu.org> 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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#60034: comment character for org and python includes a space
2022-12-13 18:36 ` Stefan Kangas
@ 2022-12-14 2:35 ` Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-10 18:47 ` Stefan Kangas
0 siblings, 1 reply; 6+ messages in thread
From: Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-14 2:35 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 60034
------- Original Message -------
On Tuesday, December 13th, 2022 at 6:36 PM, Stefan Kangas <stefankangas@gmail.com> wrote:
> tags 60034 + moreinfo
> thanks
>
> Heime via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" bug-gnu-emacs@gnu.org 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. Another difficulty has been that in "c-mode", "comment-start" returns "/*" with no possibility to get the alternative "//".
(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\\(\\[.+\\]\\).*$"))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#60034: comment character for org and python includes a space
2022-12-14 2:35 ` Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-10 18:47 ` Stefan Kangas
2023-09-11 2:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2023-09-10 18:47 UTC (permalink / raw)
To: Heime; +Cc: 60034, Stefan Monnier
Heime <heimeborgia@protonmail.com> writes:
>> Heime via "Bug reports for GNU Emacs, the Swiss army knife of text
>> editors" bug-gnu-emacs@gnu.org 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\\(\\[.+\\]\\).*$"))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#60034: comment character for org and python includes a space
2023-09-10 18:47 ` Stefan Kangas
@ 2023-09-11 2:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 8:24 ` Stefan Kangas
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-11 2:46 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 60034, Heime, Stefan Monnier
>>> > 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?
FWIW, both options are valid and they lead to different results
when you do `M-;` (as well as as when `-comment-add` is 0).
E.g. ELisp uses ";" rather than "; " so that you can do `M-; ; hello` to
add a comment of the form `;; hello` at the end of the current line.
In modes where using repetitions of the comment char is unusual
(typically because indentation rules don't pay attention to the number
of consecutive comment chars), it's more common to add a space at the
end of `comment-start`.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#60034: comment character for org and python includes a space
2023-09-11 2:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-11 8:24 ` Stefan Kangas
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2023-09-11 8:24 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 60034, Heime, Stefan Monnier
tags 60034 + notabug wontfix
close 60034
thanks
Stefan Monnier <monnier@iro.umontreal.ca> 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?
>
> FWIW, both options are valid and they lead to different results
> when you do `M-;` (as well as as when `-comment-add` is 0).
>
> E.g. ELisp uses ";" rather than "; " so that you can do `M-; ; hello` to
> add a comment of the form `;; hello` at the end of the current line.
>
> In modes where using repetitions of the comment char is unusual
> (typically because indentation rules don't pay attention to the number
> of consecutive comment chars), it's more common to add a space at the
> end of `comment-start`.
Thanks, so I don't think there's anything to fix here. If someone needs
the space-free version, they can use something like:
(string-remove-suffix " " comment-start)
So I'm closing this as a wontfix. Sorry.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-09-11 8:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-13 15:27 bug#60034: comment character for org and python includes a space Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 18:36 ` Stefan Kangas
2022-12-14 2:35 ` Heime via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-10 18:47 ` Stefan Kangas
2023-09-11 2:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 8:24 ` Stefan Kangas
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).