[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 0970844 02/67: Deal with partial ^^-quoting in p
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 0970844 02/67: Deal with partial ^^-quoting in preview-latex |
Date: |
Fri, 8 Feb 2019 11:40:27 -0500 (EST) |
branch: externals/auctex
commit 097084443771d6716c6870f2f8d329e9c0949d97
Author: Ikumi Keita <address@hidden>
Commit: Ikumi Keita <address@hidden>
Deal with partial ^^-quoting in preview-latex
If latex outputs a multibyte character as a mixture of raw 8-bit byte
and byte with ^^-quoting, we have to decode them as a whole.
* preview.el.in (preview--decode-^^ab): Include raw 8-bit bytes which
already exist in the string as well when decoding with the given
coding system.
* tests/latex/preview-latex-test.el: New test.
---
preview.el.in | 10 ++++++--
tests/latex/preview-latex-test.el | 49 +++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/preview.el.in b/preview.el.in
index 07dad50..91b3467 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -2650,9 +2650,15 @@ Sequences of control characters such as ^^I are left
untouched.
Return a new string."
;; Since the given string can contain multibyte characters, decoding
;; should be performed seperately on each segment made up entirely
- ;; with ASCII characters.
+ ;; with ASCII and raw 8-bit characters.
+ ;; Raw 8-bit characters can arise if the latex outputs multibyte
+ ;; characters with partial ^^-quoting.
(let ((result ""))
- (while (string-match "[\x00-\x7F]+" string)
+ (while (string-match "[\x00-\xFF]+" string)
+ ;; Strings between "\x80" and "\xFF" represent raw 8-bit, not
+ ;; unicode characters between U+0080 and U+00FF. The latter
+ ;; are represented by "\u0080" and so on in literal string.
+ ;; See Info node `(elisp)Non-ASCII Characters in Strings'.
(setq result
(concat result
(substring string 0 (match-beginning 0))
diff --git a/tests/latex/preview-latex-test.el
b/tests/latex/preview-latex-test.el
new file mode 100644
index 0000000..0249683
--- /dev/null
+++ b/tests/latex/preview-latex-test.el
@@ -0,0 +1,49 @@
+;;; preview-latex.el --- tests for preview-latex compatibility
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING. If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Code:
+
+(require 'ert)
+(require 'preview)
+
+(ert-deftest preview-error-quote-utf-8 ()
+ "`preview-error-quote' is robust against partial ^^-quoting or not.
+If a utf-8 byte sequence is partially ^^-quoted in latex output, we have
+to decode ^^ab as raw 8-bit character first and decode in the sense of
+emacs' coding system later."
+ (let (case-fold-search
+ (buffer-file-coding-system 'utf-8))
+ (dolist (str '("primárias"
+ ;; Unicode character á is encoded in utf-8 as
+ ;; a byte sequence \xC3 \xA1.
+ "prim\xC3\xA1rias" "prim^^c3\xA1rias" "prim^^c3^^a1rias"))
+ (should (string-match (preview-error-quote str) "primárias")))))
+
+(ert-deftest preview-decode-^^ab-utf-8 ()
+ "Test mixture of raw 8-bit byte and byte with ^^-quoting."
+ (dolist (str '("prim\xC3\xA1rias" "prim^^c3\xA1rias" "prim^^c3^^a1rias"))
+ (should (string= (preview--decode-^^ab str 'utf-8) "primárias"))))
+
+;;; preview-latex.el ends here
+
+;; Local Variables:
+;; coding: utf-8
+;; End:
- [elpa] externals/auctex updated (eca4ffe -> f34ce5a), Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 2152678 04/67: Change regexp for clarity, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 1ea64ff 01/67: Extract caption for RefTeX's label context, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 0970844 02/67: Deal with partial ^^-quoting in preview-latex,
Tassilo Horn <=
- [elpa] externals/auctex 3694373 05/67: Deal with space in path of MikTeX gs executable (Bug#32251), Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 10047fb 07/67: * style/fancyvrb.el (LaTeX-fancyvrb-key-val-options): Add vspace key., Tassilo Horn, 2019/02/08
- [elpa] externals/auctex c8a8d47 08/67: Don't block emacs during viewing document, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex f213b1b 10/67: Set `TeX-command-buffer' always (bug#33377), Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 06226ea 09/67: Adjust preview-latex in case sub file isn't in master directory, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex d8c6f94 06/67: Improve style/fancyvrb.el, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 7ede3be 03/67: Make style hooks associated with class options valid again, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex dad0c60 11/67: Surround both \langle and \rangle with math delimiter, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 8d0e9cd 13/67: style/enumitem.el ("enumitem"): Use `TeX-argument-prompt' for query., Tassilo Horn, 2019/02/08
- [elpa] externals/auctex da4cb3d 14/67: Improve behavior of `TeX-arg-beamer-overlay-spec', Tassilo Horn, 2019/02/08