mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
(find-auto-coding): Provide filename to auto-coding-functions
Allow `auto-coding-functions` to know the file name. Motivated by the needs of Editorconfig support. * lisp/international/mule.el (auto-coding-file-name): New var. (find-auto-coding): Let-bind it for `auto-coding-functions`. Document the expectation that the arg be an absolute file name. * doc/lispref/nonascii.texi (Default Coding Systems): Mention `auto-coding-file-name`. * test/lisp/international/mule-util-resources/test.utf-16le: New file. * test/lisp/international/mule-tests.el (mule-tests--dir): New var. (mule-tests--auto-coding): New fun. (mule-tests--auto-coding-functions): New test.
This commit is contained in:
parent
ce5d004b5b
commit
3ecc6b4f3c
5 changed files with 41 additions and 3 deletions
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
(require 'ert-x) ;For `ert-simulate-keys'.
|
||||
|
||||
(defconst mule-tests--dir (file-name-directory (macroexp-file-name)))
|
||||
|
||||
(ert-deftest find-auto-coding--bug27391 ()
|
||||
"Check that Bug#27391 is fixed."
|
||||
(with-temp-buffer
|
||||
|
|
@ -94,6 +96,23 @@
|
|||
;; The chinese-hz encoding is not ASCII compatible.
|
||||
(should-not (coding-system-get 'chinese-hz :ascii-compatible-p)))
|
||||
|
||||
(defun mule-tests--auto-coding (_size)
|
||||
(when (and (stringp auto-coding-file-name)
|
||||
(string-match-p "\\.utf-16le\\'" auto-coding-file-name))
|
||||
'utf-16le-with-signature))
|
||||
|
||||
(ert-deftest mule-tests--auto-coding-functions ()
|
||||
(unwind-protect
|
||||
(progn
|
||||
(add-hook 'auto-coding-functions #'mule-tests--auto-coding)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents
|
||||
(expand-file-name "mule-util-resources/test.utf-16le"
|
||||
mule-tests--dir))
|
||||
(goto-char (point-min))
|
||||
(should (search-forward "été" nil t))))
|
||||
(remove-hook 'auto-coding-functions #'mule-tests--auto-coding)))
|
||||
|
||||
;;; Testing `sgml-html-meta-auto-coding-function'.
|
||||
|
||||
(defvar sgml-html-meta-pre "<!doctype html><html><head>"
|
||||
|
|
|
|||
BIN
test/lisp/international/mule-util-resources/test.utf-16le
Normal file
BIN
test/lisp/international/mule-util-resources/test.utf-16le
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue