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

Package: emacs;

Reported by: Daan Ro <daanturo <at> gmail.com>

Date: Mon, 6 May 2024 16:38:01 UTC

Severity: wishlist

Tags: patch

Found in version 29.3.50

Full log


Message #10 received at 70804 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Daan Ro <daanturo <at> gmail.com>
Cc: 70804 <at> debbugs.gnu.org
Subject: Re: bug#70804: 29.3.50; Feature request: Allow setting INITIAL-INPUT
 in comment-normalize-vars when comment-start is nil
Date: Sun, 2 Mar 2025 17:59:11 -0800
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)




This bug report was last modified 104 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.