branch: externals/ement
commit cd75afe780f848dcc4a63fa5a3a894906b15e36d
Author: Adam Porter <a...@alphapapa.net>
Commit: Adam Porter <a...@alphapapa.net>

    Fix: (ement-room-download-file) Require eww
    
    See 
<https://github.com/alphapapa/ement.el/pull/323#issuecomment-2868619676>.
    
    Reported-by: Phil Sainty <p...@catalyst.net.nz>
---
 ement-room.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/ement-room.el b/ement-room.el
index 7c729ffb6e..214f3a40c3 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -5950,6 +5950,7 @@ For use in `completion-at-point-functions'."
 
 ;;;; Downloading media/files
 
+;; We load `eww' to define this variable on-demand.
 (defvar eww-download-directory)
 
 (defun ement-room-download-file (event destination)
@@ -5957,18 +5958,20 @@ For use in `completion-at-point-functions'."
 If DESTINATION is a directory, use the file's default name;
 otherwise, download to the filename.  Interactively, download to
 `eww-download-directory'; with prefix, prompt for destination."
-  (interactive (list (ement-room--event-at (point))
-                     (if current-prefix-arg
+  (interactive (progn
+                 (require 'eww)
+                 (list (ement-room--event-at (point))
+                       (if current-prefix-arg
+                           (expand-file-name
+                            (read-file-name
+                             "Download to: "
+                             (cl-typecase eww-download-directory
+                               (string eww-download-directory)
+                               (function (funcall eww-download-directory)))))
                          (expand-file-name
-                          (read-file-name
-                           "Download to: "
-                           (cl-typecase eww-download-directory
-                             (string eww-download-directory)
-                             (function (funcall eww-download-directory)))))
-                       (expand-file-name
-                        (cl-typecase eww-download-directory
-                          (string eww-download-directory)
-                          (function (funcall eww-download-directory)))))))
+                          (cl-typecase eww-download-directory
+                            (string eww-download-directory)
+                            (function (funcall eww-download-directory))))))))
   (pcase-let (((cl-struct ement-event
                           (content (map ('filename event-filename)
                                         ('url mxc-url))))

Reply via email to