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

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

[nongnu] elpa/dslide dc441317fa 06/21: Image action is default. Checks f


From: ELPA Syncer
Subject: [nongnu] elpa/dslide dc441317fa 06/21: Image action is default. Checks for very-non-image links.
Date: Tue, 17 Dec 2024 13:00:52 -0500 (EST)

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

    Image action is default.  Checks for very-non-image links.
    
    This action was super not going to work without at least attempting to see 
if
    the link was likely an image before trying to do its thing.
---
 NEWS.org  |  2 ++
 dslide.el | 45 ++++++++++++++++++++++++++++-----------------
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index 0c6706681f..64f3e7b6a7 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -14,9 +14,11 @@
 * v0.6.0 Fighting Spam 💌 :latest:
 ** Added ➕
 ** Changed 🙅
+- Image action is now a default action (although default actions are going 
away.)
 - ⚠️ 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 💩
+- The image action will no longer haphazardly try to display links that don't 
look like an image.  Remote images, if they were working on your Emacs, may be 
affected.  File an issue, explain your setup, and workaround by downloading.
 * 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.
   + Markup will be reduced, not changed
diff --git a/dslide.el b/dslide.el
index 601c366de0..8603005ad6 100644
--- a/dslide.el
+++ b/dslide.el
@@ -318,7 +318,8 @@ keyword."
 
 ;; TODO test the use of plist args
 (defcustom dslide-default-actions '(dslide-action-hide-markup
-                                    dslide-action-propertize)
+                                    dslide-action-propertize
+                                    dslide-action-image)
   "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
@@ -1648,25 +1649,24 @@ Only affects standalone-display.")
           (dslide-section-map
            obj 'link
            (lambda (e)
-             (let ((overlay (make-overlay
-                             (1- (org-element-property :begin e))
-                             (org-element-property :end e))))
-               (overlay-put overlay 'invisible t)
-               (push overlay (oref obj overlays)))))))
+             (when (dslide--element-image-p e)
+               (let ((overlay (make-overlay
+                               (1- (org-element-property :begin e))
+                               (org-element-property :end e))))
+                 (overlay-put overlay 'invisible t)
+                 (push overlay (oref obj overlays))))))))
 
     ;; If not showing in buffer at all, just hide the links
     (dslide-section-map
      obj 'link
      (lambda (e)
-       (let ((overlay (make-overlay
-                       (1- (org-element-property :begin e))
-                       (org-element-property :end e))))
-         (overlay-put overlay 'invisible t)
-         (push overlay (oref obj overlays)))))))
+       (when (dslide--element-image-p e)
+         (let ((overlay (make-overlay
+                         (1- (org-element-property :begin e))
+                         (org-element-property :end e))))
+           (overlay-put overlay 'invisible t)
+           (push overlay (oref obj overlays))))))))
 
-;; TODO implementation relies on org link opening.  Does not check for file or
-;; check that image mode displays the link correctly.
-;; TODO make it just a link action?
 (cl-defmethod dslide-forward ((obj dslide-action-image))
   ;; When just revealing images without doing standalone display, we can
   ;; reverse in place, hiding and showing the same image when changing
@@ -1677,7 +1677,8 @@ Only affects standalone-display.")
          (slide-display (oref obj slide-display))
          (reverse-in-place (and (eq slide-display 'reveal)
                         (null standalone-display))))
-    (when-let ((link (dslide-section-next obj 'link nil reverse-in-place)))
+    (when-let ((link (dslide-section-next
+                      obj 'link #'dslide--element-image-p reverse-in-place)))
       ;; Show the image standalone
       (when (member standalone-display '(full-frame window t))
         (dslide-push-window-config nil)
@@ -1718,7 +1719,8 @@ Only affects standalone-display.")
                       (overlay-put overlay 'invisible t)
                       (push overlay (oref obj overlays)))
                     ;; Punch the progress tracking marker
-                    (dslide-section-previous obj 'link nil reverse-in-place)
+                    (dslide-section-previous
+                     obj 'link #'dslide--element-image-p reverse-in-place)
                     t))))))
           ;; Restore the buffer after we're done
           (set-buffer (oref dslide--deck slide-buffer))))
@@ -1745,7 +1747,8 @@ Only affects standalone-display.")
          (slide-display (oref obj slide-display))
          (reverse-in-place (and (eq slide-display 'reveal)
                         (null standalone-display))))
-    (when-let ((link (dslide-section-previous obj 'link nil reverse-in-place)))
+    (when-let ((link (dslide-section-previous
+                      obj 'link #'dslide--element-image-p reverse-in-place)))
       (when (member standalone-display '(full-frame window t))
         (dslide-push-window-config nil)
         ;; TODO success detection
@@ -2468,6 +2471,14 @@ be a list of types or a type from 
`org-element-all-elements.'"
         (member element-type type)
       (eq element-type type))))
 
+(defun dslide--element-image-p (element)
+  (and (eq 'link (org-element-type element))
+       (when-let ((type (org-element-property :type element)))
+         (and (eq 'file (intern-soft type))
+              (org-file-image-p (org-element-property
+                                 :path element))
+              element))))
+
 ;; TODO cruft
 (defun dslide--heading-p (element)
   (dslide-type-p element 'headline))



reply via email to

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