org-download

a fork of abo-abo's org-download
git clone https://git.trogloxene.org/org-download.git
Log | Files | Refs | README

commit 137c3d2aa083283a3fc853f9ecbbc03039bf397b
parent c63b057e84b8ba1e7c969391a0263f7d0ce936e4
Author: Oleh Krehel <ohwoeowho@gmail.com>
Date:   Mon, 13 Feb 2017 20:51:29 +0100

org-download.el (org-download-method): Can be a function

Example:

(defun my-org-download-method (link)
  (let ((filename
         (file-name-nondirectory
          (car (url-path-and-query
                (url-generic-parse-url link))))))
    (message "current-buffer: %s" (current-buffer))

    (expand-file-name filename "~/")))
(setq org-download-method 'my-org-download-method)

Fixes #40

Diffstat:
Morg-download.el | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/org-download.el b/org-download.el @@ -85,7 +85,8 @@ "The way images should be stored." :type '(choice (const :tag "Directory" directory) - (const :tag "Attachment" attach)) + (const :tag "Attachment" attach) + (function :tag "Custom function")) :group 'org-download) (defcustom org-download-image-dir nil @@ -312,12 +313,15 @@ It's inserted before the image link and is used to annotate it.") (t (error "link %s does not point to an image; unaliasing failed" link))))) (let ((filename - (if (eq org-download-method 'attach) - (let ((org-download-image-dir (progn (require 'org-attach) - (org-attach-dir t))) - org-download-heading-lvl) - (org-download--fullname link ext)) - (org-download--fullname link ext)))) + (cond ((eq org-download-method 'attach) + (let ((org-download-image-dir (progn (require 'org-attach) + (org-attach-dir t))) + org-download-heading-lvl) + (org-download--fullname link ext))) + ((fboundp org-download-method) + (funcall org-download-method link)) + (t + (org-download--fullname link ext))))) (when (image-type-from-file-name filename) (org-download--image link filename) (when (eq org-download-method 'attach)