commit 785b14464c7250bfd4264189f38659f428868a74 parent 58a604549e9ef2ac78d44174cc70b7112af6a6ac Author: Oleh Krehel <ohwoeowho@gmail.com> Date: Mon, 14 Jan 2019 15:31:05 +0100 org-download.el (org-download-abbreviate-filename-function): New defcustom Fixes #88 Code: (setq org-download-abbreviate-filename-function 'expand-file-name) Diffstat:
| M | org-download.el | | | 36 | +++++++++++++++++++++--------------- |
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/org-download.el b/org-download.el @@ -389,26 +389,32 @@ It's inserted before the image link and is used to annotate it.") (while (re-search-forward oldpath nil t) (replace-match newpath)))) +(defcustom org-download-abbreviate-filename-function #'file-relative-name + "Function that takes FILENAME and DIRECTORY and returns an abbreviated file name." + :type '(choice + (const :tag "relative" file-relative-name) + (const :tag "absolute" expand-file-name))) + (defun org-download-insert-link (link filename) (if (looking-back "^[ \t]+" (line-beginning-position)) (delete-region (match-beginning 0) (match-end 0)) (newline)) + (insert (funcall org-download-annotate-function link)) + (insert "\n") + (insert (if (= org-download-image-html-width 0) + "" + (format "#+attr_html: :width %dpx\n" org-download-image-html-width))) + (insert (if (= org-download-image-latex-width 0) + "" + (format "#+attr_latex: :width %dcm\n" org-download-image-latex-width))) + (insert (if (= org-download-image-org-width 0) + "" + (format "#+attr_org: :width %dpx\n" org-download-image-org-width))) (insert - (concat - (funcall org-download-annotate-function link) - "\n" - (if (= org-download-image-html-width 0) - "" - (format "#+attr_html: :width %dpx\n" org-download-image-html-width)) - (if (= org-download-image-latex-width 0) - "" - (format "#+attr_latex: :width %dcm\n" org-download-image-latex-width)) - (if (= org-download-image-org-width 0) - "" - (format "#+attr_org: :width %dpx\n" org-download-image-org-width)) - (format org-download-link-format - (org-link-escape - (file-relative-name filename (file-name-directory (buffer-name))))))) + (format org-download-link-format + (org-link-escape + (funcall org-download-abbreviate-filename-function + filename (file-name-directory (buffer-name)))))) (org-display-inline-images)) (defun org-download--at-comment-p ()