lang/org: move org-yt out of +attach in config.el
This commit is contained in:
parent
ecaa8fc7cd
commit
b2927955e7
2 changed files with 23 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue