Subject: bug#70804: 29.3.50; Feature request: Allow setting INITIAL-INPUT in comment-normalize-vars when comment-start is nil

From: Stefan Kangas <[email-masked]>
Date: Mon, 3 Mar 2025 19:10:19 +0000

Version: 31.1

Daan Ro <[email-masked]> writes:

> Attached a single sexp change patch =)).

Thanks!  Some comments below:

> From 549ee68d5b6cf3dae5dd69b8f1a99c045f200cbe Mon Sep 17 00:00:00 2001
> From: Daanturo <[email-masked]>
> 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