emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/textmodes/tex-mode.el,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/tex-mode.el,v
Date: Mon, 03 Mar 2008 13:55:42 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        08/03/03 13:55:42

Index: textmodes/tex-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/tex-mode.el,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -b -r1.208 -r1.209
--- textmodes/tex-mode.el       8 Jan 2008 20:45:41 -0000       1.208
+++ textmodes/tex-mode.el       3 Mar 2008 13:55:40 -0000       1.209
@@ -1042,7 +1042,7 @@
                "\\>\\|\\\\[a-z]*" (regexp-opt '("space" "skip" "page") t)
                "\\>\\)"))
   (setq paragraph-separate
-       (concat "[\f%]\\|[ \t]*\\($\\|"
+       (concat "[\f]\\|[ \t]*\\($\\|"
                "\\\\[][]\\|"
                "\\\\" (regexp-opt (append
                                    (mapcar 'car latex-section-alist)
@@ -1785,6 +1785,7 @@
                     (shell-quote-argument tex-start-commands)) " %f")
      t "%r.dvi")
     ("xdvi %r &" "%r.dvi")
+    ("\\doc-view \"%r.pdf\"" "%r.pdf")
     ("xpdf %r.pdf &" "%r.pdf")
     ("gv %r.ps &" "%r.ps")
     ("yap %r &" "%r.dvi")
@@ -1900,11 +1901,11 @@
         (save-excursion
           (goto-char (point-max))
           (and (re-search-backward
-                 (concat
-                  "(see the transcript file for additional information)"
+                 (concat "(see the transcript file for additional information)"
                   "\\|^Output written on .*"
                   (regexp-quote (file-name-nondirectory file))
-                  " (.*)\\.") nil t)
+                         " (.*)\\.")
+                 nil t)
                (> (save-excursion
                     (or (re-search-backward "\\[[0-9]+\\]" nil t)
                         (point-min)))
@@ -1945,11 +1946,15 @@
 (defvar tex-executable-cache nil)
 (defun tex-executable-exists-p (name)
   "Like `executable-find' but with a cache."
+  (let ((f (and (string-match "^\\\\\\([^ \t\n]+\\)" name)
+                (intern-soft (concat "tex-cmd-" (match-string 1 name))))))
+    (if (fboundp f)
+        f
   (let ((cache (assoc name tex-executable-cache)))
     (if cache (cdr cache)
       (let ((executable (executable-find name)))
        (push (cons name executable) tex-executable-cache)
-       executable))))
+            executable))))))
 
 (defun tex-command-executable (cmd)
   (let ((s (if (stringp cmd) cmd (eval (car cmd)))))
@@ -1968,6 +1973,24 @@
       (when (and (eq in t) (stringp out))
        (not (tex-uptodate-p (format-spec out fspec)))))))
 
+(defcustom tex-cmd-bibtex-args "--min-crossref=100"
+  "Extra args to pass to `bibtex' by default."
+  :type 'string)
+
+(defun tex-format-cmd (format fspec)
+  "Like `format-spec' but adds user-specified args to the command.
+Only applies the FSPEC to the args part of FORMAT."
+  (if (not (string-match "\\([^ /\\]+\\) " format))
+      (format-spec format fspec)
+    (let* ((prefix (substring format 0 (match-beginning 0)))
+           (cmd (match-string 1 format))
+           (args (substring format (match-end 0)))
+           (sym (intern-soft (format "tex-cmd-%s-args" cmd)))
+           (extra-args (and sym (symbol-value sym))))
+      (concat prefix cmd
+              (if extra-args (concat " " extra-args))
+              " " (format-spec args fspec)))))
+         
 (defun tex-compile-default (fspec)
   "Guess a default command given the `format-spec' FSPEC."
   ;; TODO: Learn to do latex+dvips!
@@ -2038,7 +2061,10 @@
          ;; The history command was already applied to the same file,
          ;; so just reuse it.
          hist-cmd
-       (if cmds (format-spec (caar cmds) fspec))))))
+       (if cmds (tex-format-cmd (caar cmds) fspec))))))
+
+(defun tex-cmd-doc-view (file)
+  (pop-to-buffer (find-file-noselect file)))
 
 (defun tex-compile (dir cmd)
   "Run a command CMD on current TeX buffer's file in DIR."
@@ -2056,14 +2082,24 @@
           (completing-read
            (format "Command [%s]: " (tex-summarize-command default))
            (mapcar (lambda (x)
-                     (list (format-spec (eval (car x)) fspec)))
+                     (list (tex-format-cmd (eval (car x)) fspec)))
                    tex-compile-commands)
            nil nil nil 'tex-compile-history default))))
   (save-some-buffers (not compilation-ask-about-save) nil)
+  (let ((f (and (string-match "^\\\\\\([^ \t\n]+\\)" cmd)
+                (intern-soft (concat "tex-cmd-" (match-string 1 cmd))))))
+    (if (functionp f)
+        (condition-case nil
+            (let ((default-directory dir))
+              (apply f (split-string-and-unquote
+                        (substring cmd (match-end 0)))))
+          (wrong-number-of-arguments
+           (error "Wrong number of arguments to %s"
+                  (substring (symbol-name f) 8))))
   (if (tex-shell-running)
       (tex-kill-job)
     (tex-start-shell))
-  (tex-send-tex-command cmd dir))
+      (tex-send-tex-command cmd dir))))
 
 (defun tex-start-tex (command file &optional dir)
   "Start a TeX run, using COMMAND on FILE."




reply via email to

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