summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rose <sebastian_rose@gmx.de>2010-09-16 17:23:37 +0000
committerCarsten Dominik <carsten.dominik@gmail.com>2010-09-16 18:00:59 +0200
commitf2eec6921f758dd107b79624755f57b55c202297 (patch)
tree1c02d801f0349d83f1ec00b78a678d02e2188b0d
parenta1dc916be66500dddbc49ef05bdddc2cbfde84da (diff)
downloadorg-mode-f2eec6921f758dd107b79624755f57b55c202297.tar.gz
Make org-publish-attachment honor directory structure
* lisp/org-publish.el (org-publish-attachment): Put the attachment into the right directory. Aidan Gauland <aidalgol@no8wireless.co.nz> writes: > On Thu, Sep 16, 2010 at 12:40:34AM +0200, Sebastian Rose wrote: >> Aidan Gauland <aidalgol@no8wireless.co.nz> writes: >> > Sebastian Rose <sebastian_rose <at> gmx.de> writes: >> >> It would be a bug. >> >> >> >> But I cannot reproduce it (current Org mode from git, emacs24). >> > >> > I just figured out why: I store all my images in ~/images/ and just >> > have symbolic links to them in my Org website directory. >> > >> > Can you reproduce it now that you have this piece of information? >> >> >> Ah, OK. That might be because of some call to >> >> (file-truename file...) >> >> or similar. `file-truename' removes symbolic links in filenames. >> >> Functions like this are called to make sure, the file is published only >> if needed (i.e. the file has changed since last export). >> >> I'm not sure currently if it's clever to remove such calls (see >> lisp/org-publish.el and search `file-truename'). > > What if `file-truename' was used only to get the path of the actual > file to copy, but the (relative) path of the link is used as the > destination? > > --Aidan Hi Aidan, `org-publish-attachment' is wrong or called with wrong arguments. This patch fixes it. As always, there might be a better way to fix it, but this way the function `org-publish-attachment' will work regardless of parameters. Someone will always call this function with the wrong `PUB-DIR' parameter... Aidan, would like to apply the patch and verify it works for you? Best wishes, Sebastian
-rw-r--r--lisp/org-publish.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index de52410..7534524 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -578,13 +578,18 @@ See `org-publish-org-to' to the list of arguments."
"Publish a file with no transformation of any kind.
See `org-publish-org-to' to the list of arguments."
;; make sure eshell/cp code is loaded
- (unless (file-directory-p pub-dir)
- (make-directory pub-dir t))
- (or (equal (expand-file-name (file-name-directory filename))
- (file-name-as-directory (expand-file-name pub-dir)))
- (copy-file filename
- (expand-file-name (file-name-nondirectory filename) pub-dir)
- t)))
+ (let* ((rel-dir
+ (file-relative-name
+ (file-name-directory filename)
+ (plist-get plist :base-directory)))
+ (pub-dir
+ (expand-file-name
+ (concat (file-name-as-directory pub-dir) rel-dir))))
+ (unless (file-directory-p pub-dir)
+ (make-directory pub-dir t))
+ (or (equal (expand-file-name (file-name-directory filename))
+ (file-name-as-directory (expand-file-name pub-dir)))
+ (copy-file filename pub-dir t))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Publishing files, sets of files, and indices