Add LaTeX relative to .latexmkrc compile hook
This commit is contained in:
parent
82c134a5ba
commit
ca3d679c54
|
@ -449,6 +449,37 @@ The target indentation style of ~LaTeX~ is as follows:
|
|||
\end{enumerate}
|
||||
#+end_src
|
||||
|
||||
The ~SPC m c~ command which by default binds to ~TeX-command-run-all~ is
|
||||
modified so it runs in the directory of the nearest ~.latexmkrc~ file or the
|
||||
projectile root, whichever is closer. If a ~.latexmkrc~ file is not found, we
|
||||
fall back to the current directory.
|
||||
#+begin_src emacs-lisp
|
||||
(defun custom/TeX-compile-in-root ()
|
||||
"Execute ~TeX-command-run-all~ in the nearest ~.latexmkrc~ directory or
|
||||
projectile project root."
|
||||
(interactive)
|
||||
(let*
|
||||
((dir-latexmkrc
|
||||
(projectile-locate-dominating-file default-directory ".latexmkrc"))
|
||||
(dir-projectile (projectile-project-root))
|
||||
(is-latexmk-child-of-projectile (string-match-p (regexp-quote dir-projectile) dir-latexmkrc))
|
||||
(dir-work (cond
|
||||
((and dir-latexmkrc is-latexmk-child-of-projectile) dir-latexmkrc)
|
||||
(dir-projectile dir-projectile)
|
||||
(t default-directory)))
|
||||
(dir-current-rel (string-remove-prefix dir-work default-directory))
|
||||
(file-current-rel (concat dir-current-rel (TeX-master-file))))
|
||||
; Execute in shadowed ~default-directory~
|
||||
(cl-labels ((replace-pwd () dir-work) (replace-file (&optional extension nondirectory ask) file-current-rel))
|
||||
(advice-add 'TeX-master-directory :override #'replace-pwd)
|
||||
(advice-add 'TeX-master-file :override #'replace-file)
|
||||
(TeX-command-run-all nil)
|
||||
(advice-remove 'TeX-master-file #'replace-file)
|
||||
(advice-remove 'TeX-master-directory #'replace-pwd)
|
||||
)))
|
||||
#+end_src
|
||||
|
||||
|
||||
For some reason the keymap binding has to use ~LaTeX-mode-map~ or ~TeX-mode-map~
|
||||
instead of ~latex-mode-map~. Also some original keybindings are removed so they
|
||||
can be displayed correctly in prompts. See e.g. ~tex-buf.el~ for an example.
|
||||
|
@ -471,6 +502,7 @@ introduced.
|
|||
:desc "View Compilation Log" "l" #'TeX-recenter-output-buffer
|
||||
:desc "Next Error" "e" #'TeX-next-error
|
||||
:desc "Close Environment" "]" #'LaTeX-close-environment
|
||||
:desc "Compile in root" "." #'custom/TeX-compile-in-root
|
||||
(:prefix ("f" . "Fold")
|
||||
:desc "Fold Mode" "f" #'TeX-fold-mode
|
||||
:desc "Environment" "e" #'TeX-fold-env
|
||||
|
@ -486,6 +518,7 @@ introduced.
|
|||
)
|
||||
#+end_src
|
||||
|
||||
|
||||
*** Lean 3
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
:emacs
|
||||
dired ; making dired pretty [functional]
|
||||
electric ; smarter, keyword-based electric-indent
|
||||
;;ibuffer ; interactive buffer management
|
||||
(ibuffer +icons) ; interactive buffer management
|
||||
undo ; persistent, smarter undo for your inevitable mistakes
|
||||
vc ; version-control and Emacs, sitting in a tree
|
||||
|
||||
|
@ -82,7 +82,7 @@
|
|||
:checkers
|
||||
syntax ; tasing you for every semicolon you forget
|
||||
(spell +flyspell) ; tasing you for misspelling mispelling
|
||||
;;grammar ; tasing grammar mistake every you make
|
||||
grammar ; tasing grammar mistake every you make
|
||||
|
||||
:tools
|
||||
;;ansible
|
||||
|
@ -142,7 +142,7 @@
|
|||
;;idris ; a language you can depend on
|
||||
json ; At least it ain't XML
|
||||
;;(java +lsp) ; the poster child for carpal tunnel syndrome
|
||||
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
|
||||
javascript ; all(hope(abandon(ye(who(enter(here))))))
|
||||
;;julia ; a better, faster MATLAB
|
||||
;;kotlin ; a better, slicker Java(Script)
|
||||
(latex +latexmk +lsp) ; writing papers in Emacs has never been so fun
|
||||
|
|
Loading…
Reference in New Issue