From 0c4b87bd5c7128302e7e4639c3dd2a9318578c40 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 22 Apr 2025 20:42:45 +0800 Subject: [PATCH] Revert addition of electric-block-comment-mode & follow-up commits MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 AuthorDate: Mon Mar 17 12:56:52 2025 -0600 New minor mode: `electric-block-comment-mode' Author: Elías Gabriel Pérez 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 AuthorDate: Sun Apr 13 12:26:08 2025 -0600 Add block-comment variables to cc-mode (cherry picked from commit 4808f785ccb0166a87983405c6317ab2a4d6dfde) --- lisp/electric.el | 32 ---------------------------- 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/cc-cmds.el | 1 - lisp/progmodes/cc-mode.el | 2 -- 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 -- 16 files changed, 5 insertions(+), 69 deletions(-) diff --git a/lisp/electric.el b/lisp/electric.el index 43cb8e8f8f5..7aacb3af39f 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -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 diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 39425e1c983..ab8ea467b2d 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -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 () diff --git a/lisp/newcomment.el b/lisp/newcomment.el index eb36f91104d..945187e863f 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -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- 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. diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 994b2779d1a..7acc19b9058 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -529,8 +529,6 @@ Many aspects this mode can be customized using (setq-local comment-start-skip "") (setq-local comment-end-skip "[ \t\r\n]*-->") - (setq-local block-comment-start "") (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 d6516f185b2..1f7b35e6cd8 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -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 diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 06397d23321..9230faa56da 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -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))) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index ae7d27c0ae6..d500fb29959 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -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) diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index e012c7fdddd..79ad8a2fafd 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -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 diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 5078dc8d4dd..20e31391740 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 9d374119810..11ec5d5c079 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -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 diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index 9285582724c..4bc619d8fbf 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -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) diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el index 9dcaff9645e..bd6bc3b28ac 100644 --- a/lisp/progmodes/opascal.el +++ b/lisp/progmodes/opascal.el @@ -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 diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el index 113cf68c8d6..b6316d4dfe1 100644 --- a/lisp/progmodes/pascal.el +++ b/lisp/progmodes/pascal.el @@ -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)) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 9154d5cd99f..254ed1cc345 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -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)))) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 03a5f144dae..fec92d07adc 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -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\\|\\*+/\\)") diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index c188fa2d3d1..c4a000dbfc8 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -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 block-comment-start "") (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.39.5