branch: externals/org-transclusion
commit 0818c25d4444262fc7e6e3057df710c28e558d81
Author: Noboru Ota <[email protected]>
Commit: Noboru Ota <[email protected]>
refactor: run-hooks -> dolist
`run-hook-with-args' (and other `run-hook' functions) does not seem to
be designed to receive a returned value from each function. What I would
need is a way to apply each filter function one by one to the parse
tree (obj). `dolist' can be made do this.
---
org-transclusion.el | 32 ++++++++---------------
test/test-2.0.org | 73 ++---------------------------------------------------
2 files changed, 12 insertions(+), 93 deletions(-)
diff --git a/org-transclusion.el b/org-transclusion.el
index c5d66e70d3..5f37222a69 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -1152,14 +1152,6 @@ work to
org-link-search-must-match-exact-headline)))
(with-current-buffer buf
(org-with-wide-buffer
-<<<<<<< HEAD
- (org-transclusion-content-org-buffer-or-element
- (and search-option
- (progn
- (org-link-search search-option)
- t))
- plist))))))
-=======
(if search-option
(progn
(org-link-search search-option)
@@ -1167,7 +1159,6 @@ work to
'only-element plist))
(org-transclusion-content-org-filtered
nil plist)))))))
->>>>>>> 915600c (refactor content-org-filtered)
(defvar org-transclusion-content-filter-org-functions '())
@@ -1177,20 +1168,13 @@ work to
(add-hook 'org-transclusion-content-filter-org-functions
#'org-transclusion-content-filter-org-expand-links-function)
-<<<<<<< HEAD
-(defun org-transclusion-content-org-buffer-or-element (only-element plist)
- "Return a list of payload for transclusion.
-This function assumes the point is at the beginning of the org
-element to transclude.
-=======
(make-obsolete 'org-transclusion-content-org-buffer-or-element
- 'org-transclusion-content-org-filtered "1.4.0")
+ 'org-transclusion-content-org-filtered "1.4.1")
(defun org-transclusion-content-org-filtered (only-element plist)
- "Return the playload list for transclusion.
+ "Return a list of payload for transclusion.
This function assumes the point is at the beginning of the org
element to transclude.-
->>>>>>> 915600c (refactor content-org-filtered)
The payload is a plist that consists of the following properties:
- :src-content
@@ -1243,12 +1227,16 @@ property controls the filter applied to the
transclusion."
#'org-transclusion-content-filter-org-first-section
nil nil org-element-all-elements nil)))
;; Apply other filters
- (run-hook-with-args 'org-transclusion-content-filter-org-functions obj plist)
+ (dolist (fn org-transclusion-content-filter-org-functions)
+ (let ((obj-returned (funcall fn obj plist)))
+ ;; If nil is returned, do not change the org-content (obj)
+ (when obj-returned (setq obj obj-returned))))
obj)
(defun org-transclusion-content-filter-org-expand-links-function (obj plist)
- (when-let ((expand-links (plist-get plist :expand-links)))
- (org-element-map obj 'link
#'org-transclusion-content-filter-org-expand-links)))
+ (when (plist-get plist :expand-links)
+ (org-element-map obj 'link
#'org-transclusion-content-filter-org-expand-links)
+ obj))
(defun org-transclusion-content-filter-org-expand-links (link)
"Convert LINK to an absolute filename.
@@ -1289,7 +1277,7 @@ is non-nil."
(when-let ((only-contents (plist-get plist :only-contents)))
(org-element-map obj org-element-all-elements
#'org-transclusion-content-filter-org-only-contents
- nil nil '(section) nil)))
+ nil nil 'section nil)))
(defun org-transclusion-content-filter-org-only-contents (data)
"Exclude headlines from DATA to include only contents."
diff --git a/test/test-2.0.org b/test/test-2.0.org
index 8c0243205e..abe11926f4 100644
--- a/test/test-2.0.org
+++ b/test/test-2.0.org
@@ -28,76 +28,7 @@ t/nil will be dropped after remove-at-point
** test
-* Bertrand Russell - Wikipedia
-:ref:
-:link: https://en.wikipedia.org/wiki/Bertrand_Russell
-:END:
-
-*Bertrand Arthur William Russell, 3rd Earl Russell* OM FRS[65] (18 May 1872 –
2 February 1970) was a British polymath ande writer. He was born in
Monmouthshire into one of the most prominent aristocratic families in the
United Kingdom.
-
-#+transclude: [[file:bertrand-russell.org::*Bertrand Russell - Wikipedia]]
:level 1
-
-#+begin_export nil
-As an academic, he worked in philosophy, mathematics, and logic. His work has
had a considerable influence on mathematics, logic, set theory, linguistics,
artificial intelligence, cognitive science, computer science (see type theory
and type system) and various areas of analytic philosophy, especially logic,
philosophy of mathematics, philosophy of language, epistemology and metaphysics.
-#+end_export
-
-#+begin_src elisp
- If an integer $n$ is greater than 2, then the equation $a^n + b^n = c^n$
- has no solutions in non-zero integers $a$, $b$, and $c$.
- This is live-sync'ed
-#+end_src
-
-Russell was also a public intellectual, historian, social critic, political
activist, and Nobel laureate.[66][67] Throughout his life, Russell considered
himself a liberal, a socialist and a pacifist, although he later wrote he had
"never been any of these things, in any profound sense".[68] This is live sync.
As you can see, the edit on the left (transclusion) is copied over to the
right (source)
-
-Below is an example of a LaTex environment
-
-\begin{equation}
-x=\sqrt{b}
-\end{equation}
-
-: fixed width element
-: Second line
-
-
-\begin{align*}
-2x - 5y &= 8 \\
-3x + 9y &= -12
-\end{align*}
-
-** H2
-:ref:
-:data: data
-:END:
-
-#+begin_example
- Russell is one of the early 20th century's most prominent logicians,[67] and
one of the founders of analytic philosophy, along with his predecessor Gottlob
Frege, his friend and colleague G. E. Moore and his student and protégé Ludwig
Wittgenstein.
-#+end_example
-
-#+begin_verse
-Great clouds overhead
-Tiny black birds rise and fall
-Snow covers Emacs
-
- ---AlexSchroeder
- Verse can be live-synced
-#+end_verse
-
-#+begin: dynamic
-Russell with Moore led the British "revolt against idealism".[a] Together with
his former teacher A. N. Whitehead, Russell wrote Principia Mathematica, a
milestone in the development of classical logic, and a major attempt to reduce
the whole of mathematics to logic (see Logicism). Russell's article On Denoting
has been considered a "paradigm of philosophy".[70]
-#+end:
-
-*** H3
-This is content of H3
-
-
-** Test =org-adapt-indentation=
-
-#+begin_example
-(setq org-adapt-indentation nil)
-(setq org-adapt-indentation t)
-#+end_example
-
-#+transclude: [[id:2022-05-30T203553][Bertrand Russell]]
+#+transclude: [[id:2022-05-30T203553][Bertrand Russell]] :only-contents
** Paragraph
@@ -183,7 +114,7 @@ Temporarily set ~org-transclusion-include-first-section~ to
nil
#+transclude: [[file:bertrand-russell.org::*On Denoting]] :level 2
:only-contents :exclude-elements "headline drawer"
** test
-#+transclude: [[file:bertrand-russell.org::*On Denoting]] :level 2
:only-contents :exclude-elements "headline drawer"
+#+transclude: [[file:bertrand-russell.org::*On Denoting]] :level 2
:only-contents :exclude-elements "headline drawer"
* Disable-auto
** *Hadline