From 88761b748c7ecd2145c86d1d2c3f69fb6932b605 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sun, 13 Jun 2021 09:32:38 -0700 Subject: sd-quick-export *chef's kiss* --- smart-documents.org | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/smart-documents.org b/smart-documents.org index e724758..ddc0591 100644 --- a/smart-documents.org +++ b/smart-documents.org @@ -1296,6 +1296,15 @@ later keybinding definitions for two reasons: This reimplements the most common Org mode export: Org \rightarrow LaTeX \rightarrow PDF. The binding is defined in Section [[Export to PDF]]. +This series of ~quick-export~ functions have one objective: harmonize +the export of Emacs buffers to PDF. Org mode does this by design; we +describe additional exports for other modes, most notably Nroff mode +and Ledger mode. + +*** From Org mode + +This reimplements the most common Org mode export: Org \rightarrow LaTeX \rightarrow +PDF. The binding is defined in Section [[Export to PDF]]. #+BEGIN_SRC emacs-lisp :tangle yes (defun sd-quick-export--org () @@ -1318,14 +1327,38 @@ PDF]]. (newline) (setq more-lines-p (= 0 (forward-line 1)))) (org-open-file (org-latex-export-to-pdf))))) +#+END_SRC +*** From Nroff mode + +#+BEGIN_SRC emacs-lisp :tangle yes + (defun sd-quick-export--nroff (macros) + "Export Nroff/Groff buffer to PDF, with specified macro set." + (let* ((file-exported-name + (concat (file-name-sans-extension buffer-file-name) + (format "-%s.pdf" macros))) + (command-export + (format "groff -%s -Tps %s | ps2pdf - > %s" + macros + (buffer-file-name) + file-exported-name))) + (shell-command command-export) + (org-open-file file-exported-name))) +#+END_SRC + +*** Quick export + +#+BEGIN_SRC emacs-lisp :tangle yes (defun sd-quick-export () "Quickly prettify and export current buffer to PDF." (interactive) (cond ((eq major-mode 'org-mode) (sd-quick-export--org)) + ((eq major-mode 'nroff-mode) + (sd-quick-export--nroff + (read-string "Macro set used (ms, me, mm...): "))) ((eq major-mode 'emacs-lisp-mode) - (message "No quick-export implemented yet.")) + (message "No quick-export implemented for emacs-lisp-mode yet.")) ((eq major-mode 'ledger-report-mode) (sd-quick-export--ledger-report)) (t (message (format "No sd-quick-export backend for %s." -- cgit v1.2.3