From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#11165: 24.0.95; c-indent-new-comment-line bug or feature? Date: Sun, 27 Oct 2019 11:32:16 +0000 Message-ID: <20191027113216.GA27491@ACM> References: <20191025203405.GA24064@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="228587"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 11165@debbugs.gnu.org, sdl.web@gmail.com To: Daniel Colascione , Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 27 12:33:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iOgnH-000xJO-T3 for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Oct 2019 12:33:12 +0100 Original-Received: from localhost ([::1]:44926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOgnG-0003H0-OL for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Oct 2019 07:33:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50693) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOgn9-00036i-Lo for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2019 07:33:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOgn8-0002Et-6q for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2019 07:33:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32919) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iOgn8-0002Ep-33; Sun, 27 Oct 2019 07:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iOgn7-0004co-UC; Sun, 27 Oct 2019 07:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 27 Oct 2019 11:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11165 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 11165-submit@debbugs.gnu.org id=B11165.157217594517392 (code B ref 11165); Sun, 27 Oct 2019 11:33:01 +0000 Original-Received: (at 11165) by debbugs.gnu.org; 27 Oct 2019 11:32:25 +0000 Original-Received: from localhost ([127.0.0.1]:41740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOgmW-0004W3-C8 for submit@debbugs.gnu.org; Sun, 27 Oct 2019 07:32:24 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:47524 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1iOgmT-0004Sz-IL for 11165@debbugs.gnu.org; Sun, 27 Oct 2019 07:32:22 -0400 Original-Received: (qmail 4262 invoked by uid 3782); 27 Oct 2019 11:32:20 -0000 Original-Received: from acm.muc.de (p2E5D5E17.dip0.t-ipconnect.de [46.93.94.23]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 27 Oct 2019 12:32:16 +0100 Original-Received: (qmail 27755 invoked by uid 1000); 27 Oct 2019 11:32:16 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170240 Archived-At: Hello, Daniel and Glenn. On Sat, Oct 26, 2019 at 13:08:30 -0400, Glenn Morris wrote: > Alan Mackenzie wrote: > > commit 25ed447b7bec3af66cf0322239cfabbaf71bef26 of today, "CC Mode: Fix > > positioning of point whilst inserting comments without non-ws". > This change causes some test failures, ref eg > https://hydra.nixos.org/build/104351524 The failures were in js-mode (.../lisp/progmodes/js.el). The reason for the failures was js-mode failing completely to initialise a set of CC Mode "language variables", instead manually setting the few that have been used in the past. The lastest fix to CC Mode used another language variable, one that had not been explicitly set by js-mode. Thus js-mode's filling failed. I think the best way to fix this is, rather than adding an ad hoc setq for this variable, initialising a full set of language variables for js-mode (based on Java Mode). The following patch does this. It passes the Emacs test suite completely. Daniel, what do you think? diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 599923dd27..5f0913470f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -46,6 +46,9 @@ ;;; Code: (require 'cc-mode) +(eval-when-compile + (require 'cc-langs) + (require 'cc-fonts)) (require 'newcomment) (require 'imenu) (require 'moz nil t) @@ -4529,12 +4532,22 @@ js-jsx--detect-after-change (when (js-jsx--detect-and-enable 'arbitrarily) (remove-hook 'after-change-functions #'js-jsx--detect-after-change t)))))) +;; Ensure all CC Mode "lang variables" are set to valid values. +;; js-mode, however, currently uses only those needed for filling. +(eval-and-compile + (c-add-language 'js-mode 'java-mode)) + +(c-lang-defconst c-paragraph-start + js-mode "\\(@[[:alpha:]]+\\>\\|$\\)") + ;;; Main Function ;;;###autoload (define-derived-mode js-mode prog-mode "JavaScript" "Major mode for editing JavaScript." :group 'js + ;; Ensure all CC Mode "lang variables" are set to valid values. + (c-init-language-vars js-mode) (setq-local indent-line-function #'js-indent-line) (setq-local beginning-of-defun-function #'js-beginning-of-defun) (setq-local end-of-defun-function #'js-end-of-defun) @@ -4576,16 +4589,9 @@ js-mode (setq imenu-create-index-function #'js--imenu-create-index) ;; for filling, pretend we're cc-mode - (setq c-comment-prefix-regexp "//+\\|\\**" - c-paragraph-start "\\(@[[:alpha:]]+\\>\\|$\\)" - c-paragraph-separate "$" - c-block-comment-prefix "* " - c-line-comment-starter "//" - c-comment-start-regexp "/[*/]\\|\\s!") + (c-init-language-vars js-mode) (setq-local comment-line-break-function #'c-indent-new-comment-line) - (setq-local c-block-comment-start-regexp "/\\*") (setq-local comment-multi-line t) - (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". (setq-local electric-layout-rules @@ -4599,6 +4605,13 @@ js-mode (make-local-variable 'paragraph-ignore-fill-prefix) (make-local-variable 'adaptive-fill-mode) (make-local-variable 'adaptive-fill-regexp) + ;; While the full CC Mode style system is not yet in use, set the + ;; pertinent style variables manually. + (c-initialize-builtin-style) + (let ((style (cc-choose-style-for-mode 'js-mode c-default-style))) + (c-set-style style)) + (setq c-block-comment-prefix "* " + c-comment-prefix-regexp "//+\\|\\**") (c-setup-paragraph-variables)) ;; Important to fontify the whole buffer syntactically! If we don't, -- Alan Mackenzie (Nuremberg, Germany).