diff options
| author | Benjamin Riefenstahl | 2019-07-14 17:09:39 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-07-20 12:27:19 +0300 |
| commit | e6bfc6753cac7d8eaf67ff3adea0087eb19e7f6e (patch) | |
| tree | e74eb6aada34a6aceb6d6e7284667f2fd18f9915 /test | |
| parent | 070dd439096c0f72d8f73823649e3c650f31c890 (diff) | |
| download | emacs-e6bfc6753cac7d8eaf67ff3adea0087eb19e7f6e.tar.gz emacs-e6bfc6753cac7d8eaf67ff3adea0087eb19e7f6e.zip | |
Make REs in magic-(fallback-)mode-alist case-sensitive.
These variables are used for well-defined file formats where relaxed
case matching is not wanted usually.
* lisp/files.el (magic-mode-alist, magic-fallback-mode-alist): Update
the doc string.
(set-auto-mode): Make looking-at for elements of magic-mode-alist and
magic-fallback-mode-alist use case-fold-search == nil.
* lisp/files.el (files-test-magic-mode-alist-re-baseline)
(files-test-magic-mode-alist-re-no-match)
(files-test-magic-mode-alist-re-case-diff): Add.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/files-tests.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index aa5dbe7acf9..df2c3f47ae0 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el | |||
| @@ -1282,5 +1282,32 @@ renaming only, rather than modified in-place." | |||
| 1282 | (should (equal (file-size-human-readable 10000 'si " " "bit") "10 kbit")) | 1282 | (should (equal (file-size-human-readable 10000 'si " " "bit") "10 kbit")) |
| 1283 | (should (equal (file-size-human-readable 10000 'iec " " "bit") "9.8 Kibit"))) | 1283 | (should (equal (file-size-human-readable 10000 'iec " " "bit") "9.8 Kibit"))) |
| 1284 | 1284 | ||
| 1285 | (ert-deftest files-test-magic-mode-alist-re-baseline () | ||
| 1286 | "Test magic-mode-alist with RE, expected behaviour for match." | ||
| 1287 | (let ((magic-mode-alist '(("my-tag" . text-mode)))) | ||
| 1288 | (with-temp-buffer | ||
| 1289 | (insert "my-tag") | ||
| 1290 | (normal-mode) | ||
| 1291 | (should (eq major-mode 'text-mode))))) | ||
| 1292 | |||
| 1293 | (ert-deftest files-test-magic-mode-alist-re-no-match () | ||
| 1294 | "Test magic-mode-alist with RE, expected behaviour for no match." | ||
| 1295 | (let ((magic-mode-alist '(("my-tag" . text-mode)))) | ||
| 1296 | (with-temp-buffer | ||
| 1297 | (insert "not-my-tag") | ||
| 1298 | (normal-mode) | ||
| 1299 | (should (not (eq major-mode 'text-mode)))))) | ||
| 1300 | |||
| 1301 | (ert-deftest files-test-magic-mode-alist-re-case-diff () | ||
| 1302 | "Test that regexps in magic-mode-alist are case-sensitive. | ||
| 1303 | See <https://debbugs.gnu.org/36401>." | ||
| 1304 | (let ((case-fold-search t) | ||
| 1305 | (magic-mode-alist '(("my-tag" . text-mode)))) | ||
| 1306 | (with-temp-buffer | ||
| 1307 | (goto-char (point-min)) | ||
| 1308 | (insert "My-Tag") | ||
| 1309 | (normal-mode) | ||
| 1310 | (should (not (eq major-mode 'text-mode)))))) | ||
| 1311 | |||
| 1285 | (provide 'files-tests) | 1312 | (provide 'files-tests) |
| 1286 | ;;; files-tests.el ends here | 1313 | ;;; files-tests.el ends here |