Steal everything from ox-extra in org-contrib
This commit is contained in:
parent
329ef63e16
commit
5085d5438b
64
README.org
64
README.org
@ -824,14 +824,54 @@ Stolen from [[https://git.sr.ht/~bzg/org-contrib/tree/master/item/lisp/ox-extra.
|
|||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(with-eval-after-load 'ox
|
(with-eval-after-load 'ox
|
||||||
(defun my-org-export-ignore-headline-filter (_)
|
(defun org-export-ignore-headlines (data backend info)
|
||||||
"Ignore all headlines with the \":ignore:\" tag."
|
"Remove headlines tagged \"ignore\" retaining contents and promoting children.
|
||||||
(org-map-entries
|
Each headline tagged \"ignore\" will be removed retaining its
|
||||||
(lambda ()
|
contents and promoting any children headlines to the level of the
|
||||||
(delete-region (point) (line-beginning-position 2)))
|
parent."
|
||||||
":ignore:"))
|
(org-element-map data 'headline
|
||||||
|
(lambda (object)
|
||||||
|
(when (member "ignore" (org-element-property :tags object))
|
||||||
|
(let ((level-top (org-element-property :level object))
|
||||||
|
level-diff)
|
||||||
|
(mapc (lambda (el)
|
||||||
|
;; recursively promote all nested headlines
|
||||||
|
(org-element-map el 'headline
|
||||||
|
(lambda (el)
|
||||||
|
(when (equal 'headline (org-element-type el))
|
||||||
|
(unless level-diff
|
||||||
|
(setq level-diff (- (org-element-property :level el)
|
||||||
|
level-top)))
|
||||||
|
(org-element-put-property
|
||||||
|
el :level (- (org-element-property :level el)
|
||||||
|
level-diff)))))
|
||||||
|
;; insert back into parse tree
|
||||||
|
(org-element-insert-before el object))
|
||||||
|
(org-element-contents object)))
|
||||||
|
(org-element-extract-element object)))
|
||||||
|
info nil)
|
||||||
|
(org-extra--merge-sections data backend info)
|
||||||
|
data)
|
||||||
|
|
||||||
(defun my-org-latex-header-blocks-filter (backend)
|
(defun org-extra--merge-sections (data _backend info)
|
||||||
|
(org-element-map data 'headline
|
||||||
|
(lambda (hl)
|
||||||
|
(let ((sections
|
||||||
|
(cl-loop
|
||||||
|
for el in (org-element-map (org-element-contents hl)
|
||||||
|
'(headline section) #'identity info)
|
||||||
|
until (eq (org-element-type el) 'headline)
|
||||||
|
collect el)))
|
||||||
|
(when (and sections
|
||||||
|
(> (length sections) 1))
|
||||||
|
(apply #'org-element-adopt-elements
|
||||||
|
(car sections)
|
||||||
|
(cl-mapcan (lambda (s) (org-element-contents s))
|
||||||
|
(cdr sections)))
|
||||||
|
(mapc #'org-element-extract-element (cdr sections)))))
|
||||||
|
info))
|
||||||
|
|
||||||
|
(defun org-latex-header-blocks-filter (backend)
|
||||||
"Convert marked LaTeX export blocks to \"#+latex_header: \" lines.
|
"Convert marked LaTeX export blocks to \"#+latex_header: \" lines.
|
||||||
The marker is a line \"#+header: :header yes\" preceding the block.
|
The marker is a line \"#+header: :header yes\" preceding the block.
|
||||||
|
|
||||||
@ -874,10 +914,12 @@ Stolen from [[https://git.sr.ht/~bzg/org-contrib/tree/master/item/lisp/ox-extra.
|
|||||||
(defun my-activate-buffer-local-org-export-filters ()
|
(defun my-activate-buffer-local-org-export-filters ()
|
||||||
"Activate my export filters locally in the current buffer."
|
"Activate my export filters locally in the current buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(add-hook 'org-export-before-parsing-hook
|
(set (make-local-variable 'org-export-filter-parse-tree-functions)
|
||||||
#'my-org-export-ignore-headline-filter nil 'local)
|
(cl-pushnew #'org-export-ignore-headlines
|
||||||
(add-hook 'org-export-before-parsing-hook
|
org-export-filter-parse-tree-functions))
|
||||||
#'my-org-latex-header-blocks-filter nil 'local)))
|
(set (make-local-variable 'org-export-before-parsing-hook)
|
||||||
|
(cl-pushnew #'org-latex-header-blocks-filter
|
||||||
|
org-export-before-parsing-hook))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+name: emacs-lisp-setup
|
#+name: emacs-lisp-setup
|
||||||
|
Loading…
Reference in New Issue
Block a user