From eb5399f8a42871cff9bebe382014f7036b6e5043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Sat, 28 Jan 2023 13:56:46 +0000 Subject: [PATCH] Update ASAL functions --- config.org | 57 ++++++++++++++++++++++++---------------- custom/asal-functions.el | 56 ++++++++++++--------------------------- custom/org-format.el | 38 ++++++++++++++++++--------- memoir.el | 9 ------- org-export.el | 20 ++++++++++++++ 5 files changed, 96 insertions(+), 84 deletions(-) delete mode 100644 memoir.el create mode 100644 org-export.el diff --git a/config.org b/config.org index 7392a7c..943974c 100644 --- a/config.org +++ b/config.org @@ -466,6 +466,14 @@ Set general TODO keywords. '((sequence "TODO" "|" "DONE" "CANCELLED"))) #+END_SRC +Track when I complete todos. + + #+BEGIN_SRC emacs-lisp + (setq org-log-done 'time) +#+END_SRC + +*** Export settings + In =emacs27= and above, I can set certain headlines not to be exported. I haven’t used this yet but it sounds useful. #+BEGIN_SRC emacs-lisp @@ -475,12 +483,35 @@ In =emacs27= and above, I can set certain headlines not to be exported. I haven (ox-extras-activate '(ignore-headlines))) #+END_SRC -Settings for export, fairly basic because the only thing I regularly export is HTML DW post previews. +Add the =memoir= class for LaTeX export. + +#+BEGIN_SRC emacs-lisp + (unless (version< emacs-version "27") + (add-to-list 'org-latex-classes + '("memoir" + "\\documentclass[9pt,b6paper]{memoir} + [NO-DEFAULT-PACKAGES] + \\input{header.tex}" + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) +#+END_SRC + +Settings for export, mostly for DW post previews but also fic?? #+BEGIN_SRC emacs-lisp (setq org-export-headline-levels 6) (setq org-html-head-include-default-style nil) (setq org-html-head "") + (setq org-footnote-define-inline t) + (setq org-export-with-creator nil) + (setq org-export-with-toc nil) + (setq org-export-time-stamp-file nil) + (setq org-latex-default-class "memoir") + (setq org-latex-compiler "xelatex") + (setq org-html-validation-link nil) + (setq org-html-doctype "html5") #+END_SRC Export non-breaking spaces properly; from, believe it or not, [[https://orgmode.org/manual/Advanced-Export-Configuration.html][the Org Manual]]. @@ -499,26 +530,6 @@ Export non-breaking spaces properly; from, believe it or not, [[https://orgmode. 'my-latex-filter-nobreaks)) #+END_SRC -Add the =memoir= class for LaTeX export. - -#+BEGIN_SRC emacs-lisp - (unless (version< emacs-version "27") - (add-to-list 'org-latex-classes - '("memoir" - "\\documentclass{memoir} - [NO-DEFAULT-PACKAGES]" - ("\\chapter{%s}" . "\\chapter*{%s}") - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) -#+END_SRC - - Track when I complete todos. - - #+BEGIN_SRC emacs-lisp - (setq org-log-done 'time) -#+END_SRC - *** Packages **** =org-agenda-property= @@ -801,8 +812,8 @@ Support for various types of emoge. #+BEGIN_SRC emacs-lisp (use-package emojify - :init - (add-hook 'after-init-hook #'global-emojify-mode)) + :hook + (text-mode . emojify-mode)) #+END_SRC *** =hl-line= diff --git a/custom/asal-functions.el b/custom/asal-functions.el index fa3be9e..3a7aa16 100644 --- a/custom/asal-functions.el +++ b/custom/asal-functions.el @@ -13,6 +13,9 @@ (while (re-search-forward "
\n\n

" nil t) (replace-match "\n

\n

")) (goto-char (point-min)) + (while (re-search-forward "


\n\n

" nil t) + (replace-match "

\n
\n

")) + (goto-char (point-min)) (while (re-search-forward "

" nil t) (replace-match "")) (goto-char (point-min)) @@ -28,6 +31,12 @@ (while (re-search-forward "section-number-2\">\\([0-9]*\\)<" nil t) (replace-match "section-number-2\">\\1\.<")) (goto-char (point-min)) + (while (re-search-forward "

" nil t) + (replace-match "")) + (goto-char (point-min)) + (while (re-search-forward "\n\n" nil t) + (replace-match "\n\n")) + (goto-char (point-min)) (while (re-search-forward "\\\\noindent\\\\rule{\\\\textwidth}{0.5pt}" nil t) (replace-match "\\sephim" nil t)) (goto-char (point-min)) @@ -42,44 +51,13 @@ (defun asal-pre () (interactive) - (goto-char (point-min)) - (while (re-search-forward " -" nil t) - (replace-match " –")) - (goto-char (point-min)) - (while (re-search-forward " –" nil t) - (replace-match " –")) - (goto-char (point-min)) - (while (re-search-forward "/ –" nil t) - (replace-match " –/")) - (goto-char (point-min)) - (while (re-search-forward " \\.\\.\\." nil t) - (replace-match " …")) - (goto-char (point-min)) - (while (re-search-forward " …" nil t) - (replace-match " …")) - (goto-char (point-min)) - (while (re-search-forward "'" nil t) - (replace-match "’")) - (goto-char (point-min)) - (while (re-search-forward " \n" nil t) - (replace-match "\n")) - (goto-char (point-min)) - (while (re-search-forward "\n\"" nil t) - (replace-match "\n“")) - (goto-char (point-min)) - (while (re-search-forward " \"" nil t) - (replace-match " “")) - (goto-char (point-min)) - (while (re-search-forward "\"" nil t) - (replace-match "”")) - (goto-char (point-min)) - (while (re-search-forward "“/" nil t) - (replace-match "/“")) - (goto-char (point-min)) - (while (re-search-forward "/”" nil t) - (replace-match "”/")) + (org-format) (goto-char (point-min)) (while (re-search-forward "\\[fn:\\([0-9]*\\):\\(.*\\)\\]" nil t) - (replace-match "@@html:\\2@@@@latex:\\\\footnote{\\2}@@")) - (goto-char (point-min)) - (insert "#+TITLE: A Shot At Life\n#+AUTHOR: ovely\n#+STARTUP: fninline\n#+OPTIONS: toc:nil author:nil creator:nil date:nil timestamp:nil html-style:nil\n#+HTML_HEAD: \n#+LATEX_COMPILER: xelatex\n#+LATEX_CLASS: memoir\n#+LATEX_CLASS_OPTIONS: [9pt,b6paper]\n#+LATEX_HEADER: \\input{header.tex}\n\n")) + (replace-match "@@html:\\2@@@@latex:\\\\footnote{\\2}@@"))) + +(defun asal-export () + (interactive) + (let ((org-html-head "")) + (org-html-export-to-html)) + (org-latex-export-to-latex)) diff --git a/custom/org-format.el b/custom/org-format.el index c50c0c8..0249bdd 100644 --- a/custom/org-format.el +++ b/custom/org-format.el @@ -1,38 +1,50 @@ (defun org-format () (interactive) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward " -" nil t) (replace-match " –")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward " –" nil t) (replace-match " –")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward "/ –" nil t) (replace-match " –/")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward " \\.\\.\\." nil t) (replace-match " …")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward " …" nil t) (replace-match " …")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward "'" nil t) (replace-match "’")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward " \n" nil t) (replace-match "\n")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward "\n\"" nil t) (replace-match "\n“")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward " \"" nil t) (replace-match " “")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward "\"" nil t) (replace-match "”")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward "“/" nil t) (replace-match "/“")) - (goto-char (region-beginning)) + (goto-char (point-min)) (while (re-search-forward "/”" nil t) - (replace-match "”/"))) + (replace-match "”/")) + (goto-char (point-min)) + (while (re-search-forward "=”" nil t) + (replace-match "=\"")) + (goto-char (point-min)) + (while (re-search-forward "”>" nil t) + (replace-match "\">")) + (goto-char (point-min)) + (while (re-search-forward "”/>" nil t) + (replace-match "\"/>")) + (goto-char (point-min)) + (while (re-search-forward "=\"\\([^>]*\\)”" nil t) + (replace-match "=\"\\1\""))) diff --git a/memoir.el b/memoir.el deleted file mode 100644 index e83a038..0000000 --- a/memoir.el +++ /dev/null @@ -1,9 +0,0 @@ -(require 'ox-latex) -(add-to-list 'org-latex-classes - '("memoir" - "\\documentclass{memoir} - [NO-DEFAULT-PACKAGES]" - ("\\chapter{%s}" . "\\chapter*{%s}") - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) diff --git a/org-export.el b/org-export.el new file mode 100644 index 0000000..83a1960 --- /dev/null +++ b/org-export.el @@ -0,0 +1,20 @@ +(require 'ox-latex) +(setq org-export-headline-levels 6) +(setq org-html-head-include-default-style nil) +(setq org-footnote-define-inline t) +(setq org-export-with-creator nil) +(setq org-export-with-toc nil) +(setq org-export-time-stamp-file nil) +(setq org-latex-default-class "memoir") +(setq org-latex-compiler "xelatex") +(setq org-html-validation-link nil) +(setq org-html-doctype "html5") +(add-to-list 'org-latex-classes + '("memoir" + "\\documentclass[9pt,b6paper]{memoir} + [NO-DEFAULT-PACKAGES] + \\input{header.tex}" + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))