"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "preview.el.in" between
auctex-12.2.tar.gz and auctex-12.3.tar.gz

About: AUCTEX is an extensible package for writing and formatting TeX files in GNU Emacs and XEmacs.

preview.el.in  (auctex-12.2):preview.el.in  (auctex-12.3)
;;; preview.el --- embed preview LaTeX images in source buffer ;;; preview.el --- embed preview LaTeX images in source buffer
;; Copyright (C) 2001-2006, 2010-2015, ;; Copyright (C) 2001-2006, 2010-2015,
;; 2017-2019 Free Software Foundation, Inc. ;; 2017-2020 Free Software Foundation, Inc.
;; Author: David Kastrup ;; Author: David Kastrup
;; Keywords: tex, wp, convenience ;; Keywords: tex, wp, convenience
;; This file is free software; you can redistribute it and/or modify ;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by ;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option) ;; the Free Software Foundation; either version 3, or (at your option)
;; any later version. ;; any later version.
;; This file is distributed in the hope that it will be useful, ;; This file is distributed in the hope that it will be useful,
skipping to change at line 58 skipping to change at line 58
(condition-case nil (condition-case nil
(require 'desktop) (require 'desktop)
(file-error (message "Missing desktop package: (file-error (message "Missing desktop package:
preview-latex buffers will not survive across sessions."))) preview-latex buffers will not survive across sessions.")))
(condition-case nil (condition-case nil
(require 'reporter) (require 'reporter)
(file-error (message "Missing reporter library, probably from the mail-lib p ackage: (file-error (message "Missing reporter library, probably from the mail-lib p ackage:
preview-latex's bug reporting commands will probably not work."))) preview-latex's bug reporting commands will probably not work.")))
(require 'info)) (require 'info))
(require 'prv-emacs)
(defgroup preview nil "Embed Preview images into LaTeX buffers." (defgroup preview nil "Embed Preview images into LaTeX buffers."
:group 'AUCTeX :group 'AUCTeX
:prefix "preview-" :prefix "preview-"
:link '(custom-manual "(preview-latex)Top") :link '(custom-manual "(preview-latex)Top")
:link '(info-link "(preview-latex)The Emacs interface") :link '(info-link "(preview-latex)The Emacs interface")
:link '(url-link :tag "Homepage" "https://www.gnu.org/software/auctex/")) :link '(url-link :tag "Homepage" "https://www.gnu.org/software/auctex/"))
(defgroup preview-gs nil "Preview's Ghostscript renderer." (defgroup preview-gs nil "Preview's Ghostscript renderer."
:group 'preview :group 'preview
:prefix "preview-") :prefix "preview-")
skipping to change at line 755 skipping to change at line 753
preview-gs-command-line) preview-gs-command-line)
" ") "''\n") " ") "''\n")
(setq preview-gs-answer "") (setq preview-gs-answer "")
(set-process-query-on-exit-flag process nil) (set-process-query-on-exit-flag process nil)
(set-process-sentinel process #'preview-gs-sentinel) (set-process-sentinel process #'preview-gs-sentinel)
(set-process-filter process #'preview-gs-filter) (set-process-filter process #'preview-gs-filter)
(process-send-string process preview-gs-init-string) (process-send-string process preview-gs-init-string)
(setq mode-name "Preview-Ghostscript") (setq mode-name "Preview-Ghostscript")
(push process compilation-in-progress) (push process compilation-in-progress)
(TeX-command-mode-line process) (TeX-command-mode-line process)
(set-buffer-modified-p (buffer-modified-p)) (force-mode-line-update)
process))) process)))
(defun preview-gs-open (&optional setup) (defun preview-gs-open (&optional setup)
"Start a Ghostscript conversion pass. "Start a Ghostscript conversion pass.
SETUP may contain a parser setup function." SETUP may contain a parser setup function."
(let ((image-info (assq preview-image-type preview-gs-image-type-alist))) (let ((image-info (assq preview-image-type preview-gs-image-type-alist)))
(setq preview-gs-image-type (nth 1 image-info)) (setq preview-gs-image-type (nth 1 image-info))
(setq preview-gs-sequence nil) (setq preview-gs-sequence nil)
(setq preview-gs-command-line (append (setq preview-gs-command-line (append
preview-gs-options preview-gs-options
skipping to change at line 789 skipping to change at line 787
;; Compatibility for gs 9.27 with non-trivial ;; Compatibility for gs 9.27 with non-trivial
;; foreground color and dark background. ;; foreground color and dark background.
;; Suppress color adjustment with PDF backend ;; Suppress color adjustment with PDF backend
;; when `preview-pdf-color-adjust-method' is nil. ;; when `preview-pdf-color-adjust-method' is nil.
(and (not preview-pdf-color-adjust-method) (and (not preview-pdf-color-adjust-method)
;; The switch `preview-parsed-pdfoutput' isn't ;; The switch `preview-parsed-pdfoutput' isn't
;; set before parsing the latex output, so use ;; set before parsing the latex output, so use
;; heuristic here. ;; heuristic here.
(with-current-buffer TeX-command-buffer (with-current-buffer TeX-command-buffer
(and TeX-PDF-mode (and TeX-PDF-mode
(not TeX-PDF-from-DVI))))))) (not (TeX-PDF-from-DVI))))))))
(preview-gs-queue-empty) (preview-gs-queue-empty)
(preview-parse-messages (or setup #'preview-gs-dvips-process-setup)))) (preview-parse-messages (or setup #'preview-gs-dvips-process-setup))))
(defun preview-gs-color-value (value) (defun preview-gs-color-value (value)
"Return string to be used as color value for an RGB component. "Return string to be used as color value for an RGB component.
Conversion from Emacs color numbers (0 to 65535) in VALUE Conversion from Emacs color numbers (0 to 65535) in VALUE
to Ghostscript floats." to Ghostscript floats."
(format "%g" (/ value 65535.0))) (format "%g" (/ value 65535.0)))
(defun preview-pdf-color-string (colors) (defun preview-pdf-color-string (colors)
skipping to change at line 889 skipping to change at line 887
(mapconcat #'preview-gs-color-value bg " "))) (mapconcat #'preview-gs-color-value bg " ")))
(and fg (and fg
(format "--fg \"rgb %s\" " (format "--fg \"rgb %s\" "
(mapconcat #'preview-gs-color-value fg " "))) (mapconcat #'preview-gs-color-value fg " ")))
(and mask border (and mask border
(format "--bd \"rgb %s\" " (format "--bd \"rgb %s\" "
(mapconcat #'preview-gs-color-value mask " "))) (mapconcat #'preview-gs-color-value mask " ")))
(and border (and border
(format "--bd %d" (max 1 (round (/ (* res border) 72.0)))))))) (format "--bd %d" (max 1 (round (/ (* res border) 72.0))))))))
(defsubst preview-supports-image-type (imagetype)
"Check if IMAGETYPE is supported."
(image-type-available-p imagetype))
(defun preview-gs-dvips-process-setup () (defun preview-gs-dvips-process-setup ()
"Set up Dvips process for conversions via gs." "Set up Dvips process for conversions via gs."
(unless (preview-supports-image-type preview-gs-image-type) (unless (preview-supports-image-type preview-gs-image-type)
(error "preview-image-type setting '%s unsupported by this Emacs" (error "preview-image-type setting '%s unsupported by this Emacs"
preview-gs-image-type)) preview-gs-image-type))
(setq preview-gs-command-line (append (setq preview-gs-command-line (append
preview-gs-command-line preview-gs-command-line
(list (preview-gs-resolution (list (preview-gs-resolution
(preview-hook-enquiry preview-scale) (preview-hook-enquiry preview-scale)
(car preview-resolution) (car preview-resolution)
skipping to change at line 1199 skipping to change at line 1201
;; We don't requeue if the overlay has been killed (its buffer made ;; We don't requeue if the overlay has been killed (its buffer made
;; nil). Not necessary, but while we are checking... ;; nil). Not necessary, but while we are checking...
;; We must return t. ;; We must return t.
(preview-remove-urgentization ov) (preview-remove-urgentization ov)
(when (and (overlay-get ov 'queued) (when (and (overlay-get ov 'queued)
(overlay-buffer ov)) (overlay-buffer ov))
(with-current-buffer buff (with-current-buffer buff
(push ov preview-gs-queue))) (push ov preview-gs-queue)))
t) t)
(defsubst preview-icon-copy (icon)
"Prepare a later call of `preview-replace-active-icon'."
;; This is just a GNU Emacs specific efficiency hack because it
;; is easy to do. When porting, don't do anything complicated
;; here, rather deliver just the unchanged icon and make
;; `preview-replace-active-icon' do the necessary work of replacing
;; the icon where it actually has been stored, probably
;; in the car of the strings property of the overlay. This string
;; might probably serve as a begin-glyph as well, in which case
;; modifying the string in the strings property would change that
;; glyph automatically.
(cons 'image (cdr icon)))
(defsubst preview-replace-active-icon (ov replacement)
"Replace the active Icon in OV by REPLACEMENT, another icon."
(let ((img (overlay-get ov 'preview-image)))
(setcdr (car img) (cdar replacement))
(setcdr img (cdr replacement))))
(defun preview-gs-place (ov snippet box run-buffer tempdir ps-file _imagetype) (defun preview-gs-place (ov snippet box run-buffer tempdir ps-file _imagetype)
"Generate an image placeholder rendered over by Ghostscript. "Generate an image placeholder rendered over by Ghostscript.
This enters OV into all proper queues in order to make it render This enters OV into all proper queues in order to make it render
this image for real later, and returns the overlay after setting this image for real later, and returns the overlay after setting
a placeholder image. SNIPPET gives the number of the a placeholder image. SNIPPET gives the number of the
snippet in question for the file to be generated. snippet in question for the file to be generated.
BOX is a bounding box if we already know one via TeX. BOX is a bounding box if we already know one via TeX.
RUN-BUFFER is the buffer of the TeX process, RUN-BUFFER is the buffer of the TeX process,
TEMPDIR is the correct copy of `TeX-active-tempdir', TEMPDIR is the correct copy of `TeX-active-tempdir',
PS-FILE is a copy of `preview-ps-file', IMAGETYPE is the image type PS-FILE is a copy of `preview-ps-file', IMAGETYPE is the image type
skipping to change at line 1226 skipping to change at line 1249
tempdir)))) tempdir))))
(overlay-put ov 'queued (overlay-put ov 'queued
(vector box nil snippet)) (vector box nil snippet))
(overlay-put ov 'preview-image (overlay-put ov 'preview-image
(list (preview-icon-copy preview-nonready-icon))) (list (preview-icon-copy preview-nonready-icon)))
(preview-add-urgentization #'preview-gs-urgentize ov run-buffer) (preview-add-urgentization #'preview-gs-urgentize ov run-buffer)
(list ov)) (list ov))
(defvar view-exit-action) (defvar view-exit-action)
(eval-and-compile
(defvar preview-button-1 [mouse-2])
(defvar preview-button-2 [mouse-3]))
(defmacro preview-make-clickable (&optional map glyph helpstring click1 click2)
"Generate a clickable string or keymap.
If MAP is non-nil, it specifies a keymap to add to, otherwise
a new one is created. If GLYPH is given, the result is made
to display it wrapped in a string. In that case,
HELPSTRING is a format string with one or two %s specifiers
for preview's clicks, displayed as a help-echo. CLICK1 and CLICK2
are functions to call on preview's clicks."
`(let ((resmap ,(or map '(make-sparse-keymap))))
,@(if click1
`((define-key resmap preview-button-1 ,click1)))
,@(if click2
`((define-key resmap preview-button-2 ,click2)))
,(if glyph
`(propertize
"x"
'display ,glyph
'mouse-face 'highlight
'help-echo
,(if (stringp helpstring)
(format helpstring preview-button-1 preview-button-2)
`(format ,helpstring preview-button-1 preview-button-2))
'keymap resmap)
'resmap)))
(defun preview-mouse-open-error (string) (defun preview-mouse-open-error (string)
"Display STRING in a new view buffer on click." "Display STRING in a new view buffer on click."
(let ((buff (get-buffer-create (let ((buff (get-buffer-create
"*Preview-Ghostscript-Error*"))) "*Preview-Ghostscript-Error*")))
(with-current-buffer buff (with-current-buffer buff
(kill-all-local-variables) (kill-all-local-variables)
(set (make-local-variable 'view-exit-action) #'kill-buffer) (set (make-local-variable 'view-exit-action) #'kill-buffer)
(setq buffer-undo-list t) (setq buffer-undo-list t)
(erase-buffer) (erase-buffer)
(insert string) (insert string)
skipping to change at line 1423 skipping to change at line 1475
((consp hook) ((consp hook)
(let (res) (let (res)
(while (and (not res) hook) (while (and (not res) hook)
(setq res (preview-hook-enquiry (car hook)) (setq res (preview-hook-enquiry (car hook))
hook (cdr hook))) hook (cdr hook)))
res)) res))
((and (symbolp hook) (boundp hook)) ((and (symbolp hook) (boundp hook))
(symbol-value hook)) (symbol-value hook))
(t hook))) (t hook)))
(defun preview-inherited-face-attribute (face attribute &optional inherit)
"Fetch face attribute while adhering to inheritance.
This searches FACE for an ATTRIBUTE, using INHERIT
for resolving unspecified or relative specs. See the fourth
argument of function `face-attribute' for details."
(face-attribute face attribute nil inherit))
(defcustom preview-scale-function #'preview-scale-from-face (defcustom preview-scale-function #'preview-scale-from-face
"*Scale factor for included previews. "*Scale factor for included previews.
This can be either a function to calculate the scale, or This can be either a function to calculate the scale, or
a fixed number." a fixed number."
:group 'preview-appearance :group 'preview-appearance
:type '(choice (function-item preview-scale-from-face) :type '(choice (function-item preview-scale-from-face)
(const 1.0) (const 1.0)
(number :value 1.0) (number :value 1.0)
(function :value preview-scale-from-face))) (function :value preview-scale-from-face)))
skipping to change at line 1623 skipping to change at line 1682
(defcustom preview-equality-transforms '(identity (defcustom preview-equality-transforms '(identity
preview-canonical-spaces) preview-canonical-spaces)
"Transformation functions for region changes. "Transformation functions for region changes.
These functions are tried in turn on the strings from the These functions are tried in turn on the strings from the
regions of a preview to decide whether a preview is to be considered regions of a preview to decide whether a preview is to be considered
changed. If any transform leads to equal results, the preview is changed. If any transform leads to equal results, the preview is
considered unchanged." considered unchanged."
:group 'preview-appearance :group 'preview-appearance
:type '(repeat function)) :type '(repeat function))
(defcustom preview-transparent-color '(highlight :background)
"Color to appear transparent in previews.
Set this to something unusual when using `preview-transparent-border',
to the default background in most other cases."
:type '(radio (const :tag "None" nil)
(const :tag "Autodetect" t)
(color :tag "By name" :value "white")
(list :tag "Take from face"
:value (default :background)
(face)
(choice :tag "What to take"
(const :tag "Background" :value :background)
(const :tag "Foreground" :value :foreground))))
:group 'preview-appearance)
;;; Note that the following default introduces a border only when
;;; Emacs blinks politely when point is on an image (the tested
;;; unrelated function was introduced at about the time image blinking
;;; became tolerable).
(defcustom preview-transparent-border (unless (fboundp 'posn-object-x-y) 1.5)
"Width of transparent border for previews in pt.
Setting this to a numeric value will add a border of
`preview-transparent-color' around images, and will turn
the heuristic-mask setting of images to default to 't since
then the borders are correctly detected even in case of
palette operations. If the transparent color is something
not present otherwise in the image, the cursor display
will affect just this border. A width of 0 is interpreted
by PostScript as meaning a single pixel, other widths are
interpreted as PostScript points (1/72 of 1in)"
:group 'preview-appearance
:type '(choice (const :value nil :tag "No border")
(number :value 1.5 :tag "Border width in pt")))
(defun preview-get-heuristic-mask ()
"Get heuristic-mask to use for previews.
Consults `preview-transparent-color'."
(cond ((stringp preview-transparent-color)
(color-values preview-transparent-color))
((or (not (consp preview-transparent-color))
(integerp (car preview-transparent-color)))
preview-transparent-color)
(t (color-values (preview-inherited-face-attribute
(nth 0 preview-transparent-color)
(nth 1 preview-transparent-color)
'default)))))
(defsubst preview-create-icon-1 (file type ascent border)
`(image
:file ,file
:type ,type
:ascent ,ascent
,@(and border
'(:mask (heuristic t)))))
(defun preview-create-icon (file type ascent border)
"Create an icon from FILE, image TYPE, ASCENT and BORDER."
(list
(preview-create-icon-1 file type ascent border)
file type ascent border))
(put 'preview-filter-specs :type
(lambda (keyword value &rest args)
(if (image-type-available-p value)
`(image :type ,value
,@(preview-filter-specs-1 args))
(throw 'preview-filter-specs nil))))
(defun preview-import-image (image)
"Convert the printable IMAGE rendition back to an image."
(cond ((stringp image)
(propertize image 'face 'preview-face))
((eq (car image) 'image)
image)
(t
(preview-create-icon-1 (nth 0 image)
(nth 1 image)
(nth 2 image)
(if (< (length image) 4)
(preview-get-heuristic-mask)
(nth 3 image))))))
;; No defcustom here: does not seem to make sense.
(defvar preview-tb-icon-specs
'((:type xpm :file "prvtex24.xpm")
(:type xbm :file "prvtex24.xbm")))
(defvar preview-tb-icon nil)
(defun preview-add-urgentization (fun ov &rest rest)
"Cause FUN (function call form) to be called when redisplayed.
FUN must be a form with OV as first argument,
REST as the remainder, returning T."
(let ((dispro (overlay-get ov 'display)))
(unless (eq (car dispro) 'when)
(overlay-put ov 'display `(when (,fun ,ov ,@rest) . ,dispro)))))
(defun preview-remove-urgentization (ov)
"Undo urgentization of OV by `preview-add-urgentization'.
Returns the old arguments to `preview-add-urgentization'
if there was any urgentization."
(let ((dispro (overlay-get ov 'display)))
(when (eq (car-safe dispro) 'when)
(prog1
(car (cdr dispro))
(overlay-put ov 'display (cdr (cdr dispro)))))))
(defvar preview-overlay nil)
(put 'preview-overlay
'modification-hooks
'(preview-handle-modification))
(put 'preview-overlay
'insert-in-front-hooks
'(preview-handle-insert-in-front))
(put 'preview-overlay
'insert-behind-hooks
'(preview-handle-insert-behind))
;; We have to fake our way around atomicity.
;; Here is the beef: for best intuitiveness, we want to have
;; insertions be carried out as expected before iconized text
;; passages, but we want to insert *into* the overlay when not
;; iconized. A preview that has become empty can not get content
;; again: we remove it. A disabled preview needs no insert-in-front
;; handler.
(defvar preview-change-list nil
"List of tentatively changed overlays.")
(defcustom preview-dump-threshold
"^ *\\\\begin *{document}[ %]*$"
"*Regexp denoting end of preamble.
This is the location up to which preamble changes are considered
to require redumping of a format."
:group 'preview-latex
:type 'string)
(defun preview-preamble-changed-function
(ov after-change beg end &optional length)
"Hook function for change hooks on preamble.
See info node `(elisp) Overlay Properties' for
definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(let ((format-cons (overlay-get ov 'format-cons)))
(preview-unwatch-preamble format-cons)
(preview-format-kill format-cons)
(setcdr format-cons t)))
(defun preview-watch-preamble (file command format-cons)
"Set up a watch on master file FILE.
FILE can be an associated buffer instead of a filename.
COMMAND is the command that generated the format.
FORMAT-CONS contains the format info for the main
format dump handler."
(let ((buffer (if (bufferp file)
file
(find-buffer-visiting file))) ov)
(setcdr
format-cons
(cons command
(when buffer
(with-current-buffer buffer
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(unless (re-search-forward preview-dump-threshold nil t)
(error "Can't find preamble of `%s'" file))
(setq ov (make-overlay (point-min) (point)))
(overlay-put ov 'format-cons format-cons)
(overlay-put ov 'insert-in-front-hooks
'(preview-preamble-changed-function))
(overlay-put ov 'modification-hooks
'(preview-preamble-changed-function))
ov))))))))
(defun preview-unwatch-preamble (format-cons)
"Stop watching a format on FORMAT-CONS.
The watch has been set up by `preview-watch-preamble'."
(when (consp (cdr format-cons))
(when (cddr format-cons)
(delete-overlay (cddr format-cons)))
(setcdr (cdr format-cons) nil)))
(defun preview-register-change (ov)
"Register not yet changed OV for verification.
This stores the old contents of the overlay in the
`preview-prechange' property and puts the overlay into
`preview-change-list' where `preview-check-changes' will
find it at some later point of time."
(unless (overlay-get ov 'preview-prechange)
(if (eq (overlay-get ov 'preview-state) 'disabled)
(overlay-put ov 'preview-prechange t)
(overlay-put ov 'preview-prechange
(save-restriction
(widen)
(buffer-substring-no-properties
(overlay-start ov) (overlay-end ov)))))
(push ov preview-change-list)))
(defun preview-check-changes ()
"Check whether the contents under the overlay have changed.
Disable it if that is the case. Ignores text properties."
(dolist (ov preview-change-list)
(condition-case nil
(with-current-buffer (overlay-buffer ov)
(let ((text (save-restriction
(widen)
(buffer-substring-no-properties
(overlay-start ov) (overlay-end ov)))))
(if (zerop (length text))
(preview-delete ov)
(unless
(or (eq (overlay-get ov 'preview-state) 'disabled)
(preview-relaxed-string=
text (overlay-get ov 'preview-prechange)))
(overlay-put ov 'insert-in-front-hooks nil)
(overlay-put ov 'insert-behind-hooks nil)
(preview-disable ov)))))
(error nil))
(overlay-put ov 'preview-prechange nil))
(setq preview-change-list nil))
(defun preview-handle-insert-in-front
(ov after-change beg end &optional length)
"Hook function for `insert-in-front-hooks' property.
See info node `(elisp) Overlay Properties' for
definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(if after-change
(unless undo-in-progress
(if (eq (overlay-get ov 'preview-state) 'active)
(move-overlay ov end (overlay-end ov))))
(preview-register-change ov)))
(defun preview-handle-insert-behind
(ov after-change beg end &optional length)
"Hook function for `insert-behind-hooks' property.
This is needed in case `insert-before-markers' is used at the
end of the overlay. See info node `(elisp) Overlay Properties'
for definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(if after-change
(unless undo-in-progress
(if (eq (overlay-get ov 'preview-state) 'active)
(move-overlay ov (overlay-start ov) beg)))
(preview-register-change ov)))
(defun preview-handle-modification
(ov after-change beg end &optional length)
"Hook function for `modification-hooks' property.
See info node `(elisp) Overlay Properties' for
definition of OV, AFTER-CHANGE, BEG, END and LENGTH."
(unless after-change
(preview-register-change ov)))
(defun preview-toggle (ov &optional arg event)
"Toggle visibility of preview overlay OV.
ARG can be one of the following: t displays the overlay,
nil displays the underlying text, and 'toggle toggles.
If EVENT is given, it indicates the window where the event
occured, either by being a mouse event or by directly being
the window in question. This may be used for cursor restoration
purposes."
(let ((old-urgent (preview-remove-urgentization ov))
(preview-state
(if (if (eq arg 'toggle)
(null (eq (overlay-get ov 'preview-state) 'active))
arg)
'active
'inactive))
(strings (overlay-get ov 'strings)))
(unless (eq (overlay-get ov 'preview-state) 'disabled)
(overlay-put ov 'preview-state preview-state)
(if (eq preview-state 'active)
(progn
(overlay-put ov 'category 'preview-overlay)
(if (eq (overlay-start ov) (overlay-end ov))
(overlay-put ov 'before-string (car strings))
(dolist (prop '(display keymap mouse-face help-echo))
(overlay-put ov prop
(get-text-property 0 prop (car strings))))
(overlay-put ov 'before-string nil))
(overlay-put ov 'face nil))
(dolist (prop '(display keymap mouse-face help-echo))
(overlay-put ov prop nil))
(overlay-put ov 'face 'preview-face)
(unless (cdr strings)
(setcdr strings (preview-inactive-string ov)))
(overlay-put ov 'before-string (cdr strings)))
(if old-urgent
(apply 'preview-add-urgentization old-urgent))))
(if event
(preview-restore-position
ov
(if (windowp event)
event
(posn-window (event-start event))))))
(defvar preview-marker (make-marker)
"Marker for fake intangibility.")
(defvar preview-temporary-opened nil)
(defvar preview-last-location nil
"Restored cursor position marker for reopened previews.")
(make-variable-buffer-local 'preview-last-location)
(defun preview-mark-point ()
"Mark position for fake intangibility."
(when (eq (get-char-property (point) 'preview-state) 'active)
(unless preview-last-location
(setq preview-last-location (make-marker)))
(set-marker preview-last-location (point))
(set-marker preview-marker (point))
(preview-move-point))
(set-marker preview-marker (point)))
(defun preview-restore-position (ov window)
"Tweak position after opening/closing preview.
The treated overlay OV has been triggered in WINDOW. This function
records the original buffer position for reopening, or restores it
after reopening. Note that by using the mouse, you can open/close
overlays not in the active window."
(when (eq (overlay-buffer ov) (window-buffer window))
(with-current-buffer (overlay-buffer ov)
(if (eq (overlay-get ov 'preview-state) 'active)
(setq preview-last-location
(set-marker (or preview-last-location (make-marker))
(window-point window)))
(when (and
(markerp preview-last-location)
(eq (overlay-buffer ov) (marker-buffer preview-last-location))
(< (overlay-start ov) preview-last-location)
(> (overlay-end ov) preview-last-location))
(set-window-point window preview-last-location))))))
(defun preview-move-point ()
"Move point out of fake-intangible areas."
(preview-check-changes)
(let* (newlist (pt (point)) (lst (overlays-at pt)) distance)
(setq preview-temporary-opened
(dolist (ov preview-temporary-opened newlist)
(and (overlay-buffer ov)
(eq (overlay-get ov 'preview-state) 'inactive)
(if (and (eq (overlay-buffer ov) (current-buffer))
(or (<= pt (overlay-start ov))
(>= pt (overlay-end ov))))
(preview-toggle ov t)
(push ov newlist)))))
(when lst
(if (or disable-point-adjustment
global-disable-point-adjustment
(preview-auto-reveal-p
preview-auto-reveal
(setq distance
(and (eq (marker-buffer preview-marker)
(current-buffer))
(- pt (marker-position preview-marker))))))
(preview-open-overlays lst)
(while lst
(setq lst
(if (and
(eq (overlay-get (car lst) 'preview-state) 'active)
(> pt (overlay-start (car lst))))
(overlays-at
(setq pt (if (and distance (< distance 0))
(overlay-start (car lst))
(overlay-end (car lst)))))
(cdr lst))))
(goto-char pt)))))
(defun preview-open-overlays (list &optional pos)
"Open all previews in LIST, optionally restricted to enclosing POS."
(dolist (ovr list)
(when (and (eq (overlay-get ovr 'preview-state) 'active)
(or (null pos)
(and
(> pos (overlay-start ovr))
(< pos (overlay-end ovr)))))
(preview-toggle ovr)
(push ovr preview-temporary-opened))))
(defadvice replace-highlight (before preview)
"Make `query-replace' open preview text about to be replaced."
(preview-open-overlays
(overlays-in (ad-get-arg 0) (ad-get-arg 1))))
(defcustom preview-query-replace-reveal t
"*Make `query-replace' autoreveal previews."
:group 'preview-appearance
:type 'boolean
:require 'preview
:set (lambda (symbol value)
(set-default symbol value)
(if value
(ad-enable-advice 'replace-highlight 'before 'preview)
(ad-disable-advice 'replace-highlight 'before 'preview))
(ad-activate 'replace-highlight))
:initialize #'custom-initialize-reset)
(defun preview-relaxed-string= (&rest args) (defun preview-relaxed-string= (&rest args)
"Check for functional equality of arguments. "Check for functional equality of arguments.
The arguments ARGS are checked for equality by using The arguments ARGS are checked for equality by using
`preview-equality-transforms' on them until it is exhausted `preview-equality-transforms' on them until it is exhausted
or one transform returns equality." or one transform returns equality."
(let ((lst preview-equality-transforms)) (let ((lst preview-equality-transforms))
(while (and lst (not (apply #'string= (mapcar (car lst) args)))) (while (and lst (not (apply #'string= (mapcar (car lst) args))))
(setq lst (cdr lst))) (setq lst (cdr lst)))
lst)) lst))
skipping to change at line 1701 skipping to change at line 2163
(defun preview-at-point () (defun preview-at-point ()
"Do the appropriate preview thing at point. "Do the appropriate preview thing at point.
If point is positioned on or inside of an unmodified preview area, If point is positioned on or inside of an unmodified preview area,
its visibility is toggled. its visibility is toggled.
If not, the surroundings are run through preview. The If not, the surroundings are run through preview. The
surroundings don't extend into unmodified previews or past surroundings don't extend into unmodified previews or past
contiguous previews invalidated by modifications. contiguous previews invalidated by modifications.
Overriding any other action, if a region is Overriding any other action, if a region is
active (`transient-mark-mode' or `zmacs-regions'), it is run active (`transient-mark-mode'), it is run through `preview-region'."
through `preview-region'."
(interactive) (interactive)
(if (TeX-active-mark) (if (TeX-active-mark)
(preview-region (region-beginning) (region-end)) (preview-region (region-beginning) (region-end))
(catch 'exit (catch 'exit
(dolist (ovr (overlays-in (max (point-min) (1- (point))) (dolist (ovr (overlays-in (max (point-min) (1- (point)))
(min (point-max) (1+ (point))))) (min (point-max) (1+ (point)))))
(let ((preview-state (overlay-get ovr 'preview-state))) (let ((preview-state (overlay-get ovr 'preview-state)))
(when preview-state (when preview-state
(unless (eq preview-state 'disabled) (unless (eq preview-state 'disabled)
(preview-toggle ovr 'toggle (selected-window)) (preview-toggle ovr 'toggle (selected-window))
skipping to change at line 2580 skipping to change at line 3041
(> force-overwrite 1)) (> force-overwrite 1))
(t force-overwrite)))) (t force-overwrite))))
(if (cond ((eq force-save 1) (if (cond ((eq force-save 1)
(y-or-n-p "Stop using non-installed styles permanently ")) (y-or-n-p "Stop using non-installed styles permanently "))
((numberp force-save) ((numberp force-save)
(> force-save 1)) (> force-save 1))
(t force-save)) (t force-save))
(customize-save-variable 'preview-TeX-style-dir nil) (customize-save-variable 'preview-TeX-style-dir nil)
(customize-set-variable 'preview-TeX-style-dir nil))) (customize-set-variable 'preview-TeX-style-dir nil)))
(defun preview-mode-setup ()
"Setup proper buffer hooks and behavior for previews."
(set (make-local-variable 'desktop-save-buffer)
#'desktop-buffer-preview-misc-data)
(add-hook 'pre-command-hook #'preview-mark-point nil t)
(add-hook 'post-command-hook #'preview-move-point nil t)
(unless preview-tb-icon
(setq preview-tb-icon (preview-filter-specs preview-tb-icon-specs)))
(when preview-tb-icon
(define-key LaTeX-mode-map [tool-bar preview]
`(menu-item "Preview at point" preview-at-point
:image ,preview-tb-icon
:help "Preview on/off at point")))
(when buffer-file-name
(let* ((filename (expand-file-name buffer-file-name))
format-cons)
(when (string-match (concat "\\." TeX-default-extension "\\'")
filename)
(setq filename (substring filename 0 (match-beginning 0))))
(setq format-cons (assoc filename preview-dumped-alist))
(when (consp (cdr format-cons))
(preview-unwatch-preamble format-cons)
(preview-watch-preamble (current-buffer)
(cadr format-cons)
format-cons)))))
;;;###autoload ;;;###autoload
(defun LaTeX-preview-setup () (defun LaTeX-preview-setup ()
"Hook function for embedding the preview package into AUCTeX. "Hook function for embedding the preview package into AUCTeX.
This is called by `LaTeX-mode-hook' and changes AUCTeX variables This is called by `LaTeX-mode-hook' and changes AUCTeX variables
to add the preview functionality." to add the preview functionality."
;; This has to be done only once. ;; This has to be done only once.
(unless (and (boundp 'LaTeX-mode-hook) (unless (and (boundp 'LaTeX-mode-hook)
(memq #'preview-mode-setup LaTeX-mode-hook)) (memq #'preview-mode-setup LaTeX-mode-hook))
(remove-hook 'LaTeX-mode-hook #'LaTeX-preview-setup) (remove-hook 'LaTeX-mode-hook #'LaTeX-preview-setup)
(add-hook 'LaTeX-mode-hook #'preview-mode-setup) (add-hook 'LaTeX-mode-hook #'preview-mode-setup)
skipping to change at line 3151 skipping to change at line 3638
(error-message-string err))))) (error-message-string err)))))
(defun preview-set-geometry (geometry) (defun preview-set-geometry (geometry)
"Set geometry variables from GEOMETRY. "Set geometry variables from GEOMETRY.
Buffer-local `preview-scale', `preview-resolution', Buffer-local `preview-scale', `preview-resolution',
and `preview-colors' are set as given." and `preview-colors' are set as given."
(setq preview-scale (nth 0 geometry) (setq preview-scale (nth 0 geometry)
preview-resolution (nth 1 geometry) preview-resolution (nth 1 geometry)
preview-colors (nth 2 geometry))) preview-colors (nth 2 geometry)))
(defun preview-get-colors ()
"Return colors from the current display.
Fetches the current screen colors and makes a vector
of colors as numbers in the range 0..65535.
Pure borderless black-on-white will return triple NIL.
The fourth value is the transparent border thickness."
(let
((bg (color-values (preview-inherited-face-attribute
'preview-reference-face :background 'default)))
(fg (color-values (preview-inherited-face-attribute
'preview-reference-face :foreground 'default)))
(mask (preview-get-heuristic-mask)))
(if (equal '(65535 65535 65535) bg)
(setq bg nil))
(if (equal '(0 0 0) fg)
(setq fg nil))
(unless (and (numberp preview-transparent-border)
(consp mask) (integerp (car mask)))
(setq mask nil))
(vector bg fg mask preview-transparent-border)))
(defun preview-start-dvipng () (defun preview-start-dvipng ()
"Start a DviPNG process.." "Start a DviPNG process.."
(let* ((file preview-gs-file) (let* ((file preview-gs-file)
tempdir tempdir
(res (/ (* (car preview-resolution) (res (/ (* (car preview-resolution)
(preview-hook-enquiry preview-scale)) (preview-hook-enquiry preview-scale))
(preview-get-magnification))) (preview-get-magnification)))
(resolution (format " -D%d " res)) (resolution (format " -D%d " res))
(colors (preview-dvipng-color-string preview-colors res)) (colors (preview-dvipng-color-string preview-colors res))
(command (with-current-buffer TeX-command-buffer (command (with-current-buffer TeX-command-buffer
skipping to change at line 3187 skipping to change at line 3695
(if TeX-after-start-process-function (if TeX-after-start-process-function
(funcall TeX-after-start-process-function process)) (funcall TeX-after-start-process-function process))
(TeX-command-mode-line process) (TeX-command-mode-line process)
(set-process-filter process 'TeX-command-filter) (set-process-filter process 'TeX-command-filter)
(set-process-sentinel process 'TeX-command-sentinel) (set-process-sentinel process 'TeX-command-sentinel)
(set-marker (process-mark process) (point-max)) (set-marker (process-mark process) (point-max))
(push process compilation-in-progress) (push process compilation-in-progress)
(sit-for 0) (sit-for 0)
process) process)
(setq mode-line-process ": run") (setq mode-line-process ": run")
(set-buffer-modified-p (buffer-modified-p)) (force-mode-line-update)
(sit-for 0) ; redisplay
(call-process TeX-shell nil (current-buffer) nil (call-process TeX-shell nil (current-buffer) nil
TeX-shell-command-option TeX-shell-command-option
command)))) command))))
(defun preview-start-dvips (&optional fast) (defun preview-start-dvips (&optional fast)
"Start a DviPS process. "Start a DviPS process.
If FAST is set, do a fast conversion." If FAST is set, do a fast conversion."
(let* ((file preview-gs-file) (let* ((file preview-gs-file)
tempdir tempdir
(command (with-current-buffer TeX-command-buffer (command (with-current-buffer TeX-command-buffer
skipping to change at line 3231 skipping to change at line 3738
(if TeX-after-start-process-function (if TeX-after-start-process-function
(funcall TeX-after-start-process-function process)) (funcall TeX-after-start-process-function process))
(TeX-command-mode-line process) (TeX-command-mode-line process)
(set-process-filter process 'TeX-command-filter) (set-process-filter process 'TeX-command-filter)
(set-process-sentinel process 'TeX-command-sentinel) (set-process-sentinel process 'TeX-command-sentinel)
(set-marker (process-mark process) (point-max)) (set-marker (process-mark process) (point-max))
(push process compilation-in-progress) (push process compilation-in-progress)
(sit-for 0) (sit-for 0)
process) process)
(setq mode-line-process ": run") (setq mode-line-process ": run")
(set-buffer-modified-p (buffer-modified-p)) (force-mode-line-update)
(sit-for 0) ; redisplay
(call-process TeX-shell nil (current-buffer) nil (call-process TeX-shell nil (current-buffer) nil
TeX-shell-command-option TeX-shell-command-option
command)))) command))))
(defun preview-start-pdf2dsc () (defun preview-start-pdf2dsc ()
"Start a PDF2DSC process." "Start a PDF2DSC process."
(let* ((file preview-gs-file) (let* ((file preview-gs-file)
tempdir tempdir
pdfsource pdfsource
(command (with-current-buffer TeX-command-buffer (command (with-current-buffer TeX-command-buffer
skipping to change at line 3275 skipping to change at line 3781
(if TeX-after-start-process-function (if TeX-after-start-process-function
(funcall TeX-after-start-process-function process)) (funcall TeX-after-start-process-function process))
(TeX-command-mode-line process) (TeX-command-mode-line process)
(set-process-filter process 'TeX-command-filter) (set-process-filter process 'TeX-command-filter)
(set-process-sentinel process 'TeX-command-sentinel) (set-process-sentinel process 'TeX-command-sentinel)
(set-marker (process-mark process) (point-max)) (set-marker (process-mark process) (point-max))
(push process compilation-in-progress) (push process compilation-in-progress)
(sit-for 0) (sit-for 0)
process) process)
(setq mode-line-process ": run") (setq mode-line-process ": run")
(set-buffer-modified-p (buffer-modified-p)) (force-mode-line-update)
(sit-for 0) ; redisplay
(call-process TeX-shell nil (current-buffer) nil (call-process TeX-shell nil (current-buffer) nil
TeX-shell-command-option TeX-shell-command-option
command)))) command))))
(defun preview-TeX-inline-sentinel (process _name) (defun preview-TeX-inline-sentinel (process _name)
"Sentinel function for preview. "Sentinel function for preview.
See `TeX-sentinel-function' and `set-process-sentinel' See `TeX-sentinel-function' and `set-process-sentinel'
for definition of PROCESS and NAME." for definition of PROCESS and NAME."
(if process (TeX-format-mode-line process)) (if process (TeX-format-mode-line process))
(let ((status (process-status process))) (let ((status (process-status process)))
 End of changes. 15 change blocks. 
13 lines changed or deleted 518 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)