lang/org: use org-attach instead of custom system
- Adds more keys under `<localleader> a` - Reconfigures org-download to use org-attach system - Make org-id-track-globally = t a global default now (not just for org-brain) - Renamed +org-init-centralized-attachments-h to +org-init-attachments-h - org-attach-store-link-p = t (stores a link to an attachment when it is attached) - org-attach-use-inheritance = t (inherit attachment properties from parent nodes)
This commit is contained in:
parent
54f42fef23
commit
14cf97e594
4 changed files with 62 additions and 119 deletions
|
@ -355,42 +355,14 @@ underlying, modified buffer. This fixes that."
|
|||
(add-hook '+doom-dashboard-inhibit-functions #'+org-capture-frame-p)))
|
||||
|
||||
|
||||
(defun +org-init-centralized-attachments-h ()
|
||||
"I believe Org's native attachment system is over-complicated and litters
|
||||
files with metadata I don't want. So I wrote my own, which:
|
||||
|
||||
+ Places attachments in a centralized location (`org-attach-id-dir' in
|
||||
`org-directory').
|
||||
+ Adds attach:* link abbreviation for quick links to these files from anywhere.
|
||||
+ Use `+org-attach/sync' to index all attachments in `org-directory' that use
|
||||
the attach:* abbreviation and delete orphaned ones that are no longer
|
||||
referenced.
|
||||
+ This compliments the +dragndrop flag which provides drag'n'drop support for
|
||||
images (with preview) and media files.
|
||||
|
||||
Some commands of interest:
|
||||
+ `org-download-screenshot'
|
||||
+ `+org-attach/file'
|
||||
+ `+org-attach/url'
|
||||
+ `+org-attach/sync'"
|
||||
(setq org-attach-id-dir (doom-path org-directory org-attach-id-dir))
|
||||
|
||||
;; A shorter link to attachments
|
||||
(add-to-list 'org-link-abbrev-alist
|
||||
(cons "attach"
|
||||
(abbreviate-file-name org-attach-id-dir)))
|
||||
|
||||
(org-link-set-parameters
|
||||
"attach"
|
||||
:follow (lambda (link) (find-file (doom-path org-attach-id-dir link)))
|
||||
:complete (lambda (&optional _arg)
|
||||
(+org--relpath (+org-link-read-file "attach" org-attach-id-dir)
|
||||
org-attach-id-dir))
|
||||
:face (lambda (link)
|
||||
(if (file-exists-p (expand-file-name link org-attach-id-dir))
|
||||
'org-link
|
||||
'error)))
|
||||
|
||||
(defun +org-init-attachments-h ()
|
||||
"Sets up org's attachment system."
|
||||
;; Centralized attachments directory
|
||||
(setq org-attach-id-dir (doom-path org-directory org-attach-id-dir)
|
||||
;; Store a link to attachments when they are attached
|
||||
org-attach-store-link-p t
|
||||
;; Inherit attachment properties from parent nodes
|
||||
org-attach-use-inheritance t)
|
||||
(after! projectile
|
||||
(add-to-list 'projectile-globally-ignored-directories org-attach-id-dir)))
|
||||
|
||||
|
@ -650,10 +622,21 @@ between the two."
|
|||
"t" #'org-todo
|
||||
"T" #'org-todo-list
|
||||
(:prefix ("a" . "attachments")
|
||||
"a" #'+org-attach/file
|
||||
"u" #'+org-attach/uri
|
||||
"f" #'+org-attach/find-file
|
||||
"s" #'+org-attach/sync)
|
||||
"a" #'org-attach
|
||||
"d" #'org-attach-delete-one
|
||||
"D" #'org-attach-delete-all
|
||||
"f" #'+org/find-file-in-attachments
|
||||
"l" #'+org/attach-file-and-insert-link
|
||||
"n" #'org-attach-new
|
||||
"o" #'org-attach-open
|
||||
"O" #'org-attach-open-in-emacs
|
||||
"r" #'org-attach-reveal
|
||||
"R" #'org-attach-reveal-in-emacs
|
||||
"u" #'org-attach-url
|
||||
"s" #'org-attach-set-directory
|
||||
"S" #'org-attach-sync
|
||||
(:when (featurep! +dragndrop)
|
||||
"y" #'org-download-yank))
|
||||
(:prefix ("b" . "tables")
|
||||
"-" #'org-table-insert-hline
|
||||
"a" #'org-table-align
|
||||
|
@ -944,11 +927,14 @@ compelling reason, so..."
|
|||
org-capture
|
||||
:preface
|
||||
;; Change org defaults (should be set before org loads)
|
||||
(defvar org-directory "~/org/")
|
||||
(defvar org-attach-id-dir ".attach/")
|
||||
|
||||
(setq org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/")
|
||||
org-preview-latex-image-directory (concat doom-cache-dir "org-latex/"))
|
||||
(setq org-directory "~/org/"
|
||||
org-attach-id-dir ".attach/"
|
||||
org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/")
|
||||
org-preview-latex-image-directory (concat doom-cache-dir "org-latex/")
|
||||
org-id-locations-file (concat doom-etc-dir "org-id-locations")
|
||||
;; Global ID state means we can have ID links anywhere (required by
|
||||
;; `org-brain')
|
||||
org-id-track-globally t)
|
||||
|
||||
(defvar org-modules
|
||||
'(;; ol-w3m
|
||||
|
@ -978,11 +964,11 @@ compelling reason, so..."
|
|||
(add-hook! 'org-load-hook
|
||||
#'+org-init-appearance-h
|
||||
#'+org-init-agenda-h
|
||||
#'+org-init-attachments-h
|
||||
#'+org-init-babel-h
|
||||
#'+org-init-babel-lazy-loader-h
|
||||
#'+org-init-capture-defaults-h
|
||||
#'+org-init-capture-frame-h
|
||||
#'+org-init-centralized-attachments-h
|
||||
#'+org-init-centralized-exports-h
|
||||
#'+org-init-custom-links-h
|
||||
#'+org-init-export-h
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue