diff options
| author | Philipp Stephani | 2017-06-16 23:49:09 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-06-17 16:10:51 +0200 |
| commit | c3813b2aa8d2f5a625195fdbbfe6a01a602d7735 (patch) | |
| tree | 1bf3a0498632f317ed27e6e7d99171d611964f4d | |
| parent | 5575db9216e949fa1535dac33eec9b2abb48fab4 (diff) | |
| download | emacs-c3813b2aa8d2f5a625195fdbbfe6a01a602d7735.tar.gz emacs-c3813b2aa8d2f5a625195fdbbfe6a01a602d7735.zip | |
Allow local variables section to begin with a square bracket
Fixes Bug#27391.
* lisp/international/mule.el (find-auto-coding): Fix regular
expression for "Local Variables" section.
* test/lisp/international/mule-tests.el (find-auto-coding--bug27391):
Add unit test.
| -rw-r--r-- | lisp/international/mule.el | 2 | ||||
| -rw-r--r-- | test/lisp/international/mule-tests.el | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index fa3ad80e2f7..6cfb7e6d457 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -1970,7 +1970,7 @@ use \"coding: 'raw-text\" instead." | |||
| 1970 | (goto-char tail-start) | 1970 | (goto-char tail-start) |
| 1971 | (re-search-forward "[\r\n]\^L" tail-end t) | 1971 | (re-search-forward "[\r\n]\^L" tail-end t) |
| 1972 | (if (re-search-forward | 1972 | (if (re-search-forward |
| 1973 | "[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]" | 1973 | "[\r\n]\\([^\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]" |
| 1974 | tail-end t) | 1974 | tail-end t) |
| 1975 | ;; The prefix is what comes before "local variables:" in its | 1975 | ;; The prefix is what comes before "local variables:" in its |
| 1976 | ;; line. The suffix is what comes after "local variables:" | 1976 | ;; line. The suffix is what comes after "local variables:" |
diff --git a/test/lisp/international/mule-tests.el b/test/lisp/international/mule-tests.el new file mode 100644 index 00000000000..d7453332437 --- /dev/null +++ b/test/lisp/international/mule-tests.el | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | ;;; mule-tests.el --- unit tests for mule.el -*- lexical-binding: t; -*- | ||
| 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 | ;; Unit tests for lisp/international/mule.el. | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (ert-deftest find-auto-coding--bug27391 () | ||
| 27 | "Check that Bug#27391 is fixed." | ||
| 28 | (with-temp-buffer | ||
| 29 | (insert "\n[comment]: # ( Local Variables: )\n" | ||
| 30 | "[comment]: # ( coding: utf-8 )\n" | ||
| 31 | "[comment]: # ( End: )\n") | ||
| 32 | (goto-char (point-min)) | ||
| 33 | (should (equal (let ((auto-coding-alist ()) | ||
| 34 | (auto-coding-regexp-alist ()) | ||
| 35 | (auto-coding-functions ())) | ||
| 36 | (find-auto-coding "" (buffer-size))) | ||
| 37 | '(utf-8 . :coding))))) | ||
| 38 | |||
| 39 | ;;; mule-tests.el ends here | ||