emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Loris Bennett <loris.bennett@fu-berlin.de>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: File local setting for export directory?
Date: Tue, 04 Aug 2020 10:04:15 -0700	[thread overview]
Message-ID: <87zh7az6k0.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87pn873p1e.fsf@hornfels.zedat.fu-berlin.de> (Loris Bennett's message of "Tue, 4 Aug 2020 08:25:13 +0200")

Loris Bennett <loris.bennett@fu-berlin.de> writes:

> Hi Eric,
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> "Loris Bennett" <loris.bennett@fu-berlin.de> writes:
>>
>>> Hi,
>>>
>>> I want to export an org file to a pdf and have the pdf created in
>>> subdirectory relative to the org file.
>>>
>>> What's the simplest way to set the export directory in a file local way?
>>
>> I suggested the attached diff a while ago, but no one seemed very
>> interested. I think it might already do what you want.
>>
>>
>> diff --git a/lisp/ox.el b/lisp/ox.el
>> index 9cf62078a..77cafb20d 100644
>> --- a/lisp/ox.el
>> +++ b/lisp/ox.el
>> @@ -6417,6 +6417,20 @@ Return file name as a string."
>>  	      "Output file: " pub-dir nil nil nil
>>  	      (lambda (n) (string= extension (file-name-extension n t))))))
>>  	   extension))
>> +	 (pub-dir (or pub-dir
>> +		      (and subtreep (org-entry-get
>> +				     nil "EXPORT_PUB_DIR" 'selective))
>> +		      (org-with-point-at (point-min)
>> +			(catch :found
>> +			  (let ((case-fold-search t))
>> +			    (while (re-search-forward
>> +				    "^[ \t]*#\\+EXPORT_PUB_DIR:[ \t]+\\S-"
>> +				    nil t)
>> +			      (let ((element (org-element-at-point)))
>> +				(when (eq 'keyword (org-element-type element))
>> +				  (throw :found
>> +					 (org-element-property
>> +					  :value element))))))))))
>>  	 (output-file
>>  	  ;; Build file name.  Enforce EXTENSION over whatever user
>>  	  ;; may have come up with.  PUB-DIR, if defined, always has
>>
>
> Thanks for the patch - it is exactly what I needed.
>
> I'm surprised no-one was interested, although I suppose back then I was
> probably also one of the uninterested :-)

Oh I'm not blaming anyone! There are a lot of patches coming down here,
and a lot of ideas for Org, and it's hard to keep up. I don't think I
did a very good job of stating my case, either.

I actually hadn't thought of how the latex process might go haywire with
an absolute export file name. My motivation was simply that "next to my
*.org" files is pretty much never where I want exported files to end up.
I want to send them to ~/tmp, or to a directory that's shared with
colleagues via syncthing. In fact what I really want is to export to the
value of ATTACH_DIR, because then I can immediately use all the attach
tools on the exported files.

Latex compilation is a nice additional argument, though!

Eric


  parent reply	other threads:[~2020-08-04 17:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 14:15 File local setting for export directory? Loris Bennett
2020-08-03 15:12 ` Russell Adams
2020-08-04  1:29   ` Nick Dokos
2020-08-03 23:15 ` Eric Abrahamsen
2020-08-04  6:25   ` Loris Bennett
2020-08-04 10:54     ` Russell Adams
2020-08-04 11:42       ` Loris Bennett
2020-08-04 11:58         ` Russell Adams
2020-08-04 12:15     ` Russell Adams
2020-08-04 14:06       ` Loris Bennett
2020-08-04 17:04     ` Eric Abrahamsen [this message]
2020-09-01  7:15       ` Loris Bennett
2021-07-09 14:12         ` Loris Bennett

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=87zh7az6k0.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=loris.bennett@fu-berlin.de \
    /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).