Function: preview-gs-sentinel
preview-gs-sentinel is a byte-compiled function defined in preview.el.
Signature
(preview-gs-sentinel PROCESS STRING)
Documentation
Sentinel function for rendering process.
Gets the default PROCESS and STRING arguments and tries to restart Ghostscript if necessary.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-gs-sentinel (process string)
"Sentinel function for rendering process.
Gets the default PROCESS and STRING arguments
and tries to restart Ghostscript if necessary."
(condition-case err
(let ((status (process-status process))
keep-preview-ps)
(when (memq status '(exit signal))
(setq compilation-in-progress (delq process compilation-in-progress)))
(when (buffer-name (process-buffer process))
(with-current-buffer (process-buffer process)
(goto-char (point-max))
(insert-before-markers "\n" mode-name " " string)
(forward-char -1)
(insert " at "
(substring (current-time-string) 0 -5))
(forward-char 1)
(TeX-command-mode-line process)
(when (memq status '(exit signal))
;; process died.
;; Throw away culprit, go on.
(let* ((err (concat preview-gs-answer "\n"
(process-name process) " " string))
(ov (preview-gs-behead-outstanding err)))
(when (and (null ov) preview-gs-queue)
(save-excursion
(goto-char (if (marker-buffer (process-mark process))
(process-mark process)
(point-max)))
(insert-before-markers err)))
(delete-process process)
(unless (or (null ov)
(eq status 'signal))
;; If process was killed explicitly by signal, or if
;; nothing was processed, we give up on the matter
;; altogether, otherwise restart only if we made
;; progress since last call.
(let (filenames)
(dolist (ov preview-gs-outstanding)
(setq filenames (overlay-get ov 'filenames))
(condition-case nil
(preview-delete-file (nth 1 filenames))
(file-error nil))
(setcdr filenames nil)))
(setq preview-gs-queue (nconc preview-gs-outstanding
preview-gs-queue))
(setq preview-gs-outstanding nil)
;; Keep preview-ps if another GS process is started.
(setq keep-preview-ps (preview-gs-restart)))
(unless keep-preview-ps
(when preview-ps-file
(condition-case nil
(preview-delete-file preview-ps-file)
(file-error nil)))
(preview-gs-queue-empty)))))))
(error (preview-log-error err "Ghostscript" process)))
(preview-reraise-error process))