diff options
| author | Noam Postavsky | 2019-04-18 23:36:04 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2019-05-09 06:42:40 -0400 |
| commit | ca14dd1d4628094dd33d5d94694dcf5f29e843b8 (patch) | |
| tree | 3e875dde24b32704e647ba9853f52d341861a4a6 /test | |
| parent | e7ab351caa884755c032fd9544ba67a3c953144f (diff) | |
| download | emacs-ca14dd1d4628094dd33d5d94694dcf5f29e843b8.tar.gz emacs-ca14dd1d4628094dd33d5d94694dcf5f29e843b8.zip | |
Fix nxml-get-inside (Bug#32003)
The change from 2016-01-16 "lisp/nxml: Use syntax-tables for comments"
made nxml-get-inside return non-nil for any string or comment,
including attribute strings. This caused incorrect and therefore
indentation.
* lisp/nxml/nxml-rap.el: Update commentary to reflect changes to
nxml-mode parsing.
(nxml-get-inside): Only return non-nil when inside comments and
generic strings, not normal quote-delimited strings.
* test/lisp/nxml/nxml-mode-tests.el: New tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/nxml/nxml-mode-tests.el | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el new file mode 100644 index 00000000000..57a731ad182 --- /dev/null +++ b/test/lisp/nxml/nxml-mode-tests.el | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | ;;; nxml-mode-tests.el --- Test NXML Mode -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 6 | ;; it under the terms of the GNU General Public License as published by | ||
| 7 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 8 | ;; (at your option) any later version. | ||
| 9 | |||
| 10 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | ;; GNU General Public License for more details. | ||
| 14 | |||
| 15 | ;; You should have received a copy of the GNU General Public License | ||
| 16 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | ;;; Code: | ||
| 19 | |||
| 20 | (require 'ert) | ||
| 21 | (require 'nxml-mode) | ||
| 22 | |||
| 23 | (defun nxml-mode-tests-correctly-indented-string (str) | ||
| 24 | (with-temp-buffer | ||
| 25 | (nxml-mode) | ||
| 26 | (insert str) | ||
| 27 | (indent-region (point-min) (point-max)) | ||
| 28 | (equal (buffer-string) str))) | ||
| 29 | |||
| 30 | (ert-deftest nxml-indent-line-after-attribute () | ||
| 31 | (should (nxml-mode-tests-correctly-indented-string " | ||
| 32 | <settings | ||
| 33 | xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" | ||
| 34 | xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" | ||
| 35 | xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 | ||
| 36 | https://maven.apache.org/xsd/settings-1.0.0.xsd\"> | ||
| 37 | <mirrors> | ||
| 38 | ... | ||
| 39 | </mirrors> | ||
| 40 | </settings> | ||
| 41 | ")) | ||
| 42 | (should (nxml-mode-tests-correctly-indented-string "\ | ||
| 43 | <x> | ||
| 44 | <abc xx=\"x/x/x/x/x/x/x/ | ||
| 45 | y/y/y/y/y/y/ | ||
| 46 | \"> | ||
| 47 | <zzz/> | ||
| 48 | </abc> | ||
| 49 | <nl> </nl> | ||
| 50 | </x> | ||
| 51 | "))) | ||
| 52 | |||
| 53 | (ert-deftest nxml-balanced-close-start-tag-inline () | ||
| 54 | (with-temp-buffer | ||
| 55 | (nxml-mode) | ||
| 56 | (insert "<a><b c=\"\"</a>") | ||
| 57 | (search-backward "</a>") | ||
| 58 | (nxml-balanced-close-start-tag-inline) | ||
| 59 | (should (equal (buffer-string) "<a><b c=\"\"></b></a>")))) | ||
| 60 | |||
| 61 | (provide 'nxml-mode-tests) | ||
| 62 | ;;; nxml-mode-tests.el ends here | ||