2017-06-10 01:52:44 +02:00
|
|
|
;;; lang/org/+attach.el -*- lexical-binding: t; -*-
|
2017-02-19 19:01:47 -05:00
|
|
|
|
2017-02-28 12:12:09 -05:00
|
|
|
;; FIXME Needs to be rewritten
|
|
|
|
;;
|
2017-02-19 19:01:47 -05:00
|
|
|
;; Initializes my own org-mode attachment system. I didn't like Org's native
|
|
|
|
;; one. Mine stores attachments in a global org .attach directory. It also
|
|
|
|
;; implements drag-and-drop file support and attachment icons. It also treats
|
|
|
|
;; images specially.
|
|
|
|
;;
|
|
|
|
;; To clean up unreferenced attachments, call `doom/org-cleanup-attachments'
|
2017-05-19 03:29:00 +02:00
|
|
|
(add-hook '+org-init-hook #'+org|init-attach t)
|
2017-02-19 19:01:47 -05:00
|
|
|
|
|
|
|
(defun +org|init-attach ()
|
|
|
|
(setq org-attach-directory +org-attachment-dir)
|
|
|
|
|
2017-06-05 16:56:13 +02:00
|
|
|
;; Don't track attachments in projectile or recentf
|
2017-02-19 19:01:47 -05:00
|
|
|
(push ".attach" projectile-globally-ignored-file-suffixes)
|
2017-06-05 16:56:13 +02:00
|
|
|
(after! recentf
|
|
|
|
(push (format "/%s.+$" (regexp-quote +org-attachment-dir)) recentf-exclude))
|
2017-02-19 19:01:47 -05:00
|
|
|
|
|
|
|
;; FIXME Use all-the-icons
|
|
|
|
;; (doom-fix-unicode '("FontAwesome" 13) ? ? ? ? ? ? ? ?)
|
|
|
|
;; Drag-and-drop support
|
|
|
|
(require 'org-download)
|
|
|
|
(setq-default org-download-image-dir +org-attachment-dir
|
|
|
|
org-download-heading-lvl nil
|
|
|
|
org-download-timestamp "_%Y%m%d_%H%M%S")
|
|
|
|
|
|
|
|
(setq org-download-screenshot-method
|
|
|
|
(cond (IS-MAC "screencapture -i %s")
|
|
|
|
(IS-LINUX "maim --opengl -s %s")))
|
|
|
|
|
|
|
|
;; Write download paths relative to current file
|
2017-04-17 02:17:10 -04:00
|
|
|
(advice-add #'org-download--dir-2 :override #'ignore)
|
2017-02-19 19:01:47 -05:00
|
|
|
(defun +org*download-fullname (path)
|
2017-02-25 02:11:24 -05:00
|
|
|
(file-relative-name path (file-name-directory (buffer-file-name))))
|
2017-04-17 02:17:10 -04:00
|
|
|
(advice-add #'org-download--fullname :filter-return #'+org*download-fullname)
|
2017-02-19 19:01:47 -05:00
|
|
|
|
|
|
|
;; Add another drag-and-drop handler that will handle anything but image files
|
|
|
|
(setq dnd-protocol-alist `(("^\\(https?\\|ftp\\|file\\|nfs\\):\\(//\\)?" . doom/org-download-dnd)
|
|
|
|
,@dnd-protocol-alist))
|
|
|
|
|
|
|
|
;; keybinds
|
2017-02-23 00:06:12 -05:00
|
|
|
;; (map! :leader :n "oa" (find-file-in! +org-attachment-dir))
|
2017-02-19 19:01:47 -05:00
|
|
|
)
|
|
|
|
|