Function: org-attach-dir-get-create
org-attach-dir-get-create is an interactive and byte-compiled function
defined in org-attach.el.gz.
Signature
(org-attach-dir-get-create)
Documentation
Return existing or new directory associated with the current outline node.
org-attach-preferred-new-method decides how to attach new
directory if neither ID nor DIR property exist.
If the attachment by some reason cannot be created an error will be raised.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-attach.el.gz
(defun org-attach-dir-get-create ()
"Return existing or new directory associated with the current outline node.
`org-attach-preferred-new-method' decides how to attach new
directory if neither ID nor DIR property exist.
If the attachment by some reason cannot be created an error will be raised."
(interactive)
(let ((attach-dir (org-attach-dir nil 'no-fs-check)))
(unless attach-dir
(let (answer)
(when (eq org-attach-preferred-new-method 'ask)
(message "Create new ID [1] property or DIR [2] property for attachments?")
(setq answer (read-char-exclusive)))
(cond
((or (eq org-attach-preferred-new-method 'id) (eq answer ?1))
(let ((id (org-id-get nil t)))
(or (setq attach-dir (org-attach-dir-from-id id))
(error "Failed to get folder for id %s, \
adjust `org-attach-id-to-path-function-list'"
id))))
((or (eq org-attach-preferred-new-method 'dir) (eq answer ?2))
(setq attach-dir (org-attach-set-directory)))
((eq org-attach-preferred-new-method 'nil)
(error "No existing directory. DIR or ID property has to be explicitly created")))))
(unless attach-dir
(error "No attachment directory is associated with the current node"))
(unless (file-directory-p attach-dir)
(make-directory attach-dir t))
attach-dir))