emacs-elpa-diffs
[Top][All Lists]
Advanced

[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:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]