mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
Add modules/lang/org (WIP)
This commit is contained in:
44
modules/lang/org/+attach.el
Normal file
44
modules/lang/org/+attach.el
Normal file
@ -0,0 +1,44 @@
|
||||
;;; emacs/org/+attach.el --- -*- no-byte-compile: t; -*-
|
||||
|
||||
;; FIXME
|
||||
;; 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'
|
||||
(add-hook '+org-init-hook '+org|init-attach t)
|
||||
|
||||
(defun +org|init-attach ()
|
||||
(setq org-attach-directory +org-attachment-dir)
|
||||
|
||||
;; Don't track attachments in recentf or projectile
|
||||
(push (format "/%s.+$" (regexp-quote +org-attachment-dir)) recentf-exclude)
|
||||
(push ".attach" projectile-globally-ignored-file-suffixes)
|
||||
|
||||
;; 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
|
||||
(advice-add 'org-download--dir-2 :override 'ignore)
|
||||
(defun +org*download-fullname (path)
|
||||
(file-relative-name path (f-dirname (buffer-file-name))))
|
||||
(advice-add 'org-download--fullname :filter-return '+org*download-fullname)
|
||||
|
||||
;; 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
|
||||
;; (@map :leader :n "oa" (@find-file-in +org-attachment-dir))
|
||||
)
|
||||
|
Reference in New Issue
Block a user