]> git.eshelyaron.com Git - emacs.git/commitdiff
Revert addition of electric-block-comment-mode & follow-up commits
authorSean Whitton <spwhitton@spwhitton.name>
Tue, 22 Apr 2025 12:42:45 +0000 (20:42 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Apr 2025 17:57:30 +0000 (19:57 +0200)
As presently under discussion in bug#77823, the intended new
functionality is not really about comments at all.
Remove it for now to allow us to redesign from a clean slate,
and to deal with the regression reported in bug#77823.

This reverts the following three changesets:

Author:     Elías Gabriel Pérez <eg642616@gmail.com>
AuthorDate: Mon Mar 17 12:56:52 2025 -0600

  New minor mode: `electric-block-comment-mode'

Author:     Elías Gabriel Pérez <eg642616@gmail.com>
AuthorDate: Mon Mar 31 17:58:16 2025 -0600

  Add block-comment-start and block-comment-end to supported modes

Author:     Elías Gabriel Pérez <eg642616@gmail.com>
AuthorDate: Sun Apr 13 12:26:08 2025 -0600

  Add block-comment variables to cc-mode

(cherry picked from commit 4808f785ccb0166a87983405c6317ab2a4d6dfde)

16 files changed:
lisp/electric.el
lisp/emacs-lisp/lisp-mode.el
lisp/newcomment.el
lisp/nxml/nxml-mode.el
lisp/progmodes/c-ts-common.el
lisp/progmodes/cc-cmds.el
lisp/progmodes/cc-mode.el
lisp/progmodes/go-ts-mode.el
lisp/progmodes/js.el
lisp/progmodes/json-ts-mode.el
lisp/progmodes/lua-ts-mode.el
lisp/progmodes/opascal.el
lisp/progmodes/pascal.el
lisp/progmodes/typescript-ts-mode.el
lisp/textmodes/css-mode.el
lisp/textmodes/sgml-mode.el

index 43cb8e8f8f5016ef60e74eb80da54059167c4178..7aacb3af39f514f97d6d52d23b0d91caa55ffacc 100644 (file)
@@ -398,38 +398,6 @@ use `electric-quote-local-mode'."
     (setq-default electric-quote-mode nil) ; But keep it globally disabled.
     )))
 
-;;; Electric comment block
-
-(defun electric-block-comment-post-self-insert-function ()
-  "Function that `electric-block-comment' adds to `post-self-insert-hook'.
-This closes block comment with `block-comment-end' when `block-comment-start'
-is typed."
-  (when (and block-comment-start block-comment-end
-             ;; Check if we are exactly behind a `block-comment-start'
-             (save-excursion
-               (save-match-data
-                 (re-search-backward (regexp-quote block-comment-start)
-                                     (- (point) (length block-comment-start))
-                                     t)))
-             ;; And if there is not anything front us
-             (looking-at-p (concat "[^[:space:]]")))
-    (insert " ")
-    (save-excursion
-      (insert (concat " " block-comment-end)))))
-
-(define-minor-mode electric-block-comment-mode
-  "Toggle automatic closing of block comments (Electric Block Comment mode).
-
-When enabled, typing `block-comment-start' closes it inserting their
-corresponding `block-comment-end'."
-  :group 'electricity
-  :version "31.1"
-  (if electric-block-comment-mode
-      (add-hook 'post-self-insert-hook
-                #'electric-block-comment-post-self-insert-function 10 t)
-    (remove-hook 'post-self-insert-hook
-                 #'electric-block-comment-post-self-insert-function t)))
-
 (provide 'electric)
 
 ;;; electric.el ends here
index 39425e1c983a0af5be4c0d1c5b4ff706d38369ff..ab8ea467b2ddd4bb4efc893b7f21e5f2dc169bc9 100644 (file)
@@ -1159,8 +1159,6 @@ or to switch back to an existing one."
              "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
   (setq-local comment-end-skip "[ \t]*\\(\\s>\\||#\\)")
   (setq-local font-lock-comment-end-skip "|#")
-  (setq-local block-comment-start "#|")
-  (setq-local block-comment-end "|#")
   (setq imenu-case-fold-search t))
 
 (defun lisp-find-tag-default ()
index eb36f91104d262f853911be7694b54c26b57c77a..945187e863f31b55d063f33be43621a88242e637 100644 (file)
@@ -56,6 +56,7 @@
 ;; - 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
@@ -182,11 +183,9 @@ guaranteed to be correctly ordered.  It is called within `save-excursion'.
 Applicable at least in modes for languages like fixed-format Fortran where
 comments always start in column zero.")
 
-(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.")
+;; ?? never set
+(defvar block-comment-start nil)
+(defvar block-comment-end nil)
 
 (defvar comment-quote-nested t
   "Non-nil if nested comments should be quoted.
index 994b2779d1aac983c1a88da0efbf6804664decde..7acc19b90586f1edaddf71c5c299c55ce6ed98b8 100644 (file)
@@ -529,8 +529,6 @@ Many aspects this mode can be customized using
   (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
index d6516f185b24aeab68fea4a2328e049514529425..1f7b35e6cd829d63d81206c8ec5780b5ad0dc5bb 100644 (file)
@@ -282,8 +282,6 @@ Set up:
  - `comment-end'
  - `comment-start-skip'
  - `comment-end-skip'
- - `block-comment-start'
- - `block-comment-end'
  - `adaptive-fill-mode'
  - `adaptive-fill-first-line-regexp'
  - `paragraph-start'
@@ -300,8 +298,6 @@ Set up:
               (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
index 06397d2332195c5a610c10d72ab38316d7d53074..9230faa56daafec0bc45ee6d620f17ca9f809102 100644 (file)
@@ -5015,7 +5015,6 @@ If a fill prefix is specified, it overrides all the above."
                      (setq comment-start "/* " comment-end " */"))
                  (unless (string-match "[ \t]*//" comment-start)
                    (setq comment-start "// " comment-end "")))
-               (setq block-comment-start "/*" block-comment-end "*/")
                (setq col (save-excursion
                            (back-to-indentation)
                            (current-column)))
index ae7d27c0ae69c06c390680c59030bba3703725fe..d500fb299594f7e8ce02769c5ab72ba01bbcca31 100644 (file)
@@ -610,8 +610,6 @@ that requires a literal mode spec at compile time."
   (make-local-variable 'comment-start)
   (make-local-variable 'comment-end)
   (make-local-variable 'comment-start-skip)
-  (make-local-variable 'block-comment-start)
-  (make-local-variable 'block-comment-end)
 
   (make-local-variable 'paragraph-start)
   (make-local-variable 'paragraph-separate)
index e012c7fdddd61a2afdca0d007a96104f748b27fd..79ad8a2fafd62cb91d5dbc0df8b6967c0149bb95 100644 (file)
@@ -692,8 +692,6 @@ what the parent of the node would be if it were a node."
     (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
index 5078dc8d4ddfa232e43bce48d3f9313e8129b0ba..20e313917400226ac0d4805e5f0443a5ea06ea15 100644 (file)
@@ -3845,8 +3845,6 @@ Currently there are `js-mode' and `js-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 "*/")
   (setq-local fill-paragraph-function #'js-fill-paragraph)
   (setq-local normal-auto-fill-function #'js-do-auto-fill)
 
index 9d37411981077dbaaa78867dabe02b68f5c16981..11ec5d5c079bda64fa7481ee3b90b9d812967b7a 100644 (file)
@@ -142,8 +142,6 @@ Return nil if there is no name or if NODE is not a defun node."
   (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
index 9285582724c3f4326a05496cf0509edbbbe7b6c0..4bc619d8fbf4aaa54e6fbc2b9cf664ee8375b5c2 100644 (file)
@@ -672,8 +672,6 @@ Calls REPORT-FN directly."
     (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)
index 9dcaff9645e1df9a85b5635b95cc9629f0936109..bd6bc3b28ac08dfcf3a72452da2b8cc6886b175c 100644 (file)
@@ -1767,9 +1767,7 @@ Coloring:
 
   (setq-local comment-start "// ")
   (setq-local comment-start-skip "\\(?://\\|(\\*\\|{\\)[ \t]*")
-  (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*)\\|}\\)")
-  (setq-local block-comment-start "(*")
-  (setq-local block-comment-end "*)"))
+  (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*)\\|}\\)"))
 
 (provide 'opascal)
 ;;; opascal.el ends here
index 113cf68c8d607f83fa20c2a06895aa9a4efd6382..b6316d4dfe19b92b7c666f6c590737af854bc4ac 100644 (file)
@@ -348,8 +348,6 @@ See also the user variables `pascal-type-keywords', `pascal-start-keywords' and
   (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))
index 9154d5cd99f7331882e995150ab8e19a6b04ae18..254ed1cc345af1a4543911a742830dfeb7f7c3b3 100644 (file)
@@ -663,8 +663,6 @@ at least 3 (which is the default value)."
     ;; 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))))
index 03a5f144dae1d6bce9ec6d84cc20254e600beea2..fec92d07adcb104ed514170a0404d4373f4ada0f 100644 (file)
@@ -1858,8 +1858,6 @@ implementations: `css-mode' and `css-ts-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.
@@ -2083,8 +2081,6 @@ be used to fill comments.
   "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\\|\\*+/\\)")
index c188fa2d3d105a1ad5c86e4550daa7cccf2f4478..c4a000dbfc810a947295642e4d2136efe8c89347 100644 (file)
@@ -622,8 +622,6 @@ Do \\[describe-key] on the following bindings to discover what they do.
   (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)))