[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dslide d71709fd00 118/230: custom action example from vide
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dslide d71709fd00 118/230: custom action example from video (it works!) |
Date: |
Sun, 7 Jul 2024 19:00:22 -0400 (EDT) |
branch: elpa/dslide
commit d71709fd001fa696f5c0f98ef7b60f12a746eabf
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>
custom action example from video (it works!)
Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
---
README.org | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/README.org b/README.org
index c8f7bbdaf0..4345134fb1 100644
--- a/README.org
+++ b/README.org
@@ -159,6 +159,50 @@ The deck and slide class as well as actions can all be
sub-classed. Use the exi
- *Deck*: If the core methods of the deck are insufficient, extension is
another option besides advice, hooks, and modifying the source.
If you suspect you might need to sub-class the ~dslide-slide~ or
~dslide-deck~, please file an issue because your use case is probably
interesting.
+*** Custom Action
+The ~dslide-section-next~ and ~dslide-section-previous~ method documentation
are very helpful behavior for quickly writing custom actions. They advance the
action's =:marker= forwards and backwards to the next matching element and
return that element so we can do something with it.
+
+- declare a class
+- override a few methods
+- now you too can paint the paragraphs red
+#+begin_src elisp
+
+ (defclass dslide-action-red-paragraphs (dslide-action)
+ ((overlays :initform nil))
+ "Paint the paragraphs red, one by one.")
+
+ ;; Default no-op `dslide-init' is sufficient
+
+ ;; Default implementation of `dslide-end', which just plays forward to the
end,
+ ;; is well-behaved with this class.
+
+ ;; Remove any remaining overlays when calling final.
+ (cl-defmethod dslide-final :after ((obj dslide-action-red-paragraphs))
+ (mapc #'delete-overlay (oref obj overlays)))
+
+ ;; Find the next paragraph and add an overlay if it exists
+ (cl-defmethod dslide-forward ((obj dslide-action-red-paragraphs))
+ (when-let ((paragraph (dslide-section-next obj 'paragraph)))
+ (let* ((beg (org-element-property :begin paragraph))
+ (end (org-element-property :end paragraph))
+ (new-overlay (make-overlay beg end)))
+ (overlay-put new-overlay 'face 'error)
+ (push new-overlay (oref obj overlays))
+ ;; Return non-nil to indicate progress was made. This also informs the
+ ;; highlight when following the slides in the base buffer.
+ beg)))
+
+ (cl-defmethod dslide-backward ((obj dslide-action-red-paragraphs))
+ (when-let* ((overlay (pop (oref obj overlays))))
+ (delete-overlay overlay))
+ ;; If there is a preceding overlay, move to its beginning else move to the
+ ;; beginning of the heading.
+ (if-let ((overlay (car (oref obj overlays))))
+ (prog1 t
+ (dslide-marker obj (overlay-start overlay)))
+ (dslide-marker obj (org-element-property :begin (dslide-heading obj)))))
+#+end_src
+
** Default Classes
The default classes and actions can be configured at the document or customize
level. Set the =DSLIDE_DECK_CLASS= and =DSLIDE_SLIDE_CLASS= as well as other
properties that work at the heading level. The order of precedence (*Not fully
implemented* 🚧):
- Property definition of the current heading
- [nongnu] elpa/dslide e9e4a75354 104/230: roll progress-tracking directly into the ms-action class, (continued)
- [nongnu] elpa/dslide e9e4a75354 104/230: roll progress-tracking directly into the ms-action class, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 578f5082bb 105/230: whitespace, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 25c2429ac7 096/230: centralize following logic, normalize progress indications, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 6eb2cefbca 097/230: line noise, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 648cb7247a 115/230: ms- -> dslide-, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide d74b869a12 117/230: back to feature parity with demo.org, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 53ab5eb653 101/230: convert image action fullscreen into an option, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide e0be8b31fa 112/230: renaming user commands & simplifying stateful-sequence, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 50fffb5824 124/230: babel action should not use default implementation of end, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide d0ae139d26 114/230: Version up, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide d71709fd00 118/230: custom action example from video (it works!),
ELPA Syncer <=
- [nongnu] elpa/dslide 0419d1310d 089/230: remove dead function, ms-display-base, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide a6a0d57738 110/230: init -> forward, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide f07a873181 128/230: per-slide option to have no header, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide a71554c68d 121/230: partial-lines in header margins, more options, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 72ffe8494d 116/230: !some cleanup of package renaming, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 6aea1165e1 141/230: Updated demo.org, rearranged, designing into a manual of sorts, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 7028c07ace 140/230: prefer eobp and bobp to point & point-min/max comparison, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide c1267f7508 136/230: Checkdoc cleanups, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide f295183145 135/230: Bumping to 0.3.2 - expect about 95% name stability from here, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide b06f330ca3 146/230: move highlight cleanup to proper cleanup function, ELPA Syncer, 2024/07/07