all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70804: 29.3.50; Feature request: Allow setting INITIAL-INPUT in comment-normalize-vars when comment-start is nil
@ 2024-05-06 16:36 Daan Ro
  0 siblings, 0 replies; only message in thread
From: Daan Ro @ 2024-05-06 16:36 UTC (permalink / raw)
  To: 70804


[-- 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-06 16:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 16:36 bug#70804: 29.3.50; Feature request: Allow setting INITIAL-INPUT in comment-normalize-vars when comment-start is nil Daan Ro

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.