diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2019-09-16 16:56:06 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2019-09-16 16:56:53 +0200 |
| commit | 2b7ff5ebf1917345dd9cc69a3a5848f505a68cde (patch) | |
| tree | cfb826f878b47d3082576c04c863001d7897c07f /.emacs.d | |
| parent | ed74bffd18ad8597507262107c14c341dbc04b15 (diff) | |
| download | dotfiles-2b7ff5ebf1917345dd9cc69a3a5848f505a68cde.tar.gz dotfiles-2b7ff5ebf1917345dd9cc69a3a5848f505a68cde.zip | |
emacs: added some handy export functions
These avoid some clutter when exporting to either pdf or odt.
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to '.emacs.d')
| -rw-r--r-- | .emacs.d/init.org | 49 |
1 files 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: </div>") #+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 "<f1>") 'org-latex-export-to-pdf) - (define-key org-mode-map (kbd "<f2>") 'org-odt-export-to-odt)) + (define-key org-mode-map (kbd "<f1>") 'mssola-export-tex-to-pdf) + (define-key org-mode-map (kbd "<f2>") 'mssola-export-tex-to-odt)) #+END_SRC ** Agenda |
