lang/org: resolve +org-dir later
Gives users more of a chance to change +org-dir before paths are resolved with it. Addresses #296
This commit is contained in:
parent
208fbb1726
commit
b0c73c486e
2 changed files with 6 additions and 8 deletions
|
@ -15,7 +15,7 @@
|
||||||
;; + `+org-attach/url'
|
;; + `+org-attach/url'
|
||||||
;; + :org [FILE/URL]
|
;; + :org [FILE/URL]
|
||||||
|
|
||||||
(defvar +org-attach-dir (expand-file-name ".attach/" +org-dir)
|
(defvar +org-attach-dir ".attach/"
|
||||||
"Where to store attachments (relative to current org file).")
|
"Where to store attachments (relative to current org file).")
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
(advice-add #'org-download-enable :override #'ignore)
|
(advice-add #'org-download-enable :override #'ignore)
|
||||||
:config
|
:config
|
||||||
(setq-default org-download-image-dir +org-attach-dir
|
(setq-default org-download-image-dir org-attach-directory
|
||||||
org-download-heading-lvl nil
|
org-download-heading-lvl nil
|
||||||
org-download-timestamp "_%Y%m%d_%H%M%S")
|
org-download-timestamp "_%Y%m%d_%H%M%S")
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(after! org
|
(after! org
|
||||||
(setq org-attach-directory +org-attach-dir)
|
(setq org-attach-directory (expand-file-name +org-attach-dir +org-dir))
|
||||||
|
|
||||||
(push (car (last (split-string +org-attach-dir "/" t)))
|
(push (car (last (split-string +org-attach-dir "/" t)))
|
||||||
projectile-globally-ignored-directories)
|
projectile-globally-ignored-directories)
|
||||||
|
|
||||||
(after! recentf
|
(after! recentf
|
||||||
(push (format "%s.+$" (regexp-quote +org-attach-dir))
|
(push (format "%s.+$" (regexp-quote org-attach-directory))
|
||||||
recentf-exclude)))
|
recentf-exclude)))
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ the cursor."
|
||||||
(delete-region (match-beginning 0) (match-end 0))
|
(delete-region (match-beginning 0) (match-end 0))
|
||||||
(newline))
|
(newline))
|
||||||
(cond ((image-type-from-file-name filename)
|
(cond ((image-type-from-file-name filename)
|
||||||
(when (file-in-directory-p filename +org-attach-dir)
|
(when (file-in-directory-p filename org-attach-directory)
|
||||||
(setq filename (file-relative-name filename +org-dir)))
|
(setq filename (file-relative-name filename +org-dir)))
|
||||||
(insert
|
(insert
|
||||||
(concat (if (= org-download-image-html-width 0)
|
(concat (if (= org-download-image-html-width 0)
|
||||||
|
@ -124,9 +124,7 @@ the cursor."
|
||||||
(let* ((context (save-match-data (org-element-context)))
|
(let* ((context (save-match-data (org-element-context)))
|
||||||
(file (org-link-unescape (org-element-property :path context)))
|
(file (org-link-unescape (org-element-property :path context)))
|
||||||
(default-directory
|
(default-directory
|
||||||
(if (string-prefix-p
|
(if (file-in-directory-p file org-attach-directory)
|
||||||
(concat "./" (car (last (split-string +org-attach-dir "/" t))))
|
|
||||||
file)
|
|
||||||
+org-dir
|
+org-dir
|
||||||
default-directory)))
|
default-directory)))
|
||||||
(apply orig-fn args))
|
(apply orig-fn args))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue