From: Florian Lindner <mailinglists@xgm.de>
To: emacs-orgmode@gnu.org
Subject: Re: Moving and resetting attachments
Date: Thu, 1 Jun 2017 13:20:17 +0200 [thread overview]
Message-ID: <ogot9c$aqj$1@blaine.gmane.org> (raw)
In-Reply-To: <874lw05njr.fsf@ericabrahamsen.net>
Am 01.06.2017 um 06:39 schrieb Eric Abrahamsen:
> Florian Lindner <mailinglists@xgm.de> writes:
>
>> Hello,
>>
>> two questions about moving attachments to org files:
>>
>> C-c C-a a attaches a file and stores it under ./data/ID/...
>>
>> Using C-c C-a s I can set another directory a attachment directory.
>> Can I make org-mode move the content of the previous
>> directory to the new directory?
>>
>> Can I "reset" the attachment directory, i.e. like C-c C-a s but
>> :ATTACH_DIR: is deleted and the contents of the previous
>> directory are moved to ./data/ID?
>>
>> Rationale:
>>
>> I use org mode as a document management system. Create an entry Papers -> Interpolation -> ECCOMAS. I know create an
>> custom attachment directory ECCOMAS, next to the org file as long as I
>> am working on that paper. When it's finished, I
>> want to move the contents of the ECCOMAS attachment directory to ./data/ID/.
>
> It doesn't work this way now, but I think it makes sense, and I would
> also find that helpful. `org-attach-set-directory' could be changed to
> check for existing files, and offer to move them. There's no
> `org-attach-unset-directory', but I suppose there could be.
Hey,
I hacked together some lines of lisp that should achieve that. It's my first non-trivial (from my point of trivialness)
piece of code. I'm open for any suggestions:
(defun flo/org-attach-move ()
(interactive)
(when (org-attach-dir)
(let ((target (read-string "Move attachments to: ")) ; read-directory-name here?
(attach-dir (org-attach-dir)))
(if (string= target "")
(progn
(org-entry-delete nil "ATTACH_DIR")
(setq target (org-attach-dir t)))
(progn
(org-entry-put nil "ATTACH_DIR" target)
(make-directory target t))
)
(unless (string= target attach-dir)
(copy-directory attach-dir target t nil t)
(message "Deleting %s" attach-dir)
;; (shell-command "rm -rf %s" attach-dir)
)
)
)
)
Best,
Florian
next prev parent reply other threads:[~2017-06-01 11:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 12:29 Moving and resetting attachments Florian Lindner
2017-06-01 4:39 ` Eric Abrahamsen
2017-06-01 11:20 ` Florian Lindner [this message]
2017-06-02 9:19 ` Eric Abrahamsen
2017-06-02 9:51 ` Nicolas Goaziou
2017-06-02 12:34 ` Eric Abrahamsen
2017-06-02 14:34 ` Nicolas Goaziou
2017-06-02 16:51 ` Eric Abrahamsen
2017-06-04 7:59 ` Nicolas Goaziou
2017-06-04 23:25 ` Eric Abrahamsen
2017-06-06 13:56 ` Florian Lindner
2017-06-07 7:52 ` Florian Lindner
2017-06-10 7:36 ` Nicolas Goaziou
2017-06-13 8:49 ` Florian Lindner
2017-06-13 21:41 ` Nicolas Goaziou
2017-06-20 18:12 ` Florian Lindner
2017-06-24 8:53 ` Nicolas Goaziou
2017-06-28 14:57 ` Florian Lindner
2017-06-13 8:53 ` Florian Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='ogot9c$aqj$1@blaine.gmane.org' \
--to=mailinglists@xgm.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).