branch: elpa/dslide
commit dd3b7c529838ffa61939ba848682080a49d413b6
Author: Psionik K <73710933+psioni...@users.noreply.github.com>
Commit: Psionik K <73710933+psioni...@users.noreply.github.com>

    Configurable element hiding, including comment-blocks
    
    Signed-off-by: Psionik K <73710933+psioni...@users.noreply.github.com>
---
 dslide.el     | 38 ++++++++++++++++++++++++--------------
 test/demo.org |  6 ++++++
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/dslide.el b/dslide.el
index 222d512f25..cd4f42a50d 100644
--- a/dslide.el
+++ b/dslide.el
@@ -355,6 +355,17 @@ an DSLIDE_FILTER keyword."
   :type 'function
   :group 'dslide)
 
+;; TODO can also probably be objects.  Use case?
+(defcustom dslide-hide-markup-types '(comment
+                                      comment-block
+                                      drawer
+                                      property-drawer
+                                      keyword)
+  "Default types to be hidden by `dslide-action-hide-markup'.
+Can be any element in `org-element-all-elements'."
+  :type '(list symbol)
+  :group 'dslide)
+
 (defcustom dslide-contents-selection-highlight t
   "Show a highlight on the selected headline.
 This is useful if you have some subtle cursor feature enabled for
@@ -1184,27 +1195,26 @@ for `dslide-contents-map'."
     (set-marker marker nil)))
 
 ;; ** Hide Markup Action
-(defclass dslide-action-hide-markup (dslide-action)
-  ((types
-    :initform '(drawer property-drawer)
-    :initarg :types
-    :description "Either org element or types that should be hidden."))
+;; TODO allow configuration via plist args
+;; TODO precedence order of default actions
+(defclass dslide-action-hide-markup (dslide-action) ()
   "Hides element based on type.")
 
 (cl-defmethod dslide-begin ((obj dslide-action-hide-markup))
-  (dslide-section-map obj (oref obj types)
+  (dslide-section-map obj dslide-hide-markup-types
                       (lambda (e) (push (dslide-hide-element e) 
dslide--overlays)))
   ;; Ooooh! right, yeah, the element parser doesn't give you affiliated 
keywords
   ;; when you ask for keywords.  As much sense as that would make, the only
   ;; technique I've found for this is falling back to regex.
-  (save-excursion
-    (let ((bound (org-element-property :end (dslide-heading obj))))
-      (goto-char (oref obj begin))
-      (while (re-search-forward org-keyword-regexp bound t)
-        (let ((overlay (make-overlay (match-beginning 0)
-                                     (1+ (match-end 0)))))
-          (overlay-put overlay 'invisible t)
-          (push dslide--overlays overlay))))))
+  (when (member 'keyword dslide-hide-markup-types)
+    (save-excursion
+      (let ((bound (org-element-property :end (dslide-heading obj))))
+        (goto-char (oref obj begin))
+        (while (re-search-forward org-keyword-regexp bound t)
+          (let ((overlay (make-overlay (match-beginning 0)
+                                       (1+ (match-end 0)))))
+            (overlay-put overlay 'invisible t)
+            (push dslide--overlays overlay)))))))
 
 (cl-defmethod dslide-end ((obj dslide-action-hide-markup))
   (dslide-begin obj))
diff --git a/test/demo.org b/test/demo.org
index 2e8f823470..2667dbcaf5 100644
--- a/test/demo.org
+++ b/test/demo.org
@@ -125,6 +125,12 @@ Positron is deeply committed to bringing you the finest in:
 - But there is no title or other header information
 - See more options in the ~dslide-action-narrow~ class slots:
   =M-x describe-symbol dslide-action-narrow=
+* Markup Hiding
+#+begin_comment
+You can't see this during the presentation.  Convenient for reminding yourself 
to say something but not including it in the presentation.
+#+end_comment
+See ~dslide-hide-markup-types~.  By default, property drawers and keywords are 
hidden with overlays.  Comment blocks are also hidden.  There is a comment 
block above this paragraph.
+# There is a comment after this paragraph too.
 * Babel Slide Integration
 :PROPERTIES:
 :DSLIDE_ACTIONS: dslide-action-babel

Reply via email to