auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] [elpa] externals/auctex e0caf59 25/48: Drop compatibility


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex e0caf59 25/48: Drop compatibility code for older emacsen in preview-latex
Date: Sun, 16 Sep 2018 01:47:24 -0400 (EDT)

branch: externals/auctex
commit e0caf592e022449a67a7c74ddb477f01fbb612f6
Author: Ikumi Keita <address@hidden>
Commit: Ikumi Keita <address@hidden>

    Drop compatibility code for older emacsen in preview-latex
    
    We no longer need messy treatment with regard to coding system in
    preview-latex since xemacs isn't supported anymore.
    
    * preview.el.in (preview-coding-system): Remove.
    (preview-error-quote): Simplify.  Discard RUN-CODING-SYSTEM argument.
    (preview--decode-^^ab): Drop mule feature check.
    (preview--convert-^^ab): Drop compatibility code for older emacsen.
    (preview-parse-messages): Remove `run-coding-system' argument from
    calls to `preview-error-quote'.
    (TeX-inline-preview-internal): Drop codes related to coding system.
    * prv-emacs.el (preview-buffer-recode-system): Remove.
    * tests/japanese/preview-latex.el
    (japanese-preview-error-quote-shift-jis): Remove `shift_jis' argument
    from call to `preview-error-quote'.
    Remove unnecessary let bind on `TeX-japanese-process-output-coding-system'.
    (japanese-preview-process-coding-system): Remove.
    (japanese-preview-shift-jis):
    (japanese-preview-different-coding-system): Use `copy-sequence' on
    `process-environment' in order to guard it from temporal `setenv'.
---
 preview.el.in                   | 62 +++++++++--------------------------------
 prv-emacs.el                    |  8 +-----
 tests/japanese/preview-latex.el | 52 ++++------------------------------
 3 files changed, 20 insertions(+), 102 deletions(-)

diff --git a/preview.el.in b/preview.el.in
index 113d8f9..9f061c0 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -1,6 +1,7 @@
 ;;; preview.el --- embed preview LaTeX images in source buffer
 
-;; Copyright (C) 2001-2006, 2010-2015, 2017  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2006, 2010-2015,
+;;               2017, 2018  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: tex, wp, convenience
@@ -286,9 +287,6 @@ If `preview-fast-conversion' is set, this option is not
   :group 'preview-gs
   :type 'number)
 
-(defvar preview-coding-system nil
-  "Proper coding system to decode output from LaTeX process.")
-(make-variable-buffer-local 'preview-coding-system)
 (defvar preview-parsed-font-size nil
   "Font size as parsed from the log of LaTeX run.")
 (make-variable-buffer-local 'preview-parsed-font-size)
@@ -2599,14 +2597,11 @@ later while in use."
     ("Tightpage" preview-parsed-tightpage
      "\` *\(-?[0-9]+ *\)\{4\}\'" 0 preview-parse-tightpage)))
 
-(defun preview-error-quote (string run-coding-system)
+(defun preview-error-quote (string)
   "Turn STRING with potential ^^ sequences into a regexp.
 To preserve sanity, additional ^ prefixes are matched literally,
 so the character represented by ^^^ preceding extended characters
-will not get matched, usually.
-
-If decoding the process output was suppressed during receiving,
-decode first with RUN-CODING-SYSTEM."
+will not get matched, usually."
   (let (output case-fold-search)
     ;; Some coding systems (e.g. japanese-shift-jis) use regexp meta
     ;; characters on encoding.  Such meta characters would be
@@ -2614,19 +2609,12 @@ decode first with RUN-CODING-SYSTEM."
     ;; "encoding entire string beforehand and decoding it at the last
     ;; stage" does not work for such coding systems.
     ;; Rather, we work consistently with decoded text.
-    (if (and (featurep 'mule)
-            (not (eq run-coding-system
-                     (preview-buffer-recode-system run-coding-system))))
-       (setq string
-             (decode-coding-string string run-coding-system)))
-
-    ;; Next, bytes with value from 0x80 to 0xFF represented with ^^
-    ;; form are converted to byte sequence, and decoded by the file
-    ;; coding system.
+
+    ;; Bytes with value from 0x80 to 0xFF represented with ^^ form are
+    ;; converted to byte sequence, and decoded by the file coding
+    ;; system.
     (setq string
-         (preview--decode-^^ab string
-                               (if (featurep 'mule)
-                                   buffer-file-coding-system nil)))
+         (preview--decode-^^ab string buffer-file-coding-system))
 
     ;; Then, control characters are taken into account.
     (while (string-match "\^\{2,\}\(address@hidden)" string)
@@ -2665,9 +2653,7 @@ Return a new string."
                           (save-match-data
                             (preview--convert-^^ab
                              (match-string 0 string)))))
-                     (if (featurep 'mule)
-                         (decode-coding-string text coding-system)
-                       text)))
+                     (decode-coding-string text coding-system)))
            string (substring string (match-end 0))))
     (setq result (concat result string))
     result))
@@ -2686,12 +2672,7 @@ Return a new string."
                                 (substring string
                                            (+ (match-beginning 0) 2)
                                            (match-end 0)) 16)))
-                     ;; `char-to-string' is not appropriate in
-                     ;; Emacs >= 23 because it converts #xAB into
-                     ;; "\u00AB" (multibyte string), not "\xAB"
-                     ;; (raw 8bit unibyte string).
-                     (if (fboundp 'byte-to-string)
-                         (byte-to-string byte) (char-to-string byte))))
+                     (byte-to-string byte)))
            string (substring string (match-end 0))))
     (setq result (concat result string))
     result))
@@ -2712,7 +2693,6 @@ call, and in its CDR the final stuff for the placement 
hook."
          offset
          parsestate (case-fold-search nil)
          (run-buffer (current-buffer))
-         (run-coding-system preview-coding-system)
          (run-directory default-directory)
          tempdir
          close-data
@@ -2956,13 +2936,11 @@ name(\([^)]+\))\)\|\
                         (concat "\("
                                 (setq string
                                       (preview-error-quote
-                                       string
-                                       run-coding-system))
+                                       string))
                                 "\)"
                                 (setq after-string
                                       (preview-error-quote
-                                       after-string
-                                       run-coding-system)))
+                                       after-string)))
                         (line-end-position) t)
                        (goto-char (match-end 1)))
                       ((search-forward-regexp
@@ -3562,20 +3540,6 @@ internal parameters, STR may be a log to insert into the 
current log."
          (preview-set-geometry geometry)
          (setq preview-gs-file pr-file)
          (setq TeX-sentinel-function 'preview-TeX-inline-sentinel)
-         ;; Postpone decoding of process output for xemacs 21.4,
-         ;; which is rather bad at preserving incomplete multibyte
-         ;; characters.
-         (when (featurep 'mule)
-           ;; Get process coding system set in `TeX-run-command'.
-           (setq preview-coding-system (process-coding-system process))
-           ;; Substitute coding system for decode with `raw-text' if
-           ;; necessary and save the original coding system for
-           ;; decode for later use in `preview-error-quote'.
-           (set-process-coding-system process
-                                      (preview-buffer-recode-system
-                                       (car preview-coding-system))
-                                      (cdr preview-coding-system))
-           (setq preview-coding-system (car preview-coding-system)))
          (TeX-parse-reset)
          (setq TeX-parse-function 'TeX-parse-TeX)
          (if TeX-process-asynchronous
diff --git a/prv-emacs.el b/prv-emacs.el
index 9f40736..fe0f8f9 100644
--- a/prv-emacs.el
+++ b/prv-emacs.el
@@ -1,6 +1,6 @@
 ;;; prv-emacs.el --- GNU Emacs specific code for preview.el
 
-;; Copyright (C) 2001, 02, 03, 04, 05  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2005, 2018  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: convenience, tex, wp
@@ -369,12 +369,6 @@ purposes."
           event
         (posn-window (event-start event))))))
 
-(defsubst preview-buffer-recode-system (base)
-  "This is supposed to translate unrepresentable base encodings
-into something that can be used safely for byte streams in the
-run buffer.  A noop for Emacs."
-  base)
-
 (defun preview-mode-setup ()
   "Setup proper buffer hooks and behavior for previews."
   (set (make-local-variable 'desktop-save-buffer)
diff --git a/tests/japanese/preview-latex.el b/tests/japanese/preview-latex.el
index 44697d6..4831942 100644
--- a/tests/japanese/preview-latex.el
+++ b/tests/japanese/preview-latex.el
@@ -1,6 +1,6 @@
 ;;; preview-latex.el --- tests for preview-latex compatibility
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017, 2018 Free Software Foundation, Inc.
 
 ;; This file is part of AUCTeX.
 
@@ -37,7 +37,7 @@
 
 ;; Make sure coding system output from tex process to be expected
 ;; value.
-(setq japanese-TeX-use-kanji-opt-flag t) ; assume unix or darwin.
+(setq japanese-TeX-use-kanji-opt-flag t)
 
 (setq TeX-process-asynchronous t)
 (setq TeX-after-start-process-function #'TeX-adjust-process-coding-system)
@@ -51,7 +51,7 @@ character used to cause trouble.  Such patterns are tested."
   (skip-unless (not noninteractive))
   (let ((TeX-clean-confirm nil)
        (preview-auto-cache-preamble nil)
-       (process-environment process-environment)
+       (process-environment (copy-sequence process-environment))
        (locale-coding-system 'shift_jis)
        (TeX-japanese-process-output-coding-system nil)
        (TeX-japanese-process-input-coding-system nil))
@@ -101,7 +101,7 @@ the process differ."
   (skip-unless (not noninteractive))
   (let ((TeX-clean-confirm nil)
        (preview-auto-cache-preamble nil)
-       (process-environment process-environment)
+       (process-environment (copy-sequence process-environment))
        (locale-coding-system 'shift_jis)
        (TeX-japanese-process-output-coding-system nil)
        (TeX-japanese-process-input-coding-system nil))
@@ -190,10 +190,9 @@ Did the image come out at the correct position? ")))
   "`preview-error-quote' is robust against `shift_jis' or not.
 String encoded in `shift_jis' can have regexp meta characters in it."
   (let (case-fold-search
-       (buffer-file-coding-system 'shift_jis)
-       (TeX-japanese-process-output-coding-system nil))
+       (buffer-file-coding-system 'shift_jis))
     (dolist (str '("$BI=(B(1)" "$BM=(B{a}" "$BG=(B\|" "{$B$"(B} 
%$BG=(B" "$B%"!<%9(B" "$B7?(B"))
-      (should (string-match (preview-error-quote str 'shift_jis) str)))))
+      (should (string-match (preview-error-quote str) str)))))
 
 (ert-deftest japanese-preview-decode-^^ab ()
   "`preview--decode-^^ab' doesn't leave regexp meta characters in results."
@@ -215,45 +214,6 @@ String encoded in `shift_jis' can have regexp meta 
characters in it."
     (should (string= (preview--convert-^^ab "^^^a0") "^\xa0"))
     (should (string= (preview--convert-^^ab "^^c0^^Ab") "\xc0^^Ab"))))
 
-(ert-deftest japanese-preview-process-coding-system ()
-  "`TeX-inline-preview-internal' records process coding system or not.
-It used to discard the coding system for decode without recording
-previously set by `japanese-TeX-set-process-coding-system'."
-  (let ((dummyfile (make-temp-file "japanese-TeX-ert"))
-       (file-cs 'japanese-shift-jis-unix)
-       (locale-cs 'japanese-iso-8bit-unix)
-       ;; Make `preview-call-hook' inactive.
-       (preview-image-creators nil)
-       process)
-    (find-file dummyfile)
-    ;; Make `japanese-TeX-set-process-coding-system' to be called in
-    ;; `TeX-adjust-process-coding-system'.
-    (setq japanese-TeX-mode t)
-    (setq buffer-file-coding-system file-cs)
-    (unwind-protect
-       (progn
-         (setq process (TeX-inline-preview-internal
-                        "echo foo" dummyfile '(nil . nil) (current-buffer)
-                        '(nil . nil) dummyfile '(nil nil nil)))
-         ;; coding system assigned by `TeX-run-command' should be saved in
-         ;; `preview-coding-system'.
-         (should (coding-system-equal locale-cs preview-coding-system))
-         ;; actual process coding system should be the one derived from the
-         ;; original coding system via `preview-buffer-recode-system'.
-         (should (coding-system-equal
-                  (car (process-coding-system process))
-                  (preview-buffer-recode-system locale-cs)))))
-    ;; Cleanup.
-    ;; Let process to exit before finishing test.
-    (accept-process-output process)
-    (set-buffer (get-file-buffer dummyfile))
-    (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t)))
-          (process (get-buffer-process buffer)))
-      (if process (delete-process process))
-      (kill-buffer buffer))
-    (kill-buffer)
-    (delete-file dummyfile)))
-
 (ert-deftest japanese-preview-preserve-kanji-option2 ()
   "`TeX-inline-preview-internal' preserve kanji option or not."
   (let ((TeX-clean-confirm nil)



reply via email to

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