GNU bug report logs -
#70804
29.3.50; Feature request: Allow setting INITIAL-INPUT in comment-normalize-vars when comment-start is nil
Previous Next
To reply to this bug, email your comments to 70804 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Mon, 06 May 2024 16:38:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Daan Ro <daanturo <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 06 May 2024 16:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
"#" is the most common comment syntax in text files whose major mode
couldn't be recognized automatically.
I hope this can be customized in Emacs 30.
Daanturo
[Message part 2 (text/html, inline)]
[0001-Add-comment-start-default-suggestion-user-option.patch (application/octet-stream, attachment)]
Added tag(s) patch.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 01 Mar 2025 02:34:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Mon, 03 Mar 2025 02:00:03 GMT)
Full text and
rfc822 format available.
Message #10 received at 70804 <at> debbugs.gnu.org (full text, mbox):
Daan Ro <daanturo <at> gmail.com> writes:
> "#" is the most common comment syntax in text files whose major mode
> couldn't be recognized automatically.
>
> I hope this can be customized in Emacs 30.
Thanks for the patch, and sorry for the long delay.
Maybe we should just offer "#" as the default instead, if it's the most
common one? My reasoning here is that there is no need to add a
defcustom, if no one has asked for it.
> From f0a011fdc888f41eb49cb44e1be577261f8b2a9b Mon Sep 17 00:00:00 2001
> From: Daanturo <daanturo <at> gmail.com>
> Date: Mon, 6 May 2024 23:16:56 +0700
> Subject: [PATCH] Add `comment-start-default-suggestion' user option
>
> * lisp/newcomment.el: Define `comment-start-default-suggestion' Lisp
> variable and use it in `comment-normalize-vars'.
>
> * etc/NEWS: Announce the option.
> ---
> etc/NEWS | 5 +++++
> lisp/newcomment.el | 9 ++++++++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/etc/NEWS b/etc/NEWS
> index 456f9b8f8b8..fa9b7c82a97 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -541,6 +541,11 @@ whereas if the mouse pointer is in the left half of a glyph, point
> will be put in front the buffer position corresponding to that glyph.
> By default this is disabled.
>
> +---
> +** New user option 'comment-start-default-suggestion'.
> +When 'comment-normalize-vars' asks for nil 'comment-start', use this as
> +the default suggested string in the prompt.
> +
> ** Internationalization
>
> ---
> diff --git a/lisp/newcomment.el b/lisp/newcomment.el
> index ee7b2ea34d8..86529668067 100644
> --- a/lisp/newcomment.el
> +++ b/lisp/newcomment.el
> @@ -349,6 +349,12 @@ terminated by the end of line (i.e., `comment-end' is empty)."
> "Return the mirror image of string S, without any trailing space."
> (comment-string-strip (concat (nreverse (string-to-list s))) nil t))
>
> +(defcustom comment-start-default-suggestion nil
> + "The default suggestion when unset `comment-start' is asked."
> + :type 'string
> + :version "30.1"
> + :group 'comment)
> +
> ;;;###autoload
> (defun comment-normalize-vars (&optional noerror)
> "Check and set up variables needed by other commenting functions.
> @@ -358,7 +364,8 @@ functions work correctly. Lisp callers of any other `comment-*'
> function should first call this function explicitly."
> (unless (and (not comment-start) noerror)
> (unless comment-start
> - (let ((cs (read-string "No comment syntax is defined. Use: ")))
> + (let ((cs (read-string "No comment syntax is defined. Use: "
> + comment-start-default-suggestion)))
> (if (zerop (length cs))
> (error "No comment syntax defined")
> (setq-local comment-start cs)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Mon, 03 Mar 2025 14:17:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 70804 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I was afraid that directly setting the default may break many people's muscle
memory, or hypothetically maybe someday "#" won't be the most common unknown
case anymore. Between a new custom variable and the default I have no strong
opinion otherwise.
Daanturo
On Mar 3 2025, at 8:59 am, Stefan Kangas <stefankangas <at> gmail.com> wrote:
> Daan Ro <daanturo <at> gmail.com> writes:
>
> > "#" is the most common comment syntax in text files whose major mode
> > couldn't be recognized automatically.
> >
> > I hope this can be customized in Emacs 30.
>
> Thanks for the patch, and sorry for the long delay.
> Maybe we should just offer "#" as the default instead, if it's the most
> common one? My reasoning here is that there is no need to add a
> defcustom, if no one has asked for it.
>
> > From f0a011fdc888f41eb49cb44e1be577261f8b2a9b Mon Sep 17 00:00:00 2001
> > From: Daanturo <daanturo <at> gmail.com>
> > Date: Mon, 6 May 2024 23:16:56 +0700
> > Subject: [PATCH] Add `comment-start-default-suggestion' user option
> >
> > * lisp/newcomment.el: Define `comment-start-default-suggestion' Lisp
> > variable and use it in `comment-normalize-vars'.
> >
> > * etc/NEWS: Announce the option.
> > ---
> > etc/NEWS | 5 +++++
> > lisp/newcomment.el | 9 ++++++++-
> > 2 files changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/etc/NEWS b/etc/NEWS
> > index 456f9b8f8b8..fa9b7c82a97 100644
> > --- a/etc/NEWS
> > +++ b/etc/NEWS
> > @@ -541,6 +541,11 @@ whereas if the mouse pointer is in the left half of a glyph, point
> > will be put in front the buffer position corresponding to that glyph.
> > By default this is disabled.
> >
> > +---
> > +** New user option 'comment-start-default-suggestion'.
> > +When 'comment-normalize-vars' asks for nil 'comment-start', use this as
> > +the default suggested string in the prompt.
> > +
> > ** Internationalization
> >
> > ---
> > diff --git a/lisp/newcomment.el b/lisp/newcomment.el
> > index ee7b2ea34d8..86529668067 100644
> > --- a/lisp/newcomment.el
> > +++ b/lisp/newcomment.el
> > @@ -349,6 +349,12 @@ terminated by the end of line (i.e., `comment-end' is empty)."
> > "Return the mirror image of string S, without any trailing space."
> > (comment-string-strip (concat (nreverse (string-to-list s))) nil t))
> >
> > +(defcustom comment-start-default-suggestion nil
> > + "The default suggestion when unset `comment-start' is asked."
> > + :type 'string
> > + :version "30.1"
> > + :group 'comment)
> > +
> > ;;;###autoload
> > (defun comment-normalize-vars (&optional noerror)
> > "Check and set up variables needed by other commenting functions.
> > @@ -358,7 +364,8 @@ functions work correctly. Lisp callers of any other `comment-*'
> > function should first call this function explicitly."
> > (unless (and (not comment-start) noerror)
> > (unless comment-start
> > - (let ((cs (read-string "No comment syntax is defined. Use: ")))
> > + (let ((cs (read-string "No comment syntax is defined. Use: "
> > + comment-start-default-suggestion)))
> > (if (zerop (length cs))
> > (error "No comment syntax defined")
> > (setq-local comment-start cs)
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Mon, 03 Mar 2025 14:30:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 70804 <at> debbugs.gnu.org (full text, mbox):
Daan Ro <daanturo <at> gmail.com> writes:
> I was afraid that directly setting the default may break many people's muscle
> memory, or
Hmm, but the default now is the empty string, which AFAIU means to do
nothing.
It seems strange to have, in muscle memory, `M-; RET`, if it indeed has
the effect to do nothing...
IOW, I think a new default is harmless here.
> hypothetically maybe someday "#" won't be the most common unknown
> case anymore.
When that day comes, we can add a defcustom.
> Between a new custom variable and the default I have no strong
> opinion otherwise.
Would you like to propose a new patch along the above lines?
I don't think this needs to be in NEWS, even.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Mon, 03 Mar 2025 18:57:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 70804 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Attached a single sexp change patch =)).
Daanturo
On Mar 3 2025, at 9:28 pm, Stefan Kangas <stefankangas <at> gmail.com> wrote:
> Daan Ro <daanturo <at> gmail.com> writes:
>
> Would you like to propose a new patch along the above lines?
> I don't think this needs to be in NEWS, even.
[Message part 2 (text/html, inline)]
[0001-Let-sharp-be-the-suggested-comment-start-when-undefined-bug-70804.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Mon, 03 Mar 2025 19:11:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 70804 <at> debbugs.gnu.org (full text, mbox):
Version: 31.1
Daan Ro <daanturo <at> gmail.com> writes:
> Attached a single sexp change patch =)).
Thanks! Some comments below:
> From 549ee68d5b6cf3dae5dd69b8f1a99c045f200cbe Mon Sep 17 00:00:00 2001
> From: Daanturo <daanturo <at> gmail.com>
> Date: Mon, 3 Mar 2025 18:46:01 +0000
> Subject: [PATCH] Let "#" be the suggested comment-start when undefined
> (bug#70804)
>
> * lisp/newcomment.el: add "#" to 'comment-normalize-vars' prompt's
> initial input.
> ---
> lisp/newcomment.el | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/newcomment.el b/lisp/newcomment.el
> index 945187e863f..3258735dcea 100644
> --- a/lisp/newcomment.el
> +++ b/lisp/newcomment.el
> @@ -358,7 +358,7 @@ comment-normalize-vars
> function should first call this function explicitly."
> (unless (and (not comment-start) noerror)
> (unless comment-start
> - (let ((cs (read-string "No comment syntax is defined. Use: ")))
> + (let ((cs (read-string "No comment syntax is defined. Use: " "#")))
I think you should use the DEFAULT-VALUE argument instead of
INITIAL-INPUT.
Also, I recommend using format-prompt, e.g.
(format-prompt "No comment syntax is defined, use" "#")
> (if (zerop (length cs))
> (error "No comment syntax defined")
> (setq-local comment-start cs)
> --
> 2.48.1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#70804
; Package
emacs
.
(Tue, 04 Mar 2025 10:34:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 70804 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thank you! I see, that way is far less disrupting so it could be
proceeded without debating.
Daanturo
On Mar 4 2025, at 2:10 am, Stefan Kangas <stefankangas <at> gmail.com> wrote:
> Version: 31.1
>
> I think you should use the DEFAULT-VALUE argument instead of
> INITIAL-INPUT.
>
> Also, I recommend using format-prompt, e.g.
> (format-prompt "No comment syntax is defined, use" "#")
[Message part 2 (text/html, inline)]
[0001-Let-sharp-be-the-default-comment-start-when-prompted-bug-70804.patch (application/octet-stream, attachment)]
This bug report was last modified 103 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.