From b2927955e775466cedc01e8a17751a594bb630bf Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 18 Oct 2018 12:51:35 -0400 Subject: [PATCH] lang/org: move org-yt out of +attach in config.el --- modules/lang/org/+attach.el | 22 ---------------------- modules/lang/org/config.el | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/lang/org/+attach.el b/modules/lang/org/+attach.el index 1eeee2618..eee6c0223 100644 --- a/modules/lang/org/+attach.el +++ b/modules/lang/org/+attach.el @@ -63,28 +63,6 @@ (advice-add #'org-download--fullname :filter-return #'+org-attach*download-fullname)) -(def-package! org-yt - :after org - :config - (defun +org-inline-data-image (_protocol link _description) - "Interpret LINK as base64-encoded image data." - (base64-decode-string link)) - - (defun +org-image-link (protocol link _description) - "Interpret LINK as base64-encoded image data." - (when (image-type-from-file-name link) - (let ((buf (url-retrieve-synchronously (concat protocol ":" link)))) - ;; TODO Better error handling - (cl-assert buf nil "Download of image \"%s\" failed." link) - (with-current-buffer buf - (goto-char (point-min)) - (re-search-forward "\r?\n\r?\n") - (buffer-substring-no-properties (point) (point-max)))))) - - (org-link-set-parameters "http" :image-data-fun #'+org-image-link) - (org-link-set-parameters "https" :image-data-fun #'+org-image-link) - (org-link-set-parameters "img" :image-data-fun #'+org-inline-data-image)) - ;; ;; Bootstrap diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 0b7efa70c..5f4098c72 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -61,7 +61,29 @@ ;; org links to pdf files are opened in pdf-view-mode (add-to-list 'org-file-apps '("\\.pdf\\'" . (lambda (_file link) (org-pdfview-open link)))) ;; support for links to specific pages - (add-to-list 'org-file-apps '("\\.pdf::\\([[:digit:]]+\\)\\'" . (lambda (_file link) (org-pdfview-open link)))))) + (add-to-list 'org-file-apps '("\\.pdf::\\([[:digit:]]+\\)\\'" . (lambda (_file link) (org-pdfview-open link)))))) + +(def-package! org-yt + :after org + :config + (defun +org-inline-data-image (_protocol link _description) + "Interpret LINK as base64-encoded image data." + (base64-decode-string link)) + + (defun +org-image-link (protocol link _description) + "Interpret LINK as base64-encoded image data." + (when (image-type-from-file-name link) + (let ((buf (url-retrieve-synchronously (concat protocol ":" link)))) + ;; TODO Better error handling + (cl-assert buf nil "Download of image \"%s\" failed." link) + (with-current-buffer buf + (goto-char (point-min)) + (re-search-forward "\r?\n\r?\n") + (buffer-substring-no-properties (point) (point-max)))))) + + (org-link-set-parameters "http" :image-data-fun #'+org-image-link) + (org-link-set-parameters "https" :image-data-fun #'+org-image-link) + (org-link-set-parameters "img" :image-data-fun #'+org-inline-data-image)) ;;