--- preview.el~ 2019-06-22 22:15:33.280789000 +0900 +++ preview.el 2019-06-22 23:27:50.561977000 +0900 @@ -742,48 +742,52 @@ to Ghostscript floats." (format "%g" (/ value 65535.0))) +;; (defun preview-pdf-color-string (colors) +;; "Return a string that patches PDF foreground color to work properly." +;; ;; Actually, this is rather brutal. It will only be invoked in +;; ;; cases, however, where previously it was not expected that +;; ;; anything readable turned up, anyway. +;; (let ((fg (aref colors 1))) +;; (if fg +;; (concat +;; "/GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin\ +;; /graphicsbeginpage{//graphicsbeginpage exec " +;; (mapconcat #'preview-gs-color-value fg " ") +;; " 3 copy rg RG}bind store end readonly store ")))) (defun preview-pdf-color-string (colors) - "Return a string that patches PDF foreground color to work properly." - ;; Actually, this is rather brutal. It will only be invoked in - ;; cases, however, where previously it was not expected that - ;; anything readable turned up, anyway. - (let ((fg (aref colors 1))) - (if fg - (concat - "/GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin\ -/graphicsbeginpage{//graphicsbeginpage exec " - (mapconcat #'preview-gs-color-value fg " ") - " 3 copy rg RG}bind store end readonly store ")))) + "" "") +;; (defun preview-gs-color-string (colors) +;; "Return a string setting up colors" +;; (let ((bg (aref colors 0)) +;; (fg (aref colors 1)) +;; (mask (aref colors 2)) +;; (border (aref colors 3))) +;; (concat +;; (and (or (and mask border) (and bg (not fg))) +;; "gsave ") +;; (and bg +;; (concat +;; (mapconcat #'preview-gs-color-value bg " ") +;; " setrgbcolor clippath fill ")) +;; (and mask border +;; (format "%s setrgbcolor false setstrokeadjust %g \ +;; setlinewidth clippath strokepath \ +;; matrix setmatrix true \ +;; {2 index{newpath}if round exch round exch moveto pop false}\ +;; {round exch round exch lineto}{curveto}{closepath}\ +;; pathforall pop fill " +;; (mapconcat #'preview-gs-color-value mask " ") +;; (* 2 border))) +;; ;; I hate antialiasing. Warp border to integral coordinates. +;; (and (or (and mask border) (and bg (not fg))) +;; "grestore ") +;; (and fg +;; (concat +;; (mapconcat #'preview-gs-color-value fg " ") +;; " setrgbcolor"))))) (defun preview-gs-color-string (colors) - "Return a string setting up colors" - (let ((bg (aref colors 0)) - (fg (aref colors 1)) - (mask (aref colors 2)) - (border (aref colors 3))) - (concat - (and (or (and mask border) (and bg (not fg))) - "gsave ") - (and bg - (concat - (mapconcat #'preview-gs-color-value bg " ") - " setrgbcolor clippath fill ")) - (and mask border - (format "%s setrgbcolor false setstrokeadjust %g \ -setlinewidth clippath strokepath \ -matrix setmatrix true \ -{2 index{newpath}if round exch round exch moveto pop false}\ -{round exch round exch lineto}{curveto}{closepath}\ -pathforall pop fill " - (mapconcat #'preview-gs-color-value mask " ") - (* 2 border))) - ;; I hate antialiasing. Warp border to integral coordinates. - (and (or (and mask border) (and bg (not fg))) - "grestore ") - (and fg - (concat - (mapconcat #'preview-gs-color-value fg " ") - " setrgbcolor"))))) + "" "") (defun preview-dvipng-color-string (colors res) "Return color setup tokens for dvipng. @@ -1970,28 +1974,30 @@ (setcar (car file) (list attached (caar file)))) file) +;; (defun preview-delete-file (file) +;; "Delete a preview FILE. +;; See `preview-make-filename' for a description of the data +;; structure. If the containing directory becomes empty, +;; it gets deleted as well." +;; (let ((filename +;; (if (consp (car file)) +;; (and (zerop +;; (setcdr (car file) (1- (cdr (car file))))) +;; (car (car file))) +;; (car file)))) +;; (if filename +;; (unwind-protect +;; (if (listp filename) +;; (dolist (elt filename) (delete-file elt)) +;; (delete-file filename)) +;; (let ((tempdir (cdr file))) +;; (when tempdir +;; (if (> (nth 2 tempdir) 1) +;; (setcar (nthcdr 2 tempdir) (1- (nth 2 tempdir))) +;; (setcdr file nil) +;; (delete-directory (nth 0 tempdir))))))))) (defun preview-delete-file (file) - "Delete a preview FILE. -See `preview-make-filename' for a description of the data -structure. If the containing directory becomes empty, -it gets deleted as well." - (let ((filename - (if (consp (car file)) - (and (zerop - (setcdr (car file) (1- (cdr (car file))))) - (car (car file))) - (car file)))) - (if filename - (unwind-protect - (if (listp filename) - (dolist (elt filename) (delete-file elt)) - (delete-file filename)) - (let ((tempdir (cdr file))) - (when tempdir - (if (> (nth 2 tempdir) 1) - (setcar (nthcdr 2 tempdir) (1- (nth 2 tempdir))) - (setcdr file nil) - (delete-directory (nth 0 tempdir))))))))) + "" nil) (defvar preview-buffer-has-counters nil) (make-variable-buffer-local 'preview-buffer-has-counters) @@ -2215,7 +2221,8 @@ (defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\ \\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\ -\\AtBeginDocument{\\ifx\\ifPreview\\undefined" +\\AtBeginDocument{\\RequirePackage{color}\\color{white}\\pagecolor{red}\ +\\ifx\\ifPreview\\undefined" preview-default-preamble "\\fi}\"%' \"{\\detokenize{\" %t \"}}\"") ;; Since TeXLive 2018, the default encoding for LaTeX files has been ;; changed to UTF-8 if used with classic TeX or pdfTeX. I.e.,