org-attach: Attach buffers to tasks
* lisp/org-attach.el (org-attach-buffer): New function. (org-attach): Call new function. * doc/org-manual.org (Attachments): Document new function.
This commit is contained in:
parent
4241815770
commit
ae03104402
|
@ -7586,91 +7586,97 @@ The following commands deal with attachments:
|
|||
After these keys, a list of commands is displayed and you must
|
||||
press an additional key to select a command:
|
||||
|
||||
- {{{kbd(a)}}} (~org-attach-attach~) ::
|
||||
- {{{kbd(a)}}} (~org-attach-attach~) ::
|
||||
|
||||
#+kindex: C-c C-a a
|
||||
#+findex: org-attach-attach
|
||||
#+vindex: org-attach-method
|
||||
Select a file and move it into the task's attachment
|
||||
directory. The file is copied, moved, or linked, depending
|
||||
on ~org-attach-method~. Note that hard links are not
|
||||
supported on all systems.
|
||||
#+kindex: C-c C-a a
|
||||
#+findex: org-attach-attach
|
||||
#+vindex: org-attach-method
|
||||
Select a file and move it into the task's attachment directory.
|
||||
The file is copied, moved, or linked, depending on
|
||||
~org-attach-method~. Note that hard links are not supported on
|
||||
all systems.
|
||||
|
||||
- {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
|
||||
- {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
|
||||
|
||||
#+kindex: C-c C-a c
|
||||
#+kindex: C-c C-a m
|
||||
#+kindex: C-c C-a l
|
||||
Attach a file using the copy/move/link method. Note that
|
||||
hard links are not supported on all systems.
|
||||
#+kindex: C-c C-a c
|
||||
#+kindex: C-c C-a m
|
||||
#+kindex: C-c C-a l
|
||||
Attach a file using the copy/move/link method. Note that hard
|
||||
links are not supported on all systems.
|
||||
|
||||
- {{{kbd(n)}}} (~org-attach-new~) ::
|
||||
- {{{kbd(b)}}} (~org-attach-buffer~) ::
|
||||
|
||||
#+kindex: C-c C-a n
|
||||
#+findex: org-attach-new
|
||||
Create a new attachment as an Emacs buffer.
|
||||
#+kindex: C-c C-a b
|
||||
#+findex: org-attach-buffer
|
||||
Select a buffer and save it as a file in the task's attachment
|
||||
directory.
|
||||
|
||||
- {{{kbd(z)}}} (~org-attach-sync~) ::
|
||||
- {{{kbd(n)}}} (~org-attach-new~) ::
|
||||
|
||||
#+kindex: C-c C-a z
|
||||
#+findex: org-attach-sync
|
||||
Synchronize the current task with its attachment directory, in case
|
||||
you added attachments yourself.
|
||||
#+kindex: C-c C-a n
|
||||
#+findex: org-attach-new
|
||||
Create a new attachment as an Emacs buffer.
|
||||
|
||||
- {{{kbd(o)}}} (~org-attach-open~) ::
|
||||
- {{{kbd(z)}}} (~org-attach-sync~) ::
|
||||
|
||||
#+kindex: C-c C-a o
|
||||
#+findex: org-attach-open
|
||||
#+vindex: org-file-apps
|
||||
Open current task's attachment. If there is more than one,
|
||||
prompt for a file name first. Opening follows the rules set
|
||||
by ~org-file-apps~. For more details, see the information
|
||||
on following hyperlinks (see [[*Handling Links]]).
|
||||
#+kindex: C-c C-a z
|
||||
#+findex: org-attach-sync
|
||||
Synchronize the current task with its attachment directory, in
|
||||
case you added attachments yourself.
|
||||
|
||||
- {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
|
||||
- {{{kbd(o)}}} (~org-attach-open~) ::
|
||||
|
||||
#+kindex: C-c C-a O
|
||||
#+findex: org-attach-open-in-emacs
|
||||
Also open the attachment, but force opening the file in
|
||||
Emacs.
|
||||
#+kindex: C-c C-a o
|
||||
#+findex: org-attach-open
|
||||
#+vindex: org-file-apps
|
||||
Open current task's attachment. If there is more than one,
|
||||
prompt for a file name first. Opening follows the rules set by
|
||||
~org-file-apps~. For more details, see the information on
|
||||
following hyperlinks (see [[*Handling Links]]).
|
||||
|
||||
- {{{kbd(f)}}} (~org-attach-reveal~) ::
|
||||
- {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
|
||||
|
||||
#+kindex: C-c C-a f
|
||||
#+findex: org-attach-reveal
|
||||
Open the current task's attachment directory.
|
||||
#+kindex: C-c C-a O
|
||||
#+findex: org-attach-open-in-emacs
|
||||
Also open the attachment, but force opening the file in Emacs.
|
||||
|
||||
- {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
|
||||
- {{{kbd(f)}}} (~org-attach-reveal~) ::
|
||||
|
||||
#+kindex: C-c C-a F
|
||||
#+findex: org-attach-reveal-in-emacs
|
||||
Also open the directory, but force using Dired in Emacs.
|
||||
#+kindex: C-c C-a f
|
||||
#+findex: org-attach-reveal
|
||||
Open the current task's attachment directory.
|
||||
|
||||
- {{{kbd(d)}}} (~org-attach-delete-one~) ::
|
||||
- {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
|
||||
|
||||
#+kindex: C-c C-a d
|
||||
Select and delete a single attachment.
|
||||
#+kindex: C-c C-a F
|
||||
#+findex: org-attach-reveal-in-emacs
|
||||
Also open the directory, but force using Dired in Emacs.
|
||||
|
||||
- {{{kbd(D)}}} (~org-attach-delete-all~) ::
|
||||
- {{{kbd(d)}}} (~org-attach-delete-one~) ::
|
||||
|
||||
#+kindex: C-c C-a D
|
||||
Delete all of a task's attachments. A safer way is to open
|
||||
the directory in Dired and delete from there.
|
||||
#+kindex: C-c C-a d
|
||||
Select and delete a single attachment.
|
||||
|
||||
- {{{kbd(s)}}} (~org-attach-set-directory~) ::
|
||||
- {{{kbd(D)}}} (~org-attach-delete-all~) ::
|
||||
|
||||
#+kindex: C-c C-a s
|
||||
#+cindex: @samp{ATTACH_DIR}, property
|
||||
Set a specific directory as the entry's attachment
|
||||
directory. This works by putting the directory path into
|
||||
the =ATTACH_DIR= property.
|
||||
#+kindex: C-c C-a D
|
||||
Delete all of a task's attachments. A safer way is to open the
|
||||
directory in Dired and delete from there.
|
||||
|
||||
- {{{kbd(i)}}} (~org-attach-set-inherit~) ::
|
||||
- {{{kbd(s)}}} (~org-attach-set-directory~) ::
|
||||
|
||||
#+kindex: C-c C-a i
|
||||
#+cindex: @samp{ATTACH_DIR_INHERIT}, property
|
||||
Set the =ATTACH_DIR_INHERIT= property, so that children use
|
||||
the same directory for attachments as the parent does.
|
||||
#+kindex: C-c C-a s
|
||||
#+cindex: @samp{ATTACH_DIR}, property
|
||||
Set a specific directory as the entry's attachment directory.
|
||||
This works by putting the directory path into the =ATTACH_DIR=
|
||||
property.
|
||||
|
||||
- {{{kbd(i)}}} (~org-attach-set-inherit~) ::
|
||||
|
||||
#+kindex: C-c C-a i
|
||||
#+cindex: @samp{ATTACH_DIR_INHERIT}, property
|
||||
Set the =ATTACH_DIR_INHERIT= property, so that children use the
|
||||
same directory for attachments as the parent does.
|
||||
|
||||
#+cindex: attach from Dired
|
||||
#+findex: org-attach-dired-to-subtree
|
||||
|
|
|
@ -38,6 +38,10 @@ See [[git:3367ac9457]] for details.
|
|||
** New features
|
||||
*** Babel
|
||||
**** Add LaTeX output support in PlantUML
|
||||
*** Attach buffer contents to headline
|
||||
With =<b>= key from attachment dispatcher (=<C-c C-a>=), it is now
|
||||
possible to write the contents of a buffer to a file in the headline
|
||||
attachement directory.
|
||||
*** iCalendar export respects a =CLASS= property
|
||||
|
||||
Set the =CLASS= property on an entry to specify a visibility class for
|
||||
|
|
|
@ -177,6 +177,7 @@ Shows a list of commands and prompts for another key to execute a command."
|
|||
a Select a file and attach it to the task, using `org-attach-method'.
|
||||
c/m/l/y Attach a file using copy/move/link/symbolic-link method.
|
||||
u Attach a file from URL (downloading it).
|
||||
b Select a buffer and attach its contents to the task.
|
||||
n Create a new attachment, as an Emacs buffer.
|
||||
z Synchronize the current task with its attachment
|
||||
directory, in case you added attachments yourself.
|
||||
|
@ -193,7 +194,7 @@ D Delete all of a task's attachments. A safer way is
|
|||
s Set a specific attachment directory for this entry or reset to default.
|
||||
i Make children of the current entry inherit its attachment directory.")))
|
||||
(org-fit-window-to-buffer (get-buffer-window "*Org Attach*"))
|
||||
(message "Select command: [acmlyunzoOfFdD]")
|
||||
(message "Select command: [acmlyubnzoOfFdD]")
|
||||
(setq c (read-char-exclusive))
|
||||
(and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*"))))
|
||||
(cond
|
||||
|
@ -208,6 +209,7 @@ i Make children of the current entry inherit its attachment directory.")))
|
|||
(let ((org-attach-method 'lns)) (call-interactively 'org-attach-attach)))
|
||||
((memq c '(?u ?\C-u))
|
||||
(let ((org-attach-method 'url)) (call-interactively 'org-attach-url)))
|
||||
((eq c ?b) (call-interactively 'org-attach-buffer))
|
||||
((memq c '(?n ?\C-n)) (call-interactively 'org-attach-new))
|
||||
((memq c '(?z ?\C-z)) (call-interactively 'org-attach-sync))
|
||||
((memq c '(?o ?\C-o)) (call-interactively 'org-attach-open))
|
||||
|
@ -390,6 +392,21 @@ Only do this when `org-attach-store-link-p' is non-nil."
|
|||
(interactive "MURL of the file to attach: \n")
|
||||
(org-attach-attach url))
|
||||
|
||||
(defun org-attach-buffer (buffer-name)
|
||||
"Attach BUFFER-NAME's contents to current task.
|
||||
BUFFER-NAME is a string. Signals a `file-already-exists' error
|
||||
if it would overwrite an existing filename."
|
||||
(interactive "bBuffer whose contents should be attached: ")
|
||||
(let ((output (expand-file-name buffer-name (org-attach-dir t))))
|
||||
(when (file-exists-p output)
|
||||
(signal 'file-already-exists (list "File exists" output)))
|
||||
(when (and org-attach-file-list-property (not org-attach-inherited))
|
||||
(org-entry-add-to-multivalued-property
|
||||
(point) org-attach-file-list-property buffer-name))
|
||||
(org-attach-tag)
|
||||
(with-temp-file output
|
||||
(insert-buffer-substring buffer-name))))
|
||||
|
||||
(defun org-attach-attach (file &optional visit-dir method)
|
||||
"Move/copy/link FILE into the attachment directory of the current task.
|
||||
If VISIT-DIR is non-nil, visit the directory with dired.
|
||||
|
|
Loading…
Reference in New Issue