From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.bugs Subject: bug#19399: js mode comment-filling fixlet Date: Mon, 09 Jan 2017 20:40:14 -0700 Message-ID: <87k2a31t29.fsf@tromey.com> References: <877f662krq.fsf@tromey.com> <8760lq2jg1.fsf@users.sourceforge.net> <87wpe6149s.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484019692 15833 195.159.176.226 (10 Jan 2017 03:41:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Jan 2017 03:41:32 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.90 (gnu/linux) Cc: 19399@debbugs.gnu.org, Daniel Colascione , npostavs@users.sourceforge.net To: Tom Tromey Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 10 04:41:27 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQnJE-0002UA-BS for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Jan 2017 04:41:16 +0100 Original-Received: from localhost ([::1]:44544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQnJI-00053K-OQ for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Jan 2017 22:41:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQnJA-00053D-2k for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 22:41:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQnIz-0003Eq-Tl for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 22:41:12 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:32916) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQnIz-0003Em-Q0 for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 22:41:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cQnIz-0001dK-J7 for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 22:41:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Jan 2017 03:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19399 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19399-submit@debbugs.gnu.org id=B19399.14840196326230 (code B ref 19399); Tue, 10 Jan 2017 03:41:01 +0000 Original-Received: (at 19399) by debbugs.gnu.org; 10 Jan 2017 03:40:32 +0000 Original-Received: from localhost ([127.0.0.1]:48315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQnIW-0001cP-9S for submit@debbugs.gnu.org; Mon, 09 Jan 2017 22:40:32 -0500 Original-Received: from gproxy2-pub.mail.unifiedlayer.com ([69.89.18.3]:43322) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cQnIU-0001cB-1M for 19399@debbugs.gnu.org; Mon, 09 Jan 2017 22:40:30 -0500 Original-Received: (qmail 14404 invoked by uid 0); 10 Jan 2017 03:40:20 -0000 Original-Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy2.mail.unifiedlayer.com with SMTP; 10 Jan 2017 03:40:20 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id WTgE1u00B2f2jeq01TgHpS; Mon, 09 Jan 2017 20:40:18 -0700 X-Authority-Analysis: v=2.1 cv=GNibTI9K c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IgFoBzBjUZAA:10 a=mDV3o1hIAAAA:8 a=dObRjJ9MPpm7IK3T74EA:9 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=UNC9J7mFDFJRMoRrum5QULoTCtknzW9qJtDMXJZwjSw=; b=Bp3y2iA9dkyfto4yQFgxXC++kM 7QopDYjIU8Fv0Yoo44oFZvUX2vzljFSr2mBxd21FCPqgTnWiDH5ea/Z1gK8+WXXjJ29kywXkbVzxL KbSL/6dwklnDltRvYXPLYEb7y; Original-Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:54892 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1cQnIF-000859-Mr; Mon, 09 Jan 2017 20:40:15 -0700 X-Attribution: Tom In-Reply-To: <87wpe6149s.fsf@tromey.com> (Tom Tromey's message of "Sat, 07 Jan 2017 22:58:55 -0700") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.146.181 X-Exim-ID: 1cQnIF-000859-Mr X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (bapiya) [174.16.146.181]:54892 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== 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: 208.118.235.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:127946 Archived-At: Tom> I think I should perhaps write some tests for this patch. Here's the patch with tests. I couldn't actually find a way to make the contents of c-block-comment-start-regexp matter. Tom diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index e3f64a8..1484b79 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3760,6 +3760,8 @@ js-mode c-line-comment-starter "//" c-comment-start-regexp "/[*/]\\|\\s!" comment-start-skip "\\(//+\\|/\\*+\\)\\s *") + (setq-local comment-line-break-function #'c-indent-new-comment-line) + (setq-local c-block-comment-start-regexp "/\\*") (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el new file mode 100644 index 0000000..9bf7258 --- /dev/null +++ b/test/lisp/progmodes/js-tests.el @@ -0,0 +1,64 @@ +;;; js-tests.el --- Test suite for js-mode + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'js) + +(ert-deftest js-mode-fill-bug-19399 () + (with-temp-buffer + (insert "/") + (save-excursion (insert "/ comment")) + (js-mode) + (fill-paragraph) + (should (equal (buffer-substring (point-min) (point-max)) + "// comment")))) + +(ert-deftest js-mode-fill-bug-22431 () + (with-temp-buffer + (insert "/**\n") + (insert " * Load the inspector's shared head.js for use by tests that ") + (insert "need to open the something or other") + (js-mode) + ;; This fails with auto-fill but not fill-paragraph. + (do-auto-fill) + (should (equal (buffer-substring (point-min) (point-max)) + "/** + * Load the inspector's shared head.js for use by tests that need to + * open the something or other")))) + +(ert-deftest js-mode-fill-bug-22431-fill-paragraph-at-start () + (with-temp-buffer + (insert "/**\n") + (insert " * Load the inspector's shared head.js for use by tests that ") + (insert "need to open the something or other") + (js-mode) + (goto-char (point-min)) + (fill-paragraph) + (should (equal (buffer-substring (point-min) (point-max)) + "/** + * Load the inspector's shared head.js for use by tests that need to + * open the something or other")))) + +(provide 'js-tests) + +;;; js-tests.el ends here