diff options
author | Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net> | 2019-07-14 17:09:39 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2019-07-20 12:27:19 +0300 |
commit | e6bfc6753cac7d8eaf67ff3adea0087eb19e7f6e (patch) | |
tree | e74eb6aada34a6aceb6d6e7284667f2fd18f9915 /test/lisp/files-tests.el | |
parent | 070dd439096c0f72d8f73823649e3c650f31c890 (diff) | |
download | emacs-e6bfc6753cac7d8eaf67ff3adea0087eb19e7f6e.tar.gz emacs-e6bfc6753cac7d8eaf67ff3adea0087eb19e7f6e.tar.bz2 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/lisp/files-tests.el')
-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." (should (equal (file-size-human-readable 10000 'si " " "bit") "10 kbit")) (should (equal (file-size-human-readable 10000 'iec " " "bit") "9.8 Kibit"))) +(ert-deftest files-test-magic-mode-alist-re-baseline () + "Test magic-mode-alist with RE, expected behaviour for match." + (let ((magic-mode-alist '(("my-tag" . text-mode)))) + (with-temp-buffer + (insert "my-tag") + (normal-mode) + (should (eq major-mode 'text-mode))))) + +(ert-deftest files-test-magic-mode-alist-re-no-match () + "Test magic-mode-alist with RE, expected behaviour for no match." + (let ((magic-mode-alist '(("my-tag" . text-mode)))) + (with-temp-buffer + (insert "not-my-tag") + (normal-mode) + (should (not (eq major-mode 'text-mode)))))) + +(ert-deftest files-test-magic-mode-alist-re-case-diff () + "Test that regexps in magic-mode-alist are case-sensitive. +See <https://debbugs.gnu.org/36401>." + (let ((case-fold-search t) + (magic-mode-alist '(("my-tag" . text-mode)))) + (with-temp-buffer + (goto-char (point-min)) + (insert "My-Tag") + (normal-mode) + (should (not (eq major-mode 'text-mode)))))) + (provide 'files-tests) ;;; files-tests.el ends here |