emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/dslide 92518d7978 7/7: introducing propertize action


From: ELPA Syncer
Subject: [nongnu] elpa/dslide 92518d7978 7/7: introducing propertize action
Date: Wed, 20 Nov 2024 18:59:35 -0500 (EST)

branch: elpa/dslide
commit 92518d79780d5d560538a3d7629c4c47aec6299c
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>

    introducing propertize action
    
    Convenient one-off text tweaking
    
    TODO on the supported types.  Paragraph and plain-list should cover most for
    now.
---
 dslide.el     | 38 +++++++++++++++++++++++++++++++++++++-
 test/demo.org |  8 ++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/dslide.el b/dslide.el
index dfc016c9d2..5ebb0e17a8 100644
--- a/dslide.el
+++ b/dslide.el
@@ -309,7 +309,8 @@ keyword."
   :type 'function)
 
 ;; TODO test the use of plist args
-(defcustom dslide-default-actions '(dslide-action-hide-markup)
+(defcustom dslide-default-actions '(dslide-action-hide-markup
+                                    dslide-action-propertize)
   "Actions that run within the section display action lifecycle.
 It's value is a list of symbol `dslide-action' sub-classes or (CLASS . ARGS)
 forms where ARGS is a plist.  Each subclass will be instantiated
@@ -1258,6 +1259,41 @@ for `dslide-contents-map'.")
 (cl-defmethod dslide-end ((obj dslide-action-hide-markup))
   (dslide-begin obj))
 
+;; ** Text Property Action
+;; Interpret text properties via affiliated keyword into text properties for
+;; more control over text display on slides.
+
+(defclass dslide-action-propertize (dslide-action) ()
+  "Interpret affiliated keywords into text properties.")
+
+(cl-defmethod dslide-begin ((obj dslide-action-propertize))
+  (dslide-section-map
+   obj '(paragraph src-block headline plain-list
+                   quote-block special-block
+                   table)
+   ;; TODO see `org-element-all-elements' and make this more comprehensive
+   (lambda (e)
+     (message "Element found: %s" (car e))
+     (when-let ((props (org-element-property
+                        :attr_dslide_propertize e)))
+       (let ((overlay (make-overlay (org-element-property :post-affiliated e)
+                                    (org-element-property :end e)))
+             (props (car props))        ; TODO multi-value support
+             (offset 0))
+         (while offset
+           (let* ((prop (ignore-error 'end-of-file
+                          (read-from-string props offset)))
+                  (value (ignore-error 'end-of-file
+                           (read-from-string props (cdr prop)))))
+             (if (and prop value)
+                 (progn (overlay-put overlay (car prop) (car value))
+                        (setq offset (cdr value)))
+               (setq offset nil))))
+         (push overlay dslide-overlays))))))
+
+(cl-defmethod dslide-end ((obj dslide-action-propertize))
+  (dslide-begin obj))
+
 ;; ** Item Reveal Action
 ;; Reveal items has a somewhat fun implementation.  The end state is actually
 ;; simpler than the begin state.  Going forward, we must remove overlays and
diff --git a/test/demo.org b/test/demo.org
index e3d771dce5..38212fc0ad 100644
--- a/test/demo.org
+++ b/test/demo.org
@@ -151,6 +151,14 @@ There is a comment block above this paragraph.  There is a 
comment below this pa
 This is another case where you can use ~dslide-deck-develop~ to see the 
comments while showing just presentation content in another window.  (use 
~make-frame~ 💡)
 ** 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)
+This is some fancy text
 * Babel Integration
 :PROPERTIES:
 :DSLIDE_ACTIONS: dslide-action-babel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]