[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-transclusion f49e6b5098 14/18: Merge branch 'pr209'
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-transclusion f49e6b5098 14/18: Merge branch 'pr209' |
Date: |
Sun, 21 Jan 2024 15:58:43 -0500 (EST) |
branch: externals/org-transclusion
commit f49e6b50981d0072eaed7eeee166f58b9d0c1986
Merge: 3024fe5716 53029d91a0
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
Merge branch 'pr209'
---
org-transclusion.el | 96 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 63 insertions(+), 33 deletions(-)
diff --git a/org-transclusion.el b/org-transclusion.el
index 1096cca7d7..3f189c6d16 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -187,13 +187,26 @@ This is for live-sync. Analogous to
org-transclusion-add-other-file)
"Define a list of functions to get a payload for transclusion.
These function take two arguments: Org link and keyword plist,
-and return a playload. The payload is defined as a property list
+and return a payload. The payload is defined as a property list
that consists of the following properties:
- :tc-type
- :src-buf
- :src-beg
-- :src-end")
+- :src-end
+
+Otherwise, the payload may be a named or lambda callback
+function. In that case, the callback function will be called
+with the following arguments:
+
+- \\+`link'
+- \\+`keyword-plist'
+- \\+`copy'
+
+In order for the transclusion to be inserted into the buffer, the
+callback function should generate a payload plist, then call
+`org-transclusion-add-callback', passing in the payload as well
+as the \\+`link', \\+`keyword-plist', and \\+`copy' arguments.")
(defvar org-transclusion-keyword-value-functions
'(org-transclusion-keyword-value-link
@@ -425,37 +438,54 @@ does not support all the elements.
(link (org-transclusion-wrap-path-to-link
(plist-get keyword-plist :link)))
(payload (run-hook-with-args-until-success
- 'org-transclusion-add-functions link keyword-plist))
- (tc-type (plist-get payload :tc-type))
- (src-buf (plist-get payload :src-buf))
- (src-beg (plist-get payload :src-beg))
- (src-end (plist-get payload :src-end))
- (src-content (plist-get payload :src-content)))
- (if (or (string= src-content "")
- (eq src-content nil))
- ;; Keep going with program when no content `org-transclusion-add-all'
- ;; should move to the next transclusion
- (progn (message
- (format
- "No content found with \"%s\". Check the link at point %d,
line %d"
- (org-element-property :raw-link link) (point)
(org-current-line))
- nil))
- (let ((beg (line-beginning-position))
- (end))
- (org-transclusion-with-inhibit-read-only
- (when (save-excursion
- (end-of-line) (insert-char ?\n)
- (org-transclusion-content-insert
- keyword-plist tc-type src-content
- src-buf src-beg src-end copy)
- (unless (eobp) (delete-char 1))
- (setq end (point))
- t)
- ;; `org-transclusion-keyword-remove' checks element at point is a
- ;; keyword or not
- (org-transclusion-keyword-remove)))
- (run-hook-with-args 'org-transclusion-after-add-functions beg end))
- t))))
+ 'org-transclusion-add-functions link keyword-plist)))
+ (if (functionp payload)
+ ;; Allow for asynchronous transclusion
+ (funcall payload link keyword-plist copy)
+ (org-transclusion-add-callback payload link keyword-plist copy)))))
+
+(defun org-transclusion-add-callback (payload link keyword-plist copy)
+ "Insert transcluded content with error handling.
+
+PAYLOAD should be a plist according to the description in
+`org-transclusion-add-functions'. LINK should be an org-element
+context object for the link. KEYWORD-PLIST should contain the
+\"#+transclude:\" keywords for the transclusion at point. With
+non-nil COPY, copy the transcluded content into the buffer.
+
+This function is intended to be called from within
+`org-transclusion-add' as well as callback functions returned by
+functions in `org-transclusion-add-functions'."
+ (let ((tc-type (plist-get payload :tc-type))
+ (src-buf (plist-get payload :src-buf))
+ (src-beg (plist-get payload :src-beg))
+ (src-end (plist-get payload :src-end))
+ (src-content (plist-get payload :src-content)))
+ (if (or (string= src-content "")
+ (eq src-content nil))
+ ;; Keep going with program when no content `org-transclusion-add-all'
+ ;; should move to the next transclusion
+ (progn (message
+ (format
+ "No content found with \"%s\". Check the link at point %d,
line %d"
+ (org-element-property :raw-link link) (point)
(org-current-line))
+ nil))
+ (let ((beg (line-beginning-position))
+ (end))
+ (org-transclusion-with-inhibit-read-only
+ (when (save-excursion
+ (end-of-line) (insert-char ?\n)
+ (org-transclusion-content-insert
+ keyword-plist tc-type src-content
+ src-buf src-beg src-end copy)
+ (unless (eobp) (delete-char 1))
+ (setq end (point))
+ t)
+ ;; `org-transclusion-keyword-remove' checks element at point is a
+ ;; keyword or not
+ (org-transclusion-keyword-remove)))
+ (run-hook-with-args 'org-transclusion-after-add-functions beg end))
+ t)))
;;;###autoload
(defun org-transclusion-add-all (&optional narrowed)
- [elpa] externals/org-transclusion 01dfc13a57 09/18: Fix typos in docstrings and comments, (continued)
- [elpa] externals/org-transclusion 01dfc13a57 09/18: Fix typos in docstrings and comments, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion e1c68d113d 08/18: Use org-export-before-processing-functions if available, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion 92b91d02c5 03/18: style: Use and instead of if in org-transclusion-content-org-link, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion eb29beb1a2 10/18: copyright 2024, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion da4576da34 11/18: test: minor change, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion 3024fe5716 13/18: Merge branch 'pr211', ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion dcc0a6ddd8 15/18: Merge branch 'pr214', ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion 18b81641e6 01/18: docs: Update docstring for org-transclusion-with-inhibit-read-only, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion e65cd19167 18/18: admin: copyright 2024, ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion 2d9290554e 12/18: Merge branch 'pr210', ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion f49e6b5098 14/18: Merge branch 'pr209',
ELPA Syncer <=
- [elpa] externals/org-transclusion ac0c46c004 16/18: Merge branch 'pr216', ELPA Syncer, 2024/01/21
- [elpa] externals/org-transclusion b93eaadd05 17/18: Merge branch 'pr213', ELPA Syncer, 2024/01/21