emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex dbc87df 17/78: Generate PDF via dvips+ps2pdf.


From: Tassilo Horn
Subject: [elpa] externals/auctex dbc87df 17/78: Generate PDF via dvips+ps2pdf.
Date: Mon, 19 Oct 2015 09:10:44 +0000

branch: externals/auctex
commit dbc87df41c22a68d98629c65653afa07cfb5e398
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>

    Generate PDF via dvips+ps2pdf.
    
    * tex-buf.el (TeX-previous-error): Delete point in error message.
    (TeX-command-default)
    (TeX-run-set-command): Take care of `TeX-PDF-via-dvips-ps2pdf'.
    (TeX-run-dvips, TeX-run-ps2pdf): New functions.
    (TeX-TeX-sentinel, TeX-TeX-sentinel-check, TeX-LaTeX-sentinel):
    Take care of `TeX-PDF-via-dvips-ps2pdf'.
    (TeX-dvips-sentinel, TeX-ps2pdf-sentinel): New functions.
    (TeX-parse-command, TeX-output-revert-buffer): Delete point in
    error message.
    
    * tex.el (TeX-command-list): Add "Dvips" and "Ps2pdf" entries.
    (TeX-expand-list): Take care of `TeX-PDF-via-dvips-ps2pdf'.
    (TeX-PDF-via-dvips-ps2pdf): New customizable and safe-local
    variable.
    (TeX-toggle-PDF-via-dvips-ps2pdf): New function.
    (TeX-mode-specific-command-menu-entries): Add "PDF via dvips +
    ps2pdf" entry.
    
    * doc/auctex.texi (Processor Options): Document
    `TeX-PDF-via-dvips-ps2pdf' and fix a typo.
    
    * doc/changes.texi: Mention `TeX-PDF-via-dvips-ps2pdf'.
    
    * doc/quickstart.texi (Processing Facilities): Mention
    `TeX-PDF-via-dvips-ps2pdf'.
---
 ChangeLog           |   26 +++++++++++++++
 doc/auctex.texi     |   29 ++++++++++++++++-
 doc/changes.texi    |    5 +++
 doc/quickstart.texi |    8 +++++
 tex-buf.el          |   88 ++++++++++++++++++++++++++++++++++++++++++++-------
 tex.el              |   29 +++++++++++++++--
 6 files changed, 169 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4edd55f..5057a0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2015-08-31  Mos� Giordano  <address@hidden>
 
+       * tex-buf.el (TeX-previous-error): Delete point in error message.
+       (TeX-command-default)
+       (TeX-run-set-command): Take care of `TeX-PDF-via-dvips-ps2pdf'.
+       (TeX-run-dvips, TeX-run-ps2pdf): New functions.
+       (TeX-TeX-sentinel, TeX-TeX-sentinel-check, TeX-LaTeX-sentinel):
+       Take care of `TeX-PDF-via-dvips-ps2pdf'.
+       (TeX-dvips-sentinel, TeX-ps2pdf-sentinel): New functions.
+       (TeX-parse-command, TeX-output-revert-buffer): Delete point in
+       error message.
+
+       * tex.el (TeX-command-list): Add "Dvips" and "Ps2pdf" entries.
+       (TeX-expand-list): Take care of `TeX-PDF-via-dvips-ps2pdf'.
+       (TeX-PDF-via-dvips-ps2pdf): New customizable and safe-local
+       variable.
+       (TeX-toggle-PDF-via-dvips-ps2pdf): New function.
+       (TeX-mode-specific-command-menu-entries): Add "PDF via dvips +
+       ps2pdf" entry.
+
+       * doc/auctex.texi (Processor Options): Document
+       `TeX-PDF-via-dvips-ps2pdf' and fix a typo.
+
+       * doc/changes.texi: Mention `TeX-PDF-via-dvips-ps2pdf'.
+
+       * doc/quickstart.texi (Processing Facilities): Mention
+       `TeX-PDF-via-dvips-ps2pdf'.
+
        * tex-buf.el: Update copyright year.
        (TeX-command-sequence-max-runs-same-command)
        (TeX-command-sequence-max-runs): New customizable variables.
diff --git a/doc/auctex.texi b/doc/auctex.texi
index ad1e951..c60d755 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2907,6 +2907,33 @@ In particular, fine-tuning the page breaks should be 
done with source
 specials switched off.
 @end deffn
 
+Sometimes you are requested, by journal rules or packages, to compile
+the document into @acronym{DVI} output.  Thus, if you want a
address@hidden document in the end you can either use address@hidden engine,
+see below for information about how to set engines, or compile the
+document with @command{tex} and then convert to @acronym{PDF} with
address@hidden@command{ps2pdf} before viewing it.  The latter can be
+done automatically in @AUCTeX{} by setting the
address@hidden variable to a non-nil value.
+
address@hidden TeX-PDF-via-dvips-ps2pdf
+With @code{TeX-PDF-mode} set to non-nil, if
address@hidden is non-nil too, the document is compiled
+with @command{tex} (or @command{latex}) instead of @command{pdftex} (or
address@hidden).  When the document is ready, @kbd{C-c C-c} will
+suggest to run @command{dvips} and then @command{ps2pdf} in order to
+convert the @acronym{DVI} file to @acronym{PDF}.  When the @acronym{PDF}
+file is finally ready, the next suggested command will be to open the
+viewer.
+
+This option can also be set as a file local variable, in order to use
+the sequence @address@hidden@command{ps2pdf} on a
+per-document basis.
+
+Recall the whole sequence of @kbd{C-c C-c} commands can be replace by
+the single @kbd{C-c C-u}.
address@hidden defopt
+
 @AUCTeX{} also allows you to easily select different @TeX{} engines for
 processing, either by using the entries in the @samp{TeXing Options}
 submenu below the @samp{Command} menu or by calling the function
@@ -2963,7 +2990,7 @@ means there is no command available.
 @end defopt
 
 Some @LaTeX{} packages requires the document to be compiled with a
-specific engine.  Notably examples are fontspec and polyglossia
+specific engine.  Notable examples are fontspec and polyglossia
 packages, which require address@hidden and address@hidden engines.  If you try 
to
 compile a document which loads one of such packages and the set engine
 is not one of those allowed you will be asked to select a different
diff --git a/doc/changes.texi b/doc/changes.texi
index c2c4140..06471e7 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -30,6 +30,11 @@ Forward and backward search with Evince now also work when 
only a region
 of the document is compiled/viewed.
 
 @item
+With new option @code{TeX-PDF-via-dvips-ps2pdf} it is possible to
+compile a document to @acronym{DVI} and then convert it to @acronym{PDF}
+using @address@hidden before viewing it.
+
address@hidden
 New option @code{TeX-file-line-error} allows to select file:line:error
 style for error messages.
 
diff --git a/doc/quickstart.texi b/doc/quickstart.texi
index 0f9beeb..b50b044 100644
--- a/doc/quickstart.texi
+++ b/doc/quickstart.texi
@@ -268,6 +268,14 @@ toggles usage of Omega/lambda.
 
 @end table
 
+There is also another possibility: compile the document with
address@hidden (or @command{latex}) and then convert the resulting
address@hidden file to @acronym{PDF} using
address@hidden@command{ps2pdf} sequence.  If you want to go by this
+route, when @code{TeX-PDF-via-dvips-ps2pdf} variable is non-nil,
address@hidden will suggest you to run the appropriate command when you type
address@hidden C-c}.  For details, see @ref{Processor Options}.
+
 @subsection Debugging @LaTeX{}
 
 When @AUCTeX{} runs a program, it creates an output buffer in which it
diff --git a/tex-buf.el b/tex-buf.el
index 1bf6b5d..a341727 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -322,7 +322,7 @@ This works only with TeX commands and if the
          (TeX-parse-TeX (- arg) nil)
        ;; XXX: moving backward in the errors hasn't yet been implemented for
        ;; other parsing functions.
-       (error "Jumping to previous error not supported.")))))
+       (error "Jumping to previous error not supported")))))
 
 ;;; Command Query
 
@@ -522,8 +522,8 @@ without further expansion."
 (defun TeX-check-files (derived originals extensions)
   "Check if DERIVED is newer than any of the ORIGINALS.
 Try each original with each member of EXTENSIONS, in all directories
-in `TeX-check-path'. Returns true if any of the ORIGINALS with any of the
-EXTENSIONS are newer than DERIVED. Will prompt to save the buffer of any
+in `TeX-check-path'.  Returns true if any of the ORIGINALS with any of the
+EXTENSIONS are newer than DERIVED.  Will prompt to save the buffer of any
 ORIGINALS which are modified but not saved yet."
   (let (existingoriginals
         found
@@ -690,7 +690,9 @@ first run of the function and some variables need to be 
reset."
         (if LaTeX-using-Biber TeX-command-Biber TeX-command-BibTeX))
        ((TeX-process-get-variable name
                                   'TeX-command-next
-                                  TeX-command-Show))
+                                  (if (and TeX-PDF-via-dvips-ps2pdf 
TeX-PDF-mode)
+                                      "Dvips"
+                                    TeX-command-Show)))
        (TeX-command-Show)))
 
 (defun TeX-command-query (name)
@@ -873,7 +875,8 @@ Return the new process."
 (defun TeX-run-set-command (name command)
   "Remember TeX command to use to NAME and set corresponding output extension."
   (setq TeX-command-default name
-       TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
+       TeX-output-extension
+       (if (and (null TeX-PDF-via-dvips-ps2pdf) TeX-PDF-mode) "pdf" "dvi"))
   (let ((case-fold-search t)
        (lst TeX-command-output-list))
     (while lst
@@ -957,6 +960,22 @@ run of `TeX-run-TeX', use
         process
       (TeX-synchronous-sentinel name file process))))
 
+(defun TeX-run-dvips (name command file)
+  "Create a process for NAME using COMMAND to convert FILE with dvips."
+  (let ((process (TeX-run-command name command file)))
+    (setq TeX-sentinel-function 'TeX-dvips-sentinel)
+    (if TeX-process-asynchronous
+        process
+      (TeX-synchronous-sentinel name file process))))
+
+(defun TeX-run-ps2pdf (name command file)
+  "Create a process for NAME using COMMAND to convert FILE with ps2pdf."
+  (let ((process (TeX-run-command name command file)))
+    (setq TeX-sentinel-function 'TeX-ps2pdf-sentinel)
+    (if TeX-process-asynchronous
+        process
+      (TeX-synchronous-sentinel name file process))))
+
 (defun TeX-run-compile (name command file)
   "Ignore first and third argument, start compile with second argument."
   (let ((default-directory (TeX-master-directory)))
@@ -1170,7 +1189,10 @@ errors or warnings to show."
        (TeX-parse-all-errors))
     (if (and TeX-error-overview-open-after-TeX-run TeX-error-list)
        (TeX-error-overview))
-    (setq TeX-command-next TeX-command-Show)))
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-command-next "Dvips")
+      (setq TeX-command-next TeX-command-Show))))
 
 (defun TeX-current-pages ()
   "Return string indicating the number of pages formatted."
@@ -1211,7 +1233,10 @@ Return nil ifs no errors were found."
                                            'TeX-current-master))
                         t))
        t)
-    (setq TeX-command-next TeX-command-Show)
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-command-next "Dvips")
+      (setq TeX-command-next TeX-command-Show))
     nil))
 
 (defun TeX-LaTeX-sentinel-has-warnings ()
@@ -1293,12 +1318,18 @@ Rerun to get outlines right" nil t)
        ((re-search-forward "^LaTeX Warning: Reference" nil t)
         (message "%s%s%s" name ": there were unresolved references, "
                  (TeX-current-pages))
-        (setq TeX-command-next TeX-command-Show))
+        (if (with-current-buffer TeX-command-buffer
+              (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+            (setq TeX-command-next "Dvips")
+          (setq TeX-command-next TeX-command-Show)))
        ((re-search-forward "^\\(?:LaTeX Warning: Citation\\|\
 Package natbib Warning:.*undefined citations\\)" nil t)
         (message "%s%s%s" name ": there were unresolved citations, "
                  (TeX-current-pages))
-        (setq TeX-command-next TeX-command-Show))
+        (if (with-current-buffer TeX-command-buffer
+              (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+            (setq TeX-command-next "Dvips")
+          (setq TeX-command-next TeX-command-Show)))
        ((re-search-forward "Package longtable Warning: Table widths have \
 changed\\. Rerun LaTeX\\." nil t)
         (message
@@ -1324,7 +1355,10 @@ Rerun to get mark in right position\\." nil t)
                                    ")"))))
           (message "%s" (concat name ": successfully formatted "
                                 (TeX-current-pages) add-info)))
-        (setq TeX-command-next TeX-command-Show))
+        (if (with-current-buffer TeX-command-buffer
+              (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+            (setq TeX-command-next "Dvips")
+          (setq TeX-command-next TeX-command-Show)))
        (t
         (message "%s%s%s" name ": problems after " (TeX-current-pages))
         (setq TeX-command-next TeX-command-default)))
@@ -1379,6 +1413,36 @@ Rerun to get mark in right position\\." nil t)
                      "Run LaTeX again to get citations right."))
     (setq TeX-command-next TeX-command-default))))
 
+(defun TeX-dvips-sentinel (_process _name)
+  "Cleanup TeX output buffer after running dvips."
+  (goto-char (point-max))
+  (cond
+   ((search-backward "TeX Output exited abnormally" nil t)
+    (message "Dvips failed.  Type `%s' to display output."
+            (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
+   (t
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-output-extension "ps"
+             TeX-command-next "Ps2pdf"))
+    (message "Dvips finished successfully. "))))
+
+(defun TeX-ps2pdf-sentinel (_process _name)
+  "Cleanup TeX output buffer after running ps2pdf."
+  (goto-char (point-max))
+  (cond
+   ((search-backward "TeX Output exited abnormally" nil t)
+    (message "ps2pdf failed.  Type `%s' to display output."
+            (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
+   (t
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-command-next TeX-command-Show
+             TeX-output-extension "pdf"))
+    (message "ps2pdf finished successfully. "))))
+
 (defun TeX-command-sequence-sentinel (process string)
   "Call the appropriate sentinel for the current process.
 
@@ -1865,7 +1929,7 @@ If optional argument REPARSE is non-nil, reparse the 
output log."
 ;; be ignored, because `TeX-next-error' can call any of these functions.
 (defun TeX-parse-command (arg reparse)
   "We can't parse anything but TeX."
-  (error "I cannot parse %s output, sorry."
+  (error "I cannot parse %s output, sorry"
         (if (TeX-active-process)
             (process-name (TeX-active-process))
           "this")))
@@ -3135,7 +3199,7 @@ forward, if negative)."
           (TeX-command name (if (string-match "_region_" file)
                                 'TeX-region-file
                               'TeX-master-file))))
-    (error "Unable to find what command to run.")))
+    (error "Unable to find what command to run")))
 
 (provide 'tex-buf)
 
diff --git a/tex.el b/tex.el
index 630349c..0868d10 100644
--- a/tex.el
+++ b/tex.el
@@ -150,8 +150,12 @@ If nil, none is specified."
     ("Print" "%p" TeX-run-command t t :help "Print the file")
     ("Queue" "%q" TeX-run-background nil t :help "View the printer queue"
      :visible TeX-queue-command)
-    ("File" "%(o?)dvips %d -o %f " TeX-run-command t t
+    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t t
      :help "Generate PostScript file")
+    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil t
+     :help "Convert DVI file to PostScript")
+    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil t
+     :help "Convert PostScript file to PDF")
     ("Index" "makeindex %s" TeX-run-command nil t :help "Create index file")
     ("Xindy" "texindy %s" TeX-run-command nil t
      :help "Run xindy to create index file")
@@ -445,8 +449,9 @@ string."
            (TeX-style-check LaTeX-command-style)))
     ("%(PDF)" (lambda ()
                (if (and (eq TeX-engine 'default)
-                        (or TeX-PDF-mode
-                            TeX-DVI-via-PDFTeX))
+                        (if TeX-PDF-mode
+                            (not TeX-PDF-via-dvips-ps2pdf)
+                          TeX-DVI-via-PDFTeX))
                    "pdf"
                  "")))
     ("%(PDFout)" (lambda ()
@@ -1923,6 +1928,20 @@ already established, don't do anything."
   :group 'TeX-command
   :type 'boolean)
 
+(defcustom TeX-PDF-via-dvips-ps2pdf nil
+  "Whether to produce PDF output through the (La)TeX - dvips - ps2pdf 
sequence."
+  :group 'TeX-command
+  :type 'boolean)
+(make-variable-buffer-local 'TeX-PDF-via-dvips-ps2pdf)
+(put 'TeX-PDF-via-dvips-ps2pdf 'safe-local-variable 'booleanp)
+
+(defun TeX-toggle-PDF-via-dvips-ps2pdf ()
+  "Toggle `TeX-PDF-via-dvips-ps2pdf'."
+  (interactive)
+  (setq TeX-PDF-via-dvips-ps2pdf (not TeX-PDF-via-dvips-ps2pdf))
+  (message (concat "TeX-PDF-via-dvips-ps2pdf: "
+                  (if TeX-PDF-via-dvips-ps2pdf "on" "off"))))
+
 (define-minor-mode TeX-interactive-mode
   "Minor mode for interactive runs of TeX."
   nil nil nil
@@ -4750,6 +4769,10 @@ Brace insertion is only done if point is in a math 
construct and
         :style toggle :selected TeX-PDF-mode
         :active (not (eq TeX-engine 'omega))
         :help "Use PDFTeX to generate PDF instead of DVI"]
+       [ "PDF via dvips + ps2pdf" TeX-toggle-PDF-via-dvips-ps2pdf
+        :style toggle :selected TeX-PDF-via-dvips-ps2pdf
+        :visible TeX-PDF-mode
+        :help "Compile with (La)TeX and convert to PDF with dvips + ps2pdf"]
        [ "Run Interactively" TeX-interactive-mode
         :style toggle :selected TeX-interactive-mode :keys "C-c C-t C-i"
         :help "Stop on errors in a TeX run"]



reply via email to

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