1
0
Fork 0

feat(emacs): add open-out-pdf for latex

Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
Lucas Sta Maria 2024-02-28 09:55:19 -05:00
parent 50a089a2d0
commit d6f127a7f8
No known key found for this signature in database
GPG key ID: F07FB16A826E3B47

View file

@ -5,6 +5,7 @@
(require 'latex) (require 'latex)
(require 'cdlatex) (require 'cdlatex)
(require 'f)
(defun custom-compile-latex () (defun custom-compile-latex ()
"Run the `just' command -- the command I use to compile my environment." "Run the `just' command -- the command I use to compile my environment."
@ -12,6 +13,19 @@
(save-buffer) (save-buffer)
(shell-command-to-string "just")) (shell-command-to-string "just"))
(defun open-out-pdf ()
"Find and open the produced PDF via Zathura."
(interactive)
(save-excursion
(when (f-directory-p "./out/")
(defconst --pdf-files (f-glob "./out/*.pdf"))
(unless (zerop (length --pdf-files))
(defconst --pdf-command "zathura")
(defconst --pdf-file (car --pdf-files))
(defconst --shell-command (format "%s %s" --pdf-command --pdf-file))
(setq-local async-shell-command-buffer 'rename-buffer)
(async-shell-command --shell-command)))))
(defun enter-math () (defun enter-math ()
"Enter and ensure math-mode." "Enter and ensure math-mode."
(interactive) (interactive)
@ -72,7 +86,8 @@
(display-fill-column-indicator-mode 1) (display-fill-column-indicator-mode 1)
(set-fill-column 100) (set-fill-column 100)
(keymap-local-set "C-c C-z" #'custom-compile-latex) (keymap-local-set "C-c C-c" #'custom-compile-latex)
(keymap-local-set "C-c C-z" #'open-out-pdf)
(keymap-local-set "C-c C-b" #'latex-insert-block) (keymap-local-set "C-c C-b" #'latex-insert-block)
(keymap-local-set "C-c C-h" #'enter-math) (keymap-local-set "C-c C-h" #'enter-math)
(keymap-local-set "C-c C-/" #'insert-frac) (keymap-local-set "C-c C-/" #'insert-frac)