diff options
author | Noam Postavsky <npostavs@gmail.com> | 2018-05-11 13:44:46 -0400 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2018-05-23 07:53:58 -0400 |
commit | 6f037f427a25160168e842bff0d12b816d69067d (patch) | |
tree | fdcb0290e8f9e1a957ffab079b1f4d2f9bfdeb34 /test/src/print-tests.el | |
parent | 0d224e82411d9471f03fc339890d6a2952b5e239 (diff) | |
download | emacs-6f037f427a25160168e842bff0d12b816d69067d.tar.gz emacs-6f037f427a25160168e842bff0d12b816d69067d.tar.bz2 emacs-6f037f427a25160168e842bff0d12b816d69067d.zip |
Honor print-charset-text-property value of nil (Bug#31376)
* src/print.c (print_check_string_charset_prop): Move check
for nil Vprint_charset_text_property from here...
(print_prune_string_charset): ... to here.
(syms_of_print) <print-charset-text-property>: Clarify that any
non-boolean values are treated the same as `default'.
* doc/lispref/streams.texi (Output Variables): Add
print-prune-string-charset.
* test/src/print-tests.el (print-charset-text-property-nil)
(print-charset-text-property-default)
(print-charset-text-property-t): New tests.
(print-tests--prints-with-charset-p): New helper function.
Diffstat (limited to 'test/src/print-tests.el')
-rw-r--r-- | test/src/print-tests.el | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 01e65028bc7..c96cb5d2b69 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el @@ -27,6 +27,42 @@ (prin1-to-string "\u00A2\ff")) "\"\\x00a2\\ff\""))) +(defun print-tests--prints-with-charset-p (ch odd-charset) + "Return t if `prin1-to-string' prints CH with the `charset' property. +CH is propertized with a `charset' value according to +ODD-CHARSET: if nil, then use the one returned by `char-charset', +otherwise, use a different charset." + (integerp + (string-match + "charset" + (prin1-to-string + (propertize (string ch) + 'charset + (if odd-charset + (cl-find (char-charset ch) charset-list :test-not #'eq) + (char-charset ch))))))) + +(ert-deftest print-charset-text-property-nil () + (let ((print-charset-text-property nil)) + (should-not (print-tests--prints-with-charset-p ?\xf6 t)) ; Bug#31376. + (should-not (print-tests--prints-with-charset-p ?a t)) + (should-not (print-tests--prints-with-charset-p ?\xf6 nil)) + (should-not (print-tests--prints-with-charset-p ?a nil)))) + +(ert-deftest print-charset-text-property-default () + (let ((print-charset-text-property 'default)) + (should (print-tests--prints-with-charset-p ?\xf6 t)) + (should-not (print-tests--prints-with-charset-p ?a t)) + (should-not (print-tests--prints-with-charset-p ?\xf6 nil)) + (should-not (print-tests--prints-with-charset-p ?a nil)))) + +(ert-deftest print-charset-text-property-t () + (let ((print-charset-text-property t)) + (should (print-tests--prints-with-charset-p ?\xf6 t)) + (should (print-tests--prints-with-charset-p ?a t)) + (should (print-tests--prints-with-charset-p ?\xf6 nil)) + (should (print-tests--prints-with-charset-p ?a nil)))) + (ert-deftest terpri () (should (string= (with-output-to-string (princ 'abc) |