Subject: bug#77424: [PATCH] Add block-comment-start and block-comment-end to supported modes.

From: Elijah Gabe Pérez <[email-masked]>
Date: Mon, 31 Mar 2025 18:46:21 -0600

Tags: patch

For make =electric-block-comment-mode= works, it needs that the major
modes that support block comments set =block-comment-start= and
=block-comment-end= (which both were unused).

This patch do this work.

/Note: I didn't included cc modes because i don't know which part to add it./

>From 8a8fb10de722189005584fc428c62826d278fa57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Mon, 31 Mar 2025 17:58:16 -0600
Subject: [PATCH] Add block-comment-start and block-comment-end to supported
 modes.

* lisp/emacs-lisp/lisp-mode.el (lisp-mode-variables):
Add block-comment-start and block-comment-end from here...
* lisp/newcomment.el (block-comment-start, block-comment-end):...
* lisp/nxml/nxml-mode.el (nxml-mode):...
* lisp/progmodes/c-ts-common.el (c-ts-common-comment-setup):...
* lisp/progmodes/go-ts-mode.el (go-work-ts-mode):...
* lisp/progmodes/js.el (js--mode-setup):...
* lisp/progmodes/json-ts-mode.el (json-ts-mode):...
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode):...
* lisp/progmodes/opascal.el (opascal-mode):...
* lisp/progmodes/pascal.el (pascal-mode):...
* lisp/progmodes/typescript-ts-mode.el (tsx-ts-mode):...
* lisp/textmodes/css-mode.el (css-base-mode, scss-mode):...
* lisp/textmodes/sgml-mode.el (sgml-mode): ... to here.
---
 lisp/emacs-lisp/lisp-mode.el         | 2 ++
 lisp/newcomment.el                   | 9 +++++----
 lisp/nxml/nxml-mode.el               | 2 ++
 lisp/progmodes/c-ts-common.el        | 4 ++++
 lisp/progmodes/go-ts-mode.el         | 2 ++
 lisp/progmodes/js.el                 | 2 ++
 lisp/progmodes/json-ts-mode.el       | 2 ++
 lisp/progmodes/lua-ts-mode.el        | 2 ++
 lisp/progmodes/opascal.el            | 4 +++-
 lisp/progmodes/pascal.el             | 2 ++
 lisp/progmodes/typescript-ts-mode.el | 2 ++
 lisp/textmodes/css-mode.el           | 4 ++++
 lisp/textmodes/sgml-mode.el          | 2 ++
 13 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 006b713ae6e..ce79393fb90 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -701,6 +701,8 @@ lisp-mode-variables
   (setq-local add-log-current-defun-function #'lisp-current-defun-name)
   (setq-local comment-start ";")
   (setq-local comment-start-skip ";+ *")
+  (setq-local block-comment-start "#|")
+  (setq-local block-comment-end "|#")
   (setq-local comment-add 1)		;default to `;;' in comment-region
   (setq-local comment-column 40)
   (setq-local comment-use-syntax t)
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 945187e863f..eb36f91104d 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -56,7 +56,6 @@
 ;; - spill auto-fill of comments onto the end of the next line.
 ;; - uncomment-region with a consp (for blocks) or somehow make the
 ;;   deletion of continuation markers less dangerous.
-;; - drop block-comment-<foo> unless it's really used.
 ;; - uncomment-region on a subpart of a comment.
 ;; - support gnu-style "multi-line with space in continue".
 ;; - somehow allow comment-dwim to use the region even if transient-mark-mode
@@ -183,9 +182,11 @@ uncomment-region-function
 Applicable at least in modes for languages like fixed-format Fortran where
 comments always start in column zero.")
 
-;; ?? never set
-(defvar block-comment-start nil)
-(defvar block-comment-end nil)
+(defvar block-comment-start nil
+  "String to insert to start a new block comment, or nil if no supported.")
+
+(defvar block-comment-end nil
+  "String to insert to end a new block comment, or nil if no supported.")
 
 (defvar comment-quote-nested t
   "Non-nil if nested comments should be quoted.
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 7acc19b9058..994b2779d1a 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -529,6 +529,8 @@ nxml-mode
   (setq-local comment-start-skip "<!--[ \t\r\n]*")
   (setq-local comment-end "-->")
   (setq-local comment-end-skip "[ \t\r\n]*-->")
+  (setq-local block-comment-start "<!--")
+  (setq-local block-comment-end "-->")
   (setq-local comment-line-break-function #'nxml-newline-and-indent)
   (setq-local comment-quote-nested-function #'nxml-comment-quote-nested)
   (setq-local comment-continue "") ; avoid double-hyphens as a padding
diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el
index 71c177788a8..26d24180e8c 100644
--- a/lisp/progmodes/c-ts-common.el
+++ b/lisp/progmodes/c-ts-common.el
@@ -275,6 +275,8 @@ c-ts-common-comment-setup
  - `comment-end'
  - `comment-start-skip'
  - `comment-end-skip'
+ - `block-comment-start'
+ - `block-comment-end'
  - `adaptive-fill-mode'
  - `adaptive-fill-first-line-regexp'
  - `paragraph-start'
@@ -291,6 +293,8 @@ c-ts-common-comment-setup
               (rx (* (syntax whitespace))
                   (group (or (syntax comment-end)
                              (seq (+ "*") "/")))))
+  (setq-local block-comment-start "/*")
+  (setq-local block-comment-end "*/")
   (setq-local adaptive-fill-mode t)
   (setq-local adaptive-fill-function #'c-ts-common--adaptive-fill-prefix)
   ;; Always accept * or | as prefix, even if there's only one line in
diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index d117fe21590..bae3558e077 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -674,6 +674,8 @@ go-work-ts-mode
     (setq-local comment-start "// ")
     (setq-local comment-end "")
     (setq-local comment-start-skip (rx "//" (* (syntax whitespace))))
+    (setq-local block-comment-start "/*")
+    (setq-local block-comment-end "*/")
 
     ;; Indent.
     (setq-local indent-tabs-mode t
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f319d1d2fa9..6db032f007a 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3788,6 +3788,8 @@ js--mode-setup
   (setq-local comment-start "// ")
   (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *")
   (setq-local comment-end "")
+  (setq-local block-comment-start "/*")
+  (setq-local block-comment-end "*/")
   (setq-local fill-paragraph-function #'js-fill-paragraph)
   (setq-local normal-auto-fill-function #'js-do-auto-fill)
 
diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el
index 1b8f033e97a..c13e2e7f956 100644
--- a/lisp/progmodes/json-ts-mode.el
+++ b/lisp/progmodes/json-ts-mode.el
@@ -137,6 +137,8 @@ json-ts-mode
   (setq-local comment-start "// ")
   (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *")
   (setq-local comment-end "")
+  (setq-local block-comment-start "/*")
+  (setq-local block-comment-end "*/")
 
   ;; Electric
   (setq-local electric-indent-chars
diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index 31a1a2b8aea..32cfc4b8a8b 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -668,6 +668,8 @@ lua-ts-mode
     (setq-local comment-start "--")
     (setq-local comment-start-skip "--\\s-*")
     (setq-local comment-end "")
+    (setq-local block-comment-start "--[[" )
+    (setq-local block-comment-end "]]"))
 
     ;; Font-lock.
     (setq-local treesit-font-lock-settings lua-ts--font-lock-settings)
diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el
index bd6bc3b28ac..9dcaff9645e 100644
--- a/lisp/progmodes/opascal.el
+++ b/lisp/progmodes/opascal.el
@@ -1767,7 +1767,9 @@ opascal-mode
 
   (setq-local comment-start "// ")
   (setq-local comment-start-skip "\\(?://\\|(\\*\\|{\\)[ \t]*")
-  (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*)\\|}\\)"))
+  (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*)\\|}\\)")
+  (setq-local block-comment-start "(*")
+  (setq-local block-comment-end "*)"))
 
 (provide 'opascal)
 ;;; opascal.el ends here
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index b6316d4dfe1..eb8efbf643e 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -348,6 +348,8 @@ pascal-mode
   (setq-local comment-start "{")
   (setq-local comment-start-skip "(\\*+ *\\|{ *")
   (setq-local comment-end "}")
+  (setq-local block-comment-start "(*")
+  (setq-local block-comment-end "*)")
   (add-hook 'completion-at-point-functions 'pascal-completions-at-point nil t)
   ;; Font lock support
   (setq-local font-lock-defaults '(pascal-font-lock-keywords nil t))
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index 9051a841887..273f0fce647 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -639,6 +639,8 @@ tsx-ts-mode
     ;; Comments.
     (setq-local comment-start "// ")
     (setq-local comment-end "")
+    (setq-local block-comment-start "/*")
+    (setq-local block-comment-end "*/")
     (setq-local comment-start-skip (rx (or (seq "/" (+ "/"))
                                            (seq "/" (+ "*")))
                                        (* (syntax whitespace))))
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 02c3618d281..029e80b3498 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1847,6 +1847,8 @@ css-base-mode
   (setq-local comment-start-skip "/\\*+[ \t]*")
   (setq-local comment-end "*/")
   (setq-local comment-end-skip "[ \t]*\\*+/")
+  (setq-local block-comment-start "/*")
+  (setq-local block-comment-end "*/")
   (setq-local electric-indent-chars
               (append css-electric-keys electric-indent-chars))
   ;; The default "." creates ambiguity with class selectors.
@@ -2070,6 +2072,8 @@ scss-mode
   "Major mode to edit \"Sassy CSS\" files."
   (setq-local comment-start "// ")
   (setq-local comment-end "")
+  (setq-local block-comment-start "/*")
+  (setq-local block-comment-end "*/")
   (setq-local comment-continue " *")
   (setq-local comment-start-skip "/[*/]+[ \t]*")
   (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 2accd31bc36..4dbc6839c68 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -622,6 +622,8 @@ sgml-mode
   (setq-local indent-line-function #'sgml-indent-line)
   (setq-local comment-start "<!-- ")
   (setq-local comment-end " -->")
+  (setq-local block-comment-start "<!--")
+  (setq-local block-comment-end "-->")
   (setq-local comment-indent-function #'sgml-comment-indent)
   (setq-local comment-line-break-function #'sgml-comment-indent-new-line)
   (setq-local skeleton-further-elements '((completion-ignore-case t)))
-- 
2.49.0

-- 
                                          - E.G via GNU Emacs and Org.