From 2b7ff5ebf1917345dd9cc69a3a5848f505a68cde Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 16 Sep 2019 16:56:06 +0200 Subject: emacs: added some handy export functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These avoid some clutter when exporting to either pdf or odt. Signed-off-by: Miquel Sabaté Solà --- .emacs.d/init.org | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/.emacs.d/init.org b/.emacs.d/init.org index 78954ce..2a17feb 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -1562,12 +1562,55 @@ Also hide the "Footnotes: " title on footnotes: ") #+END_SRC -Last but not least, some handy shortcuts: +Last but not least, some handy shortcuts when exporting (adding my own functions +to avoid some of the generated clutter): #+BEGIN_SRC elisp +(defun mssola-move-file-to-out (dir name ext) + "If the given file NAME exists, move it out from DIR. +Note that EXT must include the period character. " + + (when (file-exists-p (concat dir name ext)) + (unless (file-directory-p (concat dir "out/")) + (make-directory (concat dir "out/"))) + (delete-file (concat dir "out/" name ext)) + (rename-file (concat dir name ext) (concat dir "out/" name ext)))) + +(defun mssola-export-tex-to-pdf () + "Export to current tex file to pdf and then remove all the clutter. +It will also create a pdf/ directory in which pdf files will be saved." + + (interactive) + + (org-latex-export-to-pdf) + + (let* ((fn (buffer-file-name (window-buffer (minibuffer-selected-window)))) + (dir (file-name-directory fn)) + (name (file-name-base fn))) + + (delete-directory (concat dir "auto") t) + + (when (file-exists-p (concat dir name ".tex")) + (delete-file (concat dir name ".tex"))) + + (mssola-move-file-to-out dir name ".pdf"))) + +(defun mssola-export-tex-to-odt () + "Similar to `mssola-export-tex-to-pdf' but with odt." + + (interactive) + + (org-odt-export-to-odt) + + (let* ((fn (buffer-file-name (window-buffer (minibuffer-selected-window)))) + (dir (file-name-directory fn)) + (name (file-name-base fn))) + + (mssola-move-file-to-out dir name ".odt"))) + (with-eval-after-load "org" - (define-key org-mode-map (kbd "") 'org-latex-export-to-pdf) - (define-key org-mode-map (kbd "") 'org-odt-export-to-odt)) + (define-key org-mode-map (kbd "") 'mssola-export-tex-to-pdf) + (define-key org-mode-map (kbd "") 'mssola-export-tex-to-odt)) #+END_SRC ** Agenda -- cgit v1.2.3