unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daan Ro <daanturo@gmail.com>
To: 70804@debbugs.gnu.org
Subject: bug#70804: 29.3.50; Feature request: Allow setting INITIAL-INPUT in comment-normalize-vars when comment-start is nil
Date: Mon, 6 May 2024 23:36:32 +0700	[thread overview]
Message-ID: <497AEED3-677D-453A-A567-F3CFF7D13688@getmailspring.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 162 bytes --]

"#" 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


[-- Attachment #1.2: Type: text/html, Size: 809 bytes --]

[-- Attachment #2: 0001-Add-comment-start-default-suggestion-user-option.patch --]
[-- Type: application/octet-stream, Size: 2203 bytes --]

From f0a011fdc888f41eb49cb44e1be577261f8b2a9b Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@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)
-- 
2.45.0


                 reply	other threads:[~2024-05-06 16:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=497AEED3-677D-453A-A567-F3CFF7D13688@getmailspring.com \
    --to=daanturo@gmail.com \
    --cc=70804@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).