[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dslide 39495bb1c2 05/21: warn when propertize is given unq
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dslide 39495bb1c2 05/21: warn when propertize is given unquoted lists. better parsing. |
Date: |
Tue, 17 Dec 2024 13:00:52 -0500 (EST) |
branch: elpa/dslide
commit 39495bb1c206ae862f3cd2372c951e7ead5425ac
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>
warn when propertize is given unquoted lists. better parsing.
parsing gets used later by new / changed actions
---
NEWS.org | 2 ++
dslide.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
test/demo.org | 6 ++----
3 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 88dcfe163e..0c6706681f 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -14,6 +14,8 @@
* v0.6.0 Fighting Spam 💌 :latest:
** Added ➕
** Changed 🙅
+- ⚠️ Propertize action now warns on unquoted lists. Please use quoted lists.
In my opinion, all lists should be considered quoted in org, but this change is
consistent with babel parameters being evaluated when unquoted.
+- Yet more manual Kaizen. Seriously, check it out by installing dslide.
** Fixed 💩
* v0.5.6 Let There Be News 🗞️
- ⛔ The concept of default actions has been marked for deprecation. This is
preparation for instantiating actions on-demand rather than per slide. The
action system may undergo some overhaul internally.
diff --git a/dslide.el b/dslide.el
index 4869156f1c..601c366de0 100644
--- a/dslide.el
+++ b/dslide.el
@@ -1331,12 +1331,22 @@ for `dslide-contents-map'.")
(dslide-section-map
obj t ; t for all types
(lambda (e)
- (when-let ((props (nreverse (dslide-element-plist
- :attr_dslide_propertize e)))
+ (when-let ((props (nreverse (dslide-read-affiliated
+ e :attr_dslide_propertize nil t)))
(overlay (make-overlay (org-element-property :post-affiliated
e)
(1- (org-element-property :end e)))))
(while-let ((value (pop props))
(prop (pop props)))
+ (when (listp value)
+ (if (eq (car value) 'quote)
+ (setq value (cdr value))
+ (delay-warning
+ '(dslide dslide-propertize dslide-unquoted)
+ (format "Propertize Unquoted list on %s"
+ (without-restriction
+ (line-number-at-pos
+ (org-element-property :begin e))))
+ :warning)))
(overlay-put overlay prop value))
(push overlay dslide-overlays)))))
@@ -3000,6 +3010,51 @@ the caller."
'(dslide)
(format "Class name not a class: %s" class-name))
nil))))
+;; XXX the text property action lists are unquoted while babel block lists are
+;; quoted. It would be better to normalize behavior, unquoted quoted lists
+;; and warning on unquoted lists.
+(defun dslide-read-plist (plist-string &optional start keywords)
+ "Reads PLIST-STRING into a plist.
+Returns a cons of (PLIST-READ . FINAL-STRING-INDEX) to support
+further reading. When keywords is non-nil, signal
+wrong-type-argument if any keys are not keywords. Missing
+terminal values will be interpreted as nil."
+ (let ((pos (or start 0))
+ result)
+ (condition-case nil
+ (while pos
+ (let* ((key (read-from-string plist-string pos)))
+ (if (or (null keywords)
+ (keywordp (car key)))
+ (push (car key) result)
+ (signal 'wrong-type-argument
+ (format "Symbol is not a keyword: %S" (car key))))
+ (let ((val (read-from-string plist-string (cdr key))))
+ (push (car val) result)
+ (setq pos (cdr val)))))
+ (end-of-file nil))
+ (nreverse result)))
+
+(defun dslide-read-affiliated (element property &optional keywords merged)
+ "Return plist for PROPERTY of ELEMENT.
+Affiliated keywords can have a list of value when several of the
+same affilated keyword annotate an object. When optional
+KEYWORDS is t, non-keywords will signal wrong-type-argument.
+When optional MERGED is non-nil, return a merged plist. The
+top-most affiliated keyword is considered the last to be called
+and thus overwrites the inner keywords when merging."
+ (let ((found (org-element-property property element))
+ read)
+ (while-let ((f (pop found)))
+ (let ((plist (dslide-read-plist f 0 keywords)))
+ (if merged
+ (while-let ((key (pop plist)))
+ (push key read)
+ (push (pop plist) read))
+ (push plist read))))
+ ;; Either reverses all keys or reverses the keyword order, making first
+ ;; keys in the outer list first in the result either way.
+ (nreverse read)))
;; * Contents Highlight Line
diff --git a/test/demo.org b/test/demo.org
index f8c4ff054d..641db3f669 100644
--- a/test/demo.org
+++ b/test/demo.org
@@ -164,13 +164,11 @@ This is another case where you can use
~dslide-deck-develop~ to see the comments
** TODO Todos and Tags :tag1:tag2:tag3:
Todos and tags are by default hidden. Set ~dslide-hide-tags~ and
~dslide-hide-todos~ if you need them visible in a presentation.
* Fancy Text
-:PROPERTIES:
-:DSLIDE_ACTIONS: dslide-action-propertize
-:END:
Add text properties to an element using the =attr_dslide_propertize=
affiliated keyword. No quoting is required. Lists will be interpreted as such.
-#+attr_dslide_propertize: face (:background "#ddddff" :foreground "#000000"
:weight bold :height 2.0)
+#+attr_dslide_propertize: face '(:background "#ddddff" :foreground "#000000"
:weight bold :height 1.5)
This is some fancy text
+
* Babel Integration
:PROPERTIES:
:DSLIDE_ACTIONS: dslide-action-babel
- [nongnu] elpa/dslide updated (0da4acfb73 -> b8e1399cc5), ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide dc441317fa 06/21: Image action is default. Checks for very-non-image links., ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide b1c52facb6 12/21: Keyboard macro transcription, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 39495bb1c2 05/21: warn when propertize is given unquoted lists. better parsing.,
ELPA Syncer <=
- [nongnu] elpa/dslide ad5bac3df1 08/21: Image defaults to no standalone display, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide b8509903cc 03/21: start news for 0.6.0, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 1ae8c7ce0c 02/21: Line noise, packaging, non-behavior changes, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 7d5a4f7dc6 01/21: Remove defunct test file from version control, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 7bea90a632 09/21: Babel block :direction parameter. No more spam!, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide fbf801fc91 10/21: Notes about org-confirm-babel-evaluate, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 7d527c9032 14/21: Generated files, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 0ad1ec8218 15/21: Fix for window scroll when opening contents, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide 2323468110 16/21: small corrections in the demo, ELPA Syncer, 2024/12/17
- [nongnu] elpa/dslide e585c80697 18/21: Re-generate documentation, ELPA Syncer, 2024/12/17