-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-command-recipes-latex.el
105 lines (88 loc) · 3.71 KB
/
run-command-recipes-latex.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
;;; run-command-recipes-latex.el --- Recipe of `run-command' for `latex` -*- lexical-binding: t; -*-
;; Author: semenInRussia <hrams205@gmail.com>
;; Version: 0.1.0
;; Keywords: extensions, run-command
;; Homepage: https://github.com/semenInRussia/emacs-run-command-recipes
;; URL: https://github.com/semenInRussia/emacs-run-command-recipes/blob/main/docs/latex.md
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; For use this code put the following to your Emacs configuration:
;;
;; (run-command-recipes-use-one 'latex)
;;
;;; Code:
(require 'run-command-recipes-lib)
(require 'run-command-recipes-project)
(declare-function 'latex/compile-commands-until-done "latex-extra")
(defcustom run-command-recipes-latex-command
(concat "pdflatex"
" -interaction nonstopmode"
" -file-line-error"
" --output-directory \"{current-dir}\""
" \"{file-name}\"")
"Command running pdflatex, ignoring errors."
:type 'string
:group 'run-command-recipes)
(defcustom run-command-recipes-latex-modes
'(LaTeX-mode latex-mode tex-mode TeX-mode)
"List of tex/latex major modes in the Emacs."
:type '(repeat symbol)
:group 'run-command-recipes)
(defcustom run-command-recipes-latexmk-config-filenames
'(".latexmkrc" "latexmkrc")
"Names of the `latexmk' config files indicating a LaTeX directory list."
:type '(repeat symbol)
:group 'run-command-recipes)
(defun run-command-recipes-latex ()
"Recipe of `run-command' for LaTeX."
(when (-contains-p run-command-recipes-latex-modes major-mode)
(run-command-recipes-lib-compose-recipes
'run-command-recipes-latex-pdflatex
'run-command-recipes-latex-latexmk)))
(defun run-command-recipes-latex-pdflatex ()
"Subrecipe of `run-command' for command tool pdflatex."
(run-command-recipes-lib-build
(list
(list
:display "PDFLaTeX: convert to PDF"
:command-name "pdflatex"
:command-line run-command-recipes-latex-command)
(when (featurep 'latex-extra)
(list
:display "LaTeX: compile, build everything"
:command-name "latex-compile-commands-until-done"
:lisp-function 'latex/compile-commands-until-done)))))
(defun run-command-recipes-latex-latexmk-project-p (&optional root)
"Return non-nil if the project at ROOT has the latexmk configuration file.
ROOT defaults to `run-command-recipes-project-root'"
(or root (setq root (run-command-recipes-project-root)))
(run-command-recipes-project-root-has-one-of
run-command-recipes-latexmk-config-filenames))
(defun run-command-recipes-latex-latexmk ()
"Subrecipe of `run-command' for command tool latexmk."
(let ((working-dir (run-command-recipes-project-root)))
(when (and
working-dir
(run-command-recipes-latex-latexmk-project-p working-dir)))
(list
(list
:display "LaTeX MK: compile"
:command-name "latexmk"
:command-line "latexmk"
:working-dir working-dir)
(list
:display "LaTeX MK: compile, preview"
:command-name "latexmk-with-preview"
:command-line "latexmk -pv"
:working-dir working-dir))))
(provide 'run-command-recipes-latex)
;;; run-command-recipes-latex.el ends here