Mercurial > emacs
annotate lisp/org/org-attach.el @ 99834:296816e24605
(Frame Commands): Mention "minimize" terminology.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 23 Nov 2008 04:21:41 +0000 |
parents | e3acb52d33e1 |
children | 621e15919df0 |
rev | line source |
---|---|
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
1 ;;; org-attach.el --- Manage file attachments to org-mode tasks |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
3 ;; Copyright (C) 2008 Free Software Foundation, Inc. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
4 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
5 ;; Author: John Wiegley <johnw@newartisans.com> |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
6 ;; Keywords: org data task |
99501
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
7 ;; Version: 6.12a |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
8 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
10 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
14 ;; (at your option) any later version. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
15 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
20 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
23 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
24 ;;; Commentary: |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
25 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
26 ;; See the Org-mode manual for information on how to use it. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
27 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
28 ;; Attachments are managed in a special directory called "data", which |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
29 ;; lives in the directory given by `org-directory'. If this data |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
30 ;; directory is initialized as a Git repository, then org-attach will |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
31 ;; automatically commit changes when it sees them. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
32 ;; |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
33 ;; Attachment directories are identified using a UUID generated for the |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
34 ;; task which has the attachments. These are added as property to the |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
35 ;; task when necessary, and should not be deleted or changed by the |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
36 ;; user, ever. UUIDs are generated by a mechanism defined in the variable |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
37 ;; `org-id-method'. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
38 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
39 ;;; Code: |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
40 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
41 (eval-when-compile |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
42 (require 'cl)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
43 (require 'org-id) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
44 (require 'org) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
45 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
46 (defgroup org-attach nil |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
47 "Options concerning entry attachments in Org-mode." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
48 :tag "Org Attach" |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
49 :group 'org) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
50 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
51 (defcustom org-attach-directory "data/" |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
52 "The directory where attachments are stored. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
53 If this is a relative path, it will be interpreted relative to the directory |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
54 where the Org file lives." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
55 :group 'org-attach |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
56 :type 'direcory) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
57 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
58 (defcustom org-attach-auto-tag "ATTACH" |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
59 "Tag that will be triggered automatically when an entry has an attachment." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
60 :group 'org-attach |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
61 :type '(choice |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
62 (const :tag "None" nil) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
63 (string :tag "Tag"))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
64 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
65 (defcustom org-attach-file-list-property "Attachments" |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
66 "The property used to keep a list of attachment belonging to this entry. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
67 This is not really needed, so you may set this to nil if you don't want it." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
68 :group 'org-attach |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
69 :type '(choice |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
70 (const :tag "None" nil) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
71 (string :tag "Tag"))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
72 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
73 (defcustom org-attach-method 'cp |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
74 "The preferred method to attach a file. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
75 Allowed values are: |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
76 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
77 mv rename the file to move it into the attachment directory |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
78 cp copy the file |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
79 ln create a hard link. Note that this is not supported |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
80 on all systems, and then the result is not defined." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
81 :group 'org-attach |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
82 :type '(choice |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
83 (const :tag "Copy" cp) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
84 (const :tag "Move/Rename" mv) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
85 (const :tag "Link" ln))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
86 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
87 (defcustom org-attach-expert nil |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
88 "Non-nil means do not show the splash buffer with the attach dispatcher." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
89 :group 'org-attach |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
90 :type 'boolean) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
91 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
92 ;;;###autoload |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
93 (defun org-attach () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
94 "The dispatcher for attachment commands. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
95 Shows a list of commands and prompts for another key to execute a command." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
96 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
97 (let (c marker) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
98 (when (eq major-mode 'org-agenda-mode) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
99 (setq marker (or (get-text-property (point) 'org-hd-marker) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
100 (get-text-property (point) 'org-marker))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
101 (unless marker |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
102 (error "No task in current line"))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
103 (save-excursion |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
104 (when marker |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
105 (set-buffer (marker-buffer marker)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
106 (goto-char marker)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
107 (org-back-to-heading t) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
108 (save-excursion |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
109 (save-window-excursion |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
110 (unless org-attach-expert |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
111 (with-output-to-temp-buffer "*Org Attach*" |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
112 (princ "Select an Attachment Command: |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
113 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
114 a Select a file and attach it to the task, using `org-attach-method'. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
115 c/m/l Attach a file using copy/move/link method. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
116 n Create a new attachment, as an Emacs buffer. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
117 z Synchronize the current task with its attachment |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
118 directory, in case you added attachments yourself. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
119 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
120 o Open current task's attachments. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
121 O Like \"o\", but force opening in Emacs. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
122 f Open current task's attachment directory. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
123 F Like \"f\", but force using dired in Emacs. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
124 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
125 d Delete one attachment, you will be prompted for a file name. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
126 D Delete all of a task's attachments. A safer way is |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
127 to open the directory in dired and delete from there."))) |
99501
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
128 (org-fit-window-to-buffer (get-buffer-window "*Org Attach*")) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
129 (message "Select command: [acmlzoOfFdD]") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
130 (setq c (read-char-exclusive)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
131 (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*")))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
132 (cond |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
133 ((memq c '(?a ?\C-a)) (call-interactively 'org-attach-attach)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
134 ((memq c '(?c ?\C-c)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
135 (let ((org-attach-method 'cp)) (call-interactively 'org-attach-attach))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
136 ((memq c '(?m ?\C-m)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
137 (let ((org-attach-method 'mv)) (call-interactively 'org-attach-attach))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
138 ((memq c '(?l ?\C-l)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
139 (let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
140 ((memq c '(?n ?\C-n)) (call-interactively 'org-attach-new)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
141 ((memq c '(?z ?\C-z)) (call-interactively 'org-attach-sync)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
142 ((memq c '(?o ?\C-o)) (call-interactively 'org-attach-open)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
143 ((eq c ?O) (call-interactively 'org-attach-open-in-emacs)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
144 ((memq c '(?f ?\C-f)) (call-interactively 'org-attach-reveal)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
145 ((memq c '(?F)) (call-interactively 'org-attach-reveal-in-emacs)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
146 ((memq c '(?d ?\C-d)) (call-interactively |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
147 'org-attach-delete-one)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
148 ((eq c ?D) (call-interactively 'org-attach-delete-all)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
149 ((eq c ?q) (message "Abort")) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
150 (t (error "No such attachment command %c" c)))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
151 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
152 (defun org-attach-dir (&optional create-if-not-exists-p) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
153 "Return the directory associated with the current entry. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
154 If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil, |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
155 the directory and the corresponding ID will be created." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
156 (let ((uuid (org-id-get (point) create-if-not-exists-p))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
157 (when (or uuid create-if-not-exists-p) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
158 (unless uuid |
99501
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
159 (error "ID retrieval/creation failed")) |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
160 (let ((attach-dir (expand-file-name |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
161 (format "%s/%s" |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
162 (substring uuid 0 2) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
163 (substring uuid 2)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
164 (expand-file-name org-attach-directory)))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
165 (if (and create-if-not-exists-p |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
166 (not (file-directory-p attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
167 (make-directory attach-dir t)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
168 (and (file-exists-p attach-dir) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
169 attach-dir))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
170 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
171 (defun org-attach-commit () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
172 "Commit changes to git if `org-attach-directory' is properly initialized. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
173 This checks for the existence of a \".git\" directory in that directory." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
174 (let ((dir (expand-file-name org-attach-directory))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
175 (if (file-exists-p (expand-file-name ".git" dir)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
176 (shell-command |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
177 (concat "(cd " dir "; " |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
178 " git add .; " |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
179 " git ls-files --deleted -z | xargs -0 git rm; " |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
180 " git commit -m 'Synchronized attachments')"))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
181 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
182 (defun org-attach-tag (&optional off) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
183 "Turn the autotag on or (if OFF is set) off." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
184 (when org-attach-auto-tag |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
185 (save-excursion |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
186 (org-back-to-heading t) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
187 (org-toggle-tag org-attach-auto-tag (if off 'off 'on))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
188 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
189 (defun org-attach-untag () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
190 "Turn the autotag off." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
191 (org-attach-tag 'off)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
192 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
193 (defun org-attach-attach (file &optional visit-dir method) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
194 "Move/copy/link FILE into the attachment directory of the current task. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
195 If VISIT-DIR is non-nil, visit the directory with dired. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
196 METHOD may be `cp', `mv', or `ln', default taken from `org-attach-method'." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
197 (interactive "fFile to keep as an attachment: \nP") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
198 (setq method (or method org-attach-method)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
199 (let ((basename (file-name-nondirectory file))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
200 (when org-attach-file-list-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
201 (org-entry-add-to-multivalued-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
202 (point) org-attach-file-list-property basename)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
203 (let* ((attach-dir (org-attach-dir t)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
204 (fname (expand-file-name basename attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
205 (cond |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
206 ((eq method 'mv) (rename-file file fname)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
207 ((eq method 'cp) (copy-file file fname)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
208 ((eq method 'ln) (add-name-to-file file fname))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
209 (org-attach-commit) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
210 (org-attach-tag) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
211 (if visit-dir |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
212 (dired attach-dir) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
213 (message "File \"%s\" is now a task attachment." basename))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
214 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
215 (defun org-attach-attach-cp () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
216 "Attach a file by copying it." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
217 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
218 (let ((org-attach-method 'cp)) (call-interactively 'org-attach-attach))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
219 (defun org-attach-attach-mv () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
220 "Attach a file by moving (renaming) it." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
221 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
222 (let ((org-attach-method 'mv)) (call-interactively 'org-attach-attach))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
223 (defun org-attach-attach-ln () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
224 "Attach a file by creating a hard link to it. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
225 Beware that this does not work on systems that do not support hard links. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
226 On some systems, this apparently does copy the file instead." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
227 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
228 (let ((org-attach-method 'ln)) (call-interactively 'org-attach-attach))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
229 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
230 (defun org-attach-new (file) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
231 "Create a new attachment FILE for the current task. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
232 The attachment is created as an Emacs buffer." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
233 (interactive "sCreate attachment named: ") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
234 (when org-attach-file-list-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
235 (org-entry-add-to-multivalued-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
236 (point) org-attach-file-list-property file)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
237 (let ((attach-dir (org-attach-dir t))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
238 (org-attach-tag) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
239 (find-file (expand-file-name file attach-dir)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
240 (message "New attachment %s" file))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
241 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
242 (defun org-attach-delete-one (&optional file) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
243 "Delete a single attachment." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
244 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
245 (let* ((attach-dir (org-attach-dir t)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
246 (files (org-attach-file-list attach-dir)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
247 (file (or file |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
248 (completing-read |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
249 "Delete attachment: " |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
250 (mapcar (lambda (f) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
251 (list (file-name-nondirectory f))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
252 files))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
253 (setq file (expand-file-name file attach-dir)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
254 (unless (file-exists-p file) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
255 (error "No such attachment: %s" file)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
256 (delete-file file))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
257 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
258 (defun org-attach-delete-all (&optional force) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
259 "Delete all attachments from the current task. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
260 This actually deletes the entire attachment directory. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
261 A safer way is to open the directory in dired and delete from there." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
262 (interactive "P") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
263 (when org-attach-file-list-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
264 (org-entry-delete (point) org-attach-file-list-property)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
265 (let ((attach-dir (org-attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
266 (when |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
267 (and attach-dir |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
268 (or force |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
269 (y-or-n-p "Are you sure you want to remove all attachments of this entry? "))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
270 (shell-command (format "rm -fr %s" attach-dir)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
271 (message "Attachment directory removed") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
272 (org-attach-commit) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
273 (org-attach-untag)))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
274 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
275 (defun org-attach-sync () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
276 "Synchronize the current tasks with its attachments. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
277 This can be used after files have been added externally." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
278 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
279 (org-attach-commit) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
280 (when org-attach-file-list-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
281 (org-entry-delete (point) org-attach-file-list-property)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
282 (let ((attach-dir (org-attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
283 (when attach-dir |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
284 (let ((files (org-attach-file-list attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
285 (and files (org-attach-tag)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
286 (when org-attach-file-list-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
287 (dolist (file files) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
288 (unless (string-match "^\\." file) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
289 (org-entry-add-to-multivalued-property |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
290 (point) org-attach-file-list-property file)))))))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
291 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
292 (defun org-attach-file-list (dir) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
293 "Return a list of files in the attachment directory. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
294 This ignores files starting with a \".\", and files ending in \"~\"." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
295 (delq nil |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
296 (mapcar (lambda (x) (if (string-match "^\\." x) nil x)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
297 (directory-files dir nil "[^~]\\'")))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
298 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
299 (defun org-attach-reveal () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
300 "Show the attachment directory of the current task in dired." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
301 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
302 (let ((attach-dir (org-attach-dir t))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
303 (org-open-file attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
304 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
305 (defun org-attach-reveal-in-emacs () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
306 "Show the attachment directory of the current task. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
307 This will attempt to use an external program to show the directory." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
308 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
309 (let ((attach-dir (org-attach-dir t))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
310 (dired attach-dir))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
311 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
312 (defun org-attach-open (&optional in-emacs) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
313 "Open an attachment of the current task. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
314 If there are more than one attachment, you will be prompted for the file name. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
315 This command will open the file using the settings in `org-file-apps' |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
316 and in the system-specific variants of this variable. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
317 If IN-EMACS is non-nil, force opening in Emacs." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
318 (interactive "P") |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
319 (let* ((attach-dir (org-attach-dir t)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
320 (files (org-attach-file-list attach-dir)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
321 (file (if (= (length files) 1) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
322 (car files) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
323 (completing-read "Open attachment: " |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
324 (mapcar 'list files) nil t)))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
325 (org-open-file (expand-file-name file attach-dir) in-emacs))) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
326 |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
327 (defun org-attach-open-in-emacs () |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
328 "Open attachment, force opening in Emacs. |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
329 See `org-attach-open'." |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
330 (interactive) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
331 (org-attach-open 'in-emacs)) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
332 |
99501
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
333 (defun org-attach-expand (file) |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
334 "Return the full path to the current entry's attachment file FILE. |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
335 Basically, this adds the path to the attachment directory." |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
336 (expand-file-name file (org-attach-dir))) |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
337 |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
338 (defun org-attach-expand-link (file) |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
339 "Return a file link pointing to the current entry's attachment file FILE. |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
340 Basically, this adds the path to the attachment directory, and a \"file:\" |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
341 prefix." |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
342 (concat "file:" (org-attach-expand file))) |
e3acb52d33e1
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
99139
diff
changeset
|
343 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
344 (provide 'org-attach) |
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
345 |
98696 | 346 ;; arch-tag: fce93c2e-fe07-4fa3-a905-e10dcc7a6248 |
98645
8339497a5b87
New files org-attach.el, org-list.el, org-plot.el.
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
347 ;;; org-attach.el ends here |