diff options
| author | Tom Tromey | 2017-01-09 20:42:43 -0700 |
|---|---|---|
| committer | Tom Tromey | 2017-01-13 12:38:36 -0700 |
| commit | 05fe74bec239bebea84cb6803120321c367d67d3 (patch) | |
| tree | c97352c290d455c8dadfceeabfd27240db50eaa1 | |
| parent | d018843e0e8065b1c9de9474521db069e1aa0025 (diff) | |
| download | emacs-05fe74bec239bebea84cb6803120321c367d67d3.tar.gz emacs-05fe74bec239bebea84cb6803120321c367d67d3.zip | |
Fix two js-mode filling bugs
Bug#19399 and Bug#22431:
* lisp/progmodes/js.el (js-mode): Set comment-line-break-function and
c-block-comment-start-regexp.
* test/lisp/progmodes/js-tests.el: New file.
| -rw-r--r-- | lisp/progmodes/js.el | 2 | ||||
| -rw-r--r-- | test/lisp/progmodes/js-tests.el | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index e3f64a8f327..1484b79739f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -3760,6 +3760,8 @@ If one hasn't been set, or if it's stale, prompt for a new one." | |||
| 3760 | c-line-comment-starter "//" | 3760 | c-line-comment-starter "//" |
| 3761 | c-comment-start-regexp "/[*/]\\|\\s!" | 3761 | c-comment-start-regexp "/[*/]\\|\\s!" |
| 3762 | comment-start-skip "\\(//+\\|/\\*+\\)\\s *") | 3762 | comment-start-skip "\\(//+\\|/\\*+\\)\\s *") |
| 3763 | (setq-local comment-line-break-function #'c-indent-new-comment-line) | ||
| 3764 | (setq-local c-block-comment-start-regexp "/\\*") | ||
| 3763 | 3765 | ||
| 3764 | (setq-local electric-indent-chars | 3766 | (setq-local electric-indent-chars |
| 3765 | (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". | 3767 | (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 00000000000..9bf7258eebe --- /dev/null +++ b/test/lisp/progmodes/js-tests.el | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | ;;; js-tests.el --- Test suite for js-mode | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | (require 'js) | ||
| 26 | |||
| 27 | (ert-deftest js-mode-fill-bug-19399 () | ||
| 28 | (with-temp-buffer | ||
| 29 | (insert "/") | ||
| 30 | (save-excursion (insert "/ comment")) | ||
| 31 | (js-mode) | ||
| 32 | (fill-paragraph) | ||
| 33 | (should (equal (buffer-substring (point-min) (point-max)) | ||
| 34 | "// comment")))) | ||
| 35 | |||
| 36 | (ert-deftest js-mode-fill-bug-22431 () | ||
| 37 | (with-temp-buffer | ||
| 38 | (insert "/**\n") | ||
| 39 | (insert " * Load the inspector's shared head.js for use by tests that ") | ||
| 40 | (insert "need to open the something or other") | ||
| 41 | (js-mode) | ||
| 42 | ;; This fails with auto-fill but not fill-paragraph. | ||
| 43 | (do-auto-fill) | ||
| 44 | (should (equal (buffer-substring (point-min) (point-max)) | ||
| 45 | "/** | ||
| 46 | * Load the inspector's shared head.js for use by tests that need to | ||
| 47 | * open the something or other")))) | ||
| 48 | |||
| 49 | (ert-deftest js-mode-fill-bug-22431-fill-paragraph-at-start () | ||
| 50 | (with-temp-buffer | ||
| 51 | (insert "/**\n") | ||
| 52 | (insert " * Load the inspector's shared head.js for use by tests that ") | ||
| 53 | (insert "need to open the something or other") | ||
| 54 | (js-mode) | ||
| 55 | (goto-char (point-min)) | ||
| 56 | (fill-paragraph) | ||
| 57 | (should (equal (buffer-substring (point-min) (point-max)) | ||
| 58 | "/** | ||
| 59 | * Load the inspector's shared head.js for use by tests that need to | ||
| 60 | * open the something or other")))) | ||
| 61 | |||
| 62 | (provide 'js-tests) | ||
| 63 | |||
| 64 | ;;; js-tests.el ends here | ||