diff options
| author | Stefan Monnier | 2008-03-03 13:55:41 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-03-03 13:55:41 +0000 |
| commit | 68a2af7af02d3e91854d8b1101f48242b5e62b68 (patch) | |
| tree | afd538950be628e2fa6f13b5f2a6195f8cbb6c55 /lisp/textmodes | |
| parent | 4b03e20a6f086c901d7e183a905ee9097a6de0b6 (diff) | |
| download | emacs-68a2af7af02d3e91854d8b1101f48242b5e62b68.tar.gz emacs-68a2af7af02d3e91854d8b1101f48242b5e62b68.zip | |
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
(tex-executable-exists-p, tex-compile): Extend with special syntax for
commands implemented in elisp.
(tex-compile-commands): Add an entry to use doc-view for pdf files.
(tex-format-cmd): New function.
(tex-compile): Use it to let the user specify default arguments.
(tex-cmd-bibtex-args): New var.
(tex-cmd-doc-view): New function.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index ffb06061bb6..a4067830475 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -1042,7 +1042,7 @@ subshell is initiated, `tex-shell-hook' is run." | |||
| 1042 | "\\>\\|\\\\[a-z]*" (regexp-opt '("space" "skip" "page") t) | 1042 | "\\>\\|\\\\[a-z]*" (regexp-opt '("space" "skip" "page") t) |
| 1043 | "\\>\\)")) | 1043 | "\\>\\)")) |
| 1044 | (setq paragraph-separate | 1044 | (setq paragraph-separate |
| 1045 | (concat "[\f%]\\|[ \t]*\\($\\|" | 1045 | (concat "[\f]\\|[ \t]*\\($\\|" |
| 1046 | "\\\\[][]\\|" | 1046 | "\\\\[][]\\|" |
| 1047 | "\\\\" (regexp-opt (append | 1047 | "\\\\" (regexp-opt (append |
| 1048 | (mapcar 'car latex-section-alist) | 1048 | (mapcar 'car latex-section-alist) |
| @@ -1785,6 +1785,7 @@ If NOT-ALL is non-nil, save the `.dvi' file." | |||
| 1785 | (shell-quote-argument tex-start-commands)) " %f") | 1785 | (shell-quote-argument tex-start-commands)) " %f") |
| 1786 | t "%r.dvi") | 1786 | t "%r.dvi") |
| 1787 | ("xdvi %r &" "%r.dvi") | 1787 | ("xdvi %r &" "%r.dvi") |
| 1788 | ("\\doc-view \"%r.pdf\"" "%r.pdf") | ||
| 1788 | ("xpdf %r.pdf &" "%r.pdf") | 1789 | ("xpdf %r.pdf &" "%r.pdf") |
| 1789 | ("gv %r.ps &" "%r.ps") | 1790 | ("gv %r.ps &" "%r.ps") |
| 1790 | ("yap %r &" "%r.dvi") | 1791 | ("yap %r &" "%r.dvi") |
| @@ -1900,11 +1901,11 @@ FILE is typically the output DVI or PDF file." | |||
| 1900 | (save-excursion | 1901 | (save-excursion |
| 1901 | (goto-char (point-max)) | 1902 | (goto-char (point-max)) |
| 1902 | (and (re-search-backward | 1903 | (and (re-search-backward |
| 1903 | (concat | 1904 | (concat "(see the transcript file for additional information)" |
| 1904 | "(see the transcript file for additional information)" | 1905 | "\\|^Output written on .*" |
| 1905 | "\\|^Output written on .*" | 1906 | (regexp-quote (file-name-nondirectory file)) |
| 1906 | (regexp-quote (file-name-nondirectory file)) | 1907 | " (.*)\\.") |
| 1907 | " (.*)\\.") nil t) | 1908 | nil t) |
| 1908 | (> (save-excursion | 1909 | (> (save-excursion |
| 1909 | (or (re-search-backward "\\[[0-9]+\\]" nil t) | 1910 | (or (re-search-backward "\\[[0-9]+\\]" nil t) |
| 1910 | (point-min))) | 1911 | (point-min))) |
| @@ -1945,11 +1946,15 @@ FILE is typically the output DVI or PDF file." | |||
| 1945 | (defvar tex-executable-cache nil) | 1946 | (defvar tex-executable-cache nil) |
| 1946 | (defun tex-executable-exists-p (name) | 1947 | (defun tex-executable-exists-p (name) |
| 1947 | "Like `executable-find' but with a cache." | 1948 | "Like `executable-find' but with a cache." |
| 1948 | (let ((cache (assoc name tex-executable-cache))) | 1949 | (let ((f (and (string-match "^\\\\\\([^ \t\n]+\\)" name) |
| 1949 | (if cache (cdr cache) | 1950 | (intern-soft (concat "tex-cmd-" (match-string 1 name)))))) |
| 1950 | (let ((executable (executable-find name))) | 1951 | (if (fboundp f) |
| 1951 | (push (cons name executable) tex-executable-cache) | 1952 | f |
| 1952 | executable)))) | 1953 | (let ((cache (assoc name tex-executable-cache))) |
| 1954 | (if cache (cdr cache) | ||
| 1955 | (let ((executable (executable-find name))) | ||
| 1956 | (push (cons name executable) tex-executable-cache) | ||
| 1957 | executable)))))) | ||
| 1953 | 1958 | ||
| 1954 | (defun tex-command-executable (cmd) | 1959 | (defun tex-command-executable (cmd) |
| 1955 | (let ((s (if (stringp cmd) cmd (eval (car cmd))))) | 1960 | (let ((s (if (stringp cmd) cmd (eval (car cmd))))) |
| @@ -1968,6 +1973,24 @@ FILE is typically the output DVI or PDF file." | |||
| 1968 | (when (and (eq in t) (stringp out)) | 1973 | (when (and (eq in t) (stringp out)) |
| 1969 | (not (tex-uptodate-p (format-spec out fspec))))))) | 1974 | (not (tex-uptodate-p (format-spec out fspec))))))) |
| 1970 | 1975 | ||
| 1976 | (defcustom tex-cmd-bibtex-args "--min-crossref=100" | ||
| 1977 | "Extra args to pass to `bibtex' by default." | ||
| 1978 | :type 'string) | ||
| 1979 | |||
| 1980 | (defun tex-format-cmd (format fspec) | ||
| 1981 | "Like `format-spec' but adds user-specified args to the command. | ||
| 1982 | Only applies the FSPEC to the args part of FORMAT." | ||
| 1983 | (if (not (string-match "\\([^ /\\]+\\) " format)) | ||
| 1984 | (format-spec format fspec) | ||
| 1985 | (let* ((prefix (substring format 0 (match-beginning 0))) | ||
| 1986 | (cmd (match-string 1 format)) | ||
| 1987 | (args (substring format (match-end 0))) | ||
| 1988 | (sym (intern-soft (format "tex-cmd-%s-args" cmd))) | ||
| 1989 | (extra-args (and sym (symbol-value sym)))) | ||
| 1990 | (concat prefix cmd | ||
| 1991 | (if extra-args (concat " " extra-args)) | ||
| 1992 | " " (format-spec args fspec))))) | ||
| 1993 | |||
| 1971 | (defun tex-compile-default (fspec) | 1994 | (defun tex-compile-default (fspec) |
| 1972 | "Guess a default command given the `format-spec' FSPEC." | 1995 | "Guess a default command given the `format-spec' FSPEC." |
| 1973 | ;; TODO: Learn to do latex+dvips! | 1996 | ;; TODO: Learn to do latex+dvips! |
| @@ -2038,7 +2061,10 @@ FILE is typically the output DVI or PDF file." | |||
| 2038 | ;; The history command was already applied to the same file, | 2061 | ;; The history command was already applied to the same file, |
| 2039 | ;; so just reuse it. | 2062 | ;; so just reuse it. |
| 2040 | hist-cmd | 2063 | hist-cmd |
| 2041 | (if cmds (format-spec (caar cmds) fspec)))))) | 2064 | (if cmds (tex-format-cmd (caar cmds) fspec)))))) |
| 2065 | |||
| 2066 | (defun tex-cmd-doc-view (file) | ||
| 2067 | (pop-to-buffer (find-file-noselect file))) | ||
| 2042 | 2068 | ||
| 2043 | (defun tex-compile (dir cmd) | 2069 | (defun tex-compile (dir cmd) |
| 2044 | "Run a command CMD on current TeX buffer's file in DIR." | 2070 | "Run a command CMD on current TeX buffer's file in DIR." |
| @@ -2056,14 +2082,24 @@ FILE is typically the output DVI or PDF file." | |||
| 2056 | (completing-read | 2082 | (completing-read |
| 2057 | (format "Command [%s]: " (tex-summarize-command default)) | 2083 | (format "Command [%s]: " (tex-summarize-command default)) |
| 2058 | (mapcar (lambda (x) | 2084 | (mapcar (lambda (x) |
| 2059 | (list (format-spec (eval (car x)) fspec))) | 2085 | (list (tex-format-cmd (eval (car x)) fspec))) |
| 2060 | tex-compile-commands) | 2086 | tex-compile-commands) |
| 2061 | nil nil nil 'tex-compile-history default)))) | 2087 | nil nil nil 'tex-compile-history default)))) |
| 2062 | (save-some-buffers (not compilation-ask-about-save) nil) | 2088 | (save-some-buffers (not compilation-ask-about-save) nil) |
| 2063 | (if (tex-shell-running) | 2089 | (let ((f (and (string-match "^\\\\\\([^ \t\n]+\\)" cmd) |
| 2064 | (tex-kill-job) | 2090 | (intern-soft (concat "tex-cmd-" (match-string 1 cmd)))))) |
| 2065 | (tex-start-shell)) | 2091 | (if (functionp f) |
| 2066 | (tex-send-tex-command cmd dir)) | 2092 | (condition-case nil |
| 2093 | (let ((default-directory dir)) | ||
| 2094 | (apply f (split-string-and-unquote | ||
| 2095 | (substring cmd (match-end 0))))) | ||
| 2096 | (wrong-number-of-arguments | ||
| 2097 | (error "Wrong number of arguments to %s" | ||
| 2098 | (substring (symbol-name f) 8)))) | ||
| 2099 | (if (tex-shell-running) | ||
| 2100 | (tex-kill-job) | ||
| 2101 | (tex-start-shell)) | ||
| 2102 | (tex-send-tex-command cmd dir)))) | ||
| 2067 | 2103 | ||
| 2068 | (defun tex-start-tex (command file &optional dir) | 2104 | (defun tex-start-tex (command file &optional dir) |
| 2069 | "Start a TeX run, using COMMAND on FILE." | 2105 | "Start a TeX run, using COMMAND on FILE." |