[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dslide c2b4d2991a: Re-factor out property plist reader
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dslide c2b4d2991a: Re-factor out property plist reader |
Date: |
Mon, 25 Nov 2024 12:59:49 -0500 (EST) |
branch: elpa/dslide
commit c2b4d2991a733df467fd5cd4abd3c9fdd97c8f13
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>
Re-factor out property plist reader
We also needed this for future babel block simplification.
I didn't want to use `org-export-read-attribute' because it favors returning
strings we likely want to use straight up lisp forms in places.
Anyway, makes the text property action a lot simpler.
---
dslide.el | 38 +++++++++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/dslide.el b/dslide.el
index 847ec6c06d..6a1481a5e0 100644
--- a/dslide.el
+++ b/dslide.el
@@ -1297,17 +1297,13 @@ for `dslide-contents-map'.")
(dslide-section-map
obj t ; t for all types
(lambda (e)
- (when-let ((keywords (org-element-property :attr_dslide_propertize e))
+ (when-let ((props (nreverse (dslide-element-plist
+ :attr_dslide_propertize e)))
(overlay (make-overlay (org-element-property :post-affiliated
e)
(1- (org-element-property :end e)))))
- (while-let ((keyword (pop keywords))
- (offset 0))
- (while-let ((prop (ignore-error end-of-file
- (read-from-string keyword offset)))
- (value (ignore-error end-of-file
- (read-from-string keyword (cdr prop)))))
- (overlay-put overlay (car prop) (car value))
- (setq offset (cdr value))))
+ (while-let ((value (pop props))
+ (prop (pop props)))
+ (overlay-put overlay prop value))
(push overlay dslide-overlays)))))
(cl-defmethod dslide-end ((obj dslide-action-propertize))
@@ -2916,6 +2912,30 @@ for commands without visible side effects."
'(dslide) (cdr err))))
(reverse classes-with-args))))
+(defun dslide-element-plist (property element)
+ "Return a plist from ELEMENT for PROPERTY.
+PROPERTY can be an affilated keyword property or another property. The
+only requirement is that the value of PROPERTY must be a string or list
+of strings. We will attempt to parse the value using `read-from-string'
+and cons the results into a plist. `plist-get' always returns the first
+key. It is the user's responsibility not to overload keys and expect
+more than first-key wins behavior."
+ (when-let* ((plist-strings (org-element-property property element))
+ (plist-strings (if (listp plist-strings) plist-strings
+ (list plist-strings))))
+ (let (result)
+ (while-let ((plist-string (pop plist-strings)))
+ (let ((pos 0))
+ (condition-case nil
+ (while pos
+ (let* ((key (read-from-string plist-string pos))
+ (val (read-from-string plist-string (cdr key))))
+ (push (car key) result)
+ (push (car val) result)
+ (setq pos (cdr val))))
+ (end-of-file nil))))
+ (nreverse result))))
+
;; This should not interpret nil's specially because that should he handled
;; upstream by the parse functions
(defun dslide--class (class-name &optional signal)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/dslide c2b4d2991a: Re-factor out property plist reader,
ELPA Syncer <=