   :type 'boolean
   :group 'elfeed)
 
+(defvar elfeed-show-enclosure-filename-function
+  #'elfeed-show-enclosure-filename-remote
+  "Function called to generate the filename for an enclosure.")
+
 (defun elfeed--download-enclosure (url path)
   "Download asynchronously the enclosure from URL to PATH."
   (if (require 'async nil :noerror)

          (dolist (enclosure-index attachnums)
            (let* ((url-enclosure
                    (aref (elfeed-entry-enclosures entry) enclosure-index))
                   (fname (file-name-nondirectory
                           (url-unhex-string
                            (car (url-path-and-query
                                  (url-generic-parse-url url-enclosure))))))
                   (retry t))
              (while retry
                (setf fpath (expand-file-name (concat attachdir fname) path)

                               "Enclosure to save" entry)))
         (url-enclosure (car (elt (elfeed-entry-enclosures entry)
                                  (- enclosure-index 1))))
         (fname
          (funcall elfeed-show-enclosure-filename-function
                   entry url-enclosure))
         (retry t)
         (fpath))
    (while retry
