/[auctex]/auctex/preview/preview.el
ViewVC logotype

Diff of /auctex/preview/preview.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.248 by angeli, Tue Apr 5 10:09:37 2005 UTC revision 1.249 by angeli, Sun Apr 10 16:28:59 2005 UTC
# Line 75  preview-latex's bug reporting commands w Line 75  preview-latex's bug reporting commands w
75    :link '(info-link "(preview-latex)The Emacs interface")    :link '(info-link "(preview-latex)The Emacs interface")
76    :link '(url-link :tag "Homepage" "http://www.gnu.org/software/auctex/"))    :link '(url-link :tag "Homepage" "http://www.gnu.org/software/auctex/"))
77    
78  (defgroup preview-gs nil "Preview's GhostScript renderer."  (defgroup preview-gs nil "Preview's Ghostscript renderer."
79    :group 'preview    :group 'preview
80    :prefix "preview-")    :prefix "preview-")
81    
# Line 220  function args" :inline t sexp)) Line 220  function args" :inline t sexp))
220      (jpeg jpeg "-sDEVICE=jpeg")      (jpeg jpeg "-sDEVICE=jpeg")
221      (pnm pbm "-sDEVICE=pnmraw")      (pnm pbm "-sDEVICE=pnmraw")
222      (tiff tiff "-sDEVICE=tiff12nc"))      (tiff tiff "-sDEVICE=tiff12nc"))
223    "*Alist of image types and corresponding GhostScript options.    "*Alist of image types and corresponding Ghostscript options.
224  The `dvipng' and `postscript' (don't use) entries really specify  The `dvipng' and `postscript' (don't use) entries really specify
225  a fallback device when images can't be processed by the requested  a fallback device when images can't be processed by the requested
226  method, like when PDFTeX was used."  method, like when PDFTeX was used."
227    :group 'preview-gs    :group 'preview-gs
228    :type '(repeat (list :tag nil (symbol :tag "preview image-type")    :type '(repeat (list :tag nil (symbol :tag "preview image-type")
229                         (symbol :tag "Emacs image-type")                         (symbol :tag "Emacs image-type")
230                         (repeat :inline t :tag "GhostScript options" string))))                         (repeat :inline t :tag "Ghostscript options" string))))
231    
232  (defcustom preview-image-type 'png  (defcustom preview-image-type 'png
233    "*Image type to be used in images."    "*Image type to be used in images."
# Line 370  Buffer-local to the appropriate TeX proc Line 370  Buffer-local to the appropriate TeX proc
370  (defcustom preview-gs-outstanding-limit 2  (defcustom preview-gs-outstanding-limit 2
371    "*Number of requests allowed to be outstanding.    "*Number of requests allowed to be outstanding.
372  This is the number of not-yet-completed requests we  This is the number of not-yet-completed requests we
373  might at any time have piped into GhostScript.  If  might at any time have piped into Ghostscript.  If
374  this number is larger, the probability of GhostScript  this number is larger, the probability of Ghostscript
375  working continuously is higher when Emacs is rather  working continuously is higher when Emacs is rather
376  busy.  If this number is smaller, redisplay will  busy.  If this number is smaller, redisplay will
377  follow changes in the displayed buffer area faster."  follow changes in the displayed buffer area faster."
# Line 385  follow changes in the displayed buffer a Line 385  follow changes in the displayed buffer a
385            :tag "small number"))            :tag "small number"))
386    
387  (defvar preview-gs-answer nil  (defvar preview-gs-answer nil
388    "Accumulated answer of GhostScript process.")    "Accumulated answer of Ghostscript process.")
389  (make-variable-buffer-local 'preview-gs-answer)  (make-variable-buffer-local 'preview-gs-answer)
390    
391  (defvar preview-gs-image-type nil  (defvar preview-gs-image-type nil
# Line 411  of nothing special should be done for th Line 411  of nothing special should be done for th
411  (make-variable-buffer-local 'preview-colors)  (make-variable-buffer-local 'preview-colors)
412    
413  (defvar preview-gs-init-string nil  (defvar preview-gs-init-string nil
414    "GhostScript setup string.")    "Ghostscript setup string.")
415  (make-variable-buffer-local 'preview-gs-init-string)  (make-variable-buffer-local 'preview-gs-init-string)
416    
417  (defvar preview-ps-file nil  (defvar preview-ps-file nil
# Line 439  YRES, the screen resolution in dpi." Line 439  YRES, the screen resolution in dpi."
439  (defun preview-gs-behead-outstanding (err)  (defun preview-gs-behead-outstanding (err)
440    "Remove leading element of outstanding queue after error.    "Remove leading element of outstanding queue after error.
441  Return element if non-nil.  ERR is the error string to  Return element if non-nil.  ERR is the error string to
442  show as response of GhostScript."  show as response of Ghostscript."
443    (let ((ov (pop preview-gs-outstanding)))    (let ((ov (pop preview-gs-outstanding)))
444      (when ov      (when ov
445        (preview-gs-flag-error ov err)        (preview-gs-flag-error ov err)
# Line 582  tag in the mode line." Line 582  tag in the mode line."
582  (defun preview-gs-sentinel (process string)  (defun preview-gs-sentinel (process string)
583    "Sentinel function for rendering process.    "Sentinel function for rendering process.
584  Gets the default PROCESS and STRING arguments  Gets the default PROCESS and STRING arguments
585  and tries to restart GhostScript if necessary."  and tries to restart Ghostscript if necessary."
586    (condition-case err    (condition-case err
587        (let ((status (process-status process)))        (let ((status (process-status process)))
588          (when (memq status '(exit signal))          (when (memq status '(exit signal))
# Line 632  and tries to restart GhostScript if nece Line 632  and tries to restart GhostScript if nece
632                                                  preview-gs-queue))                                                  preview-gs-queue))
633                    (setq preview-gs-outstanding nil)                    (setq preview-gs-outstanding nil)
634                    (preview-gs-restart)))))))                    (preview-gs-restart)))))))
635      (error (preview-log-error err "GhostScript" process)))      (error (preview-log-error err "Ghostscript" process)))
636    (preview-reraise-error process))    (preview-reraise-error process))
637    
638  (defun preview-gs-filter (process string)  (defun preview-gs-filter (process string)
639    "Filter function for processing GhostScript output.    "Filter function for processing Ghostscript output.
640  Gets the usual PROCESS and STRING parameters, see  Gets the usual PROCESS and STRING parameters, see
641  `set-process-filter' for a description."  `set-process-filter' for a description."
642    (with-current-buffer (process-buffer process)    (with-current-buffer (process-buffer process)
# Line 647  Gets the usual PROCESS and STRING parame Line 647  Gets the usual PROCESS and STRING parame
647          (setq preview-gs-answer (substring preview-gs-answer pos))          (setq preview-gs-answer (substring preview-gs-answer pos))
648          (condition-case err          (condition-case err
649              (preview-gs-transact process answer)              (preview-gs-transact process answer)
650            (error (preview-log-error err "GhostScript filter" process))))))            (error (preview-log-error err "Ghostscript filter" process))))))
651    (preview-reraise-error))    (preview-reraise-error))
652    
653  (defun preview-gs-restart ()  (defun preview-gs-restart ()
654    "Start a new GhostScript conversion process."    "Start a new Ghostscript conversion process."
655    (when preview-gs-queue    (when preview-gs-queue
656      (if preview-gs-sequence      (if preview-gs-sequence
657          (setcar preview-gs-sequence (1+ (car preview-gs-sequence)))          (setcar preview-gs-sequence (1+ (car preview-gs-sequence)))
# Line 666  Gets the usual PROCESS and STRING parame Line 666  Gets the usual PROCESS and STRING parame
666                                       preview-gs-image-type))))                                       preview-gs-image-type))))
667             (process             (process
668              (apply #'start-process              (apply #'start-process
669                     "Preview-GhostScript"                     "Preview-Ghostscript"
670                     (current-buffer)                     (current-buffer)
671                     preview-gs-command                     preview-gs-command
672                     outfile                     outfile
673                     preview-gs-command-line)))                     preview-gs-command-line)))
674        (goto-char (point-max))        (goto-char (point-max))
675        (insert-before-markers "Running `Preview-GhostScript' with ``"        (insert-before-markers "Running `Preview-Ghostscript' with ``"
676                               (mapconcat #'shell-quote-argument                               (mapconcat #'shell-quote-argument
677                                          (append                                          (append
678                                           (list preview-gs-command                                           (list preview-gs-command
# Line 684  Gets the usual PROCESS and STRING parame Line 684  Gets the usual PROCESS and STRING parame
684        (set-process-sentinel process #'preview-gs-sentinel)        (set-process-sentinel process #'preview-gs-sentinel)
685        (set-process-filter process #'preview-gs-filter)        (set-process-filter process #'preview-gs-filter)
686        (process-send-string process preview-gs-init-string)        (process-send-string process preview-gs-init-string)
687        (setq mode-name "Preview-GhostScript")        (setq mode-name "Preview-Ghostscript")
688        (push process compilation-in-progress)        (push process compilation-in-progress)
689        (TeX-command-mode-line process)        (TeX-command-mode-line process)
690        (set-buffer-modified-p (buffer-modified-p))        (set-buffer-modified-p (buffer-modified-p))
691        process)))        process)))
692    
693  (defun preview-gs-open (&optional setup)  (defun preview-gs-open (&optional setup)
694    "Start a GhostScript conversion pass.    "Start a Ghostscript conversion pass.
695  SETUP may contain a parser setup function."  SETUP may contain a parser setup function."
696    (let ((image-info (assq preview-image-type preview-gs-image-type-alist)))    (let ((image-info (assq preview-image-type preview-gs-image-type-alist)))
697      (setq preview-gs-image-type (nth 1 image-info))      (setq preview-gs-image-type (nth 1 image-info))
# Line 718  aload pop restore}bind def " Line 718  aload pop restore}bind def "
718  (defun preview-gs-color-value (value)  (defun preview-gs-color-value (value)
719    "Return string to be used as color value for an RGB component.    "Return string to be used as color value for an RGB component.
720  Conversion from Emacs color numbers (0 to 65535) in VALUE  Conversion from Emacs color numbers (0 to 65535) in VALUE
721  to GhostScript floats."  to Ghostscript floats."
722    (format "%g" (/ value 65535.0)))    (format "%g" (/ value 65535.0)))
723    
724  (defun preview-gs-color-string (colors)  (defun preview-gs-color-string (colors)
# Line 1043  NONREL is not NIL." Line 1043  NONREL is not NIL."
1043  This function is used in fake conditional display properties  This function is used in fake conditional display properties
1044  for reordering the conversion order to prioritize on-screen  for reordering the conversion order to prioritize on-screen
1045  images.  OV is the overlay in question, and BUFF is the  images.  OV is the overlay in question, and BUFF is the
1046  GhostScript process buffer where the buffer-local queue  Ghostscript process buffer where the buffer-local queue
1047  is located."  is located."
1048    ;; It does not matter that ov gets queued twice in that process: the    ;; It does not matter that ov gets queued twice in that process: the
1049    ;; first version to get rendered will clear the 'queued property.    ;; first version to get rendered will clear the 'queued property.
# Line 1061  is located." Line 1061  is located."
1061    
1062    
1063  (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)
1064    "Generate an image placeholder rendered over by GhostScript.    "Generate an image placeholder rendered over by Ghostscript.
1065  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
1066  this image for real later, and returns the overlay after setting  this image for real later, and returns the overlay after setting
1067  a placeholder image.  SNIPPET gives the number of the  a placeholder image.  SNIPPET gives the number of the
# Line 1088  for the file extension." Line 1088  for the file extension."
1088  (defun preview-mouse-open-error (string)  (defun preview-mouse-open-error (string)
1089    "Display STRING in a new view buffer on click."    "Display STRING in a new view buffer on click."
1090    (let ((buff (get-buffer-create    (let ((buff (get-buffer-create
1091                 "*Preview-GhostScript-Error*")))                 "*Preview-Ghostscript-Error*")))
1092      (with-current-buffer buff      (with-current-buffer buff
1093        (kill-all-local-variables)        (kill-all-local-variables)
1094        (set (make-local-variable 'view-exit-action) #'kill-buffer)        (set (make-local-variable 'view-exit-action) #'kill-buffer)
# Line 1165  Try \\[ps-shell] and \\[ps-execute-buffe Line 1165  Try \\[ps-shell] and \\[ps-execute-buffe
1165      (preview-toggle ov)))      (preview-toggle ov)))
1166    
1167  (defun preview-gs-transact (process answer)  (defun preview-gs-transact (process answer)
1168    "Work off GhostScript transaction.    "Work off Ghostscript transaction.
1169  This routine is the action routine called via the process filter.  This routine is the action routine called via the process filter.
1170  The GhostScript process buffer of PROCESS will already be selected, and  The Ghostscript process buffer of PROCESS will already be selected, and
1171  and the standard output of GhostScript up to the next prompt will be  and the standard output of Ghostscript up to the next prompt will be
1172  given as ANSWER."  given as ANSWER."
1173    (let ((ov (pop preview-gs-outstanding))    (let ((ov (pop preview-gs-outstanding))
1174          (have-error (not          (have-error (not

Legend:
Removed from v.1.248  
changed lines
  Added in v.1.249

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26