org-download

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

commit bbfca2fe4149f21105c70d3df76bb789b3868643
parent 3f0c5ef15589f02a51a4c58a6ff1713310aa3fc7
Author: Takeshi Teshima <takeshi.diadochos@gmail.com>
Date:   Fri,  6 Jan 2017 10:40:40 +0900

Refactor code (create format function)

Diffstat:
Morg-download.el | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/org-download.el b/org-download.el @@ -187,7 +187,7 @@ The directory is created if it didn't exist before." (defun org-download--fullname (link &optional ext) "Return the file name where LINK will be saved to. -It's affected by `org-download-timestamp' and `org-download--dir'. +It's affected by `org-download--dir'. EXT can hold the file extension, in case LINK doesn't provide it." (let ((filename (file-name-nondirectory @@ -198,12 +198,17 @@ EXT can hold the file extension, in case LINK doesn't provide it." (setq filename (replace-match "" nil nil filename 1))) (abbreviate-file-name (expand-file-name - (format "%s%s.%s" - (file-name-sans-extension filename) - (format-time-string org-download-timestamp) - (or ext (file-name-extension filename))) + (org-download--fullname-format filename ext) dir)))) +(defun org-download--fullname-format (filename &optional ext) + "It's affected by `org-download-timestamp'. +EXT can hold the file extension, in case FILENAME doesn't provide it." + (format "%s%s.%s" + (file-name-sans-extension filename) + (format-time-string org-download-timestamp) + (or ext (file-name-extension filename)))) + (defun org-download--image (link filename) "Save LINK to FILENAME asynchronously and show inline images in current buffer." (when (string= "file" (url-type (url-generic-parse-url link)))