From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eDSaDjEgVV/zDQAA0tVLHw (envelope-from ) for ; Sun, 06 Sep 2020 17:45:21 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id eG1qCjEgVV8JYAAAB5/wlQ (envelope-from ) for ; Sun, 06 Sep 2020 17:45:21 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B12509401D0 for ; Sun, 6 Sep 2020 17:45:20 +0000 (UTC) Received: from localhost ([::1]:36870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEyj9-0006Yr-NJ for larch@yhetil.org; Sun, 06 Sep 2020 13:45:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEyia-0006HN-Pt for emacs-orgmode@gnu.org; Sun, 06 Sep 2020 13:44:44 -0400 Received: from ericabrahamsen.net ([52.70.2.18]:44632 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEyiY-0007oN-Lb; Sun, 06 Sep 2020 13:44:44 -0400 Received: from localhost (c-73-254-86-141.hsd1.wa.comcast.net [73.254.86.141]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 20E97103014; Sun, 6 Sep 2020 17:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1599414275; bh=p5pKKJilsMgnBPglKtkxB013qZ6M1wlQUo8DT/SB0BE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=n5/xa2VPvP81vtwREejkqnAw7WrWWICr4Y1ffmjf9knV0iw4zjHCUR5V39Bq5e7+R 715UbvOApt2wopjGHsFzSFmHPY6DLOtlqBCdkzIv2pAwZzO7vtPKZNFJ6FvUCiaSYt x5yXtf8hQX2as0HXkcfHpm+z5d3+gnU1DH1OgmnY= From: Eric Abrahamsen To: Bastien Subject: Re: [PATCH] Re: Export to attach directory? References: <87o8q18isr.fsf@ericabrahamsen.net> <87a718m6ts.fsf@ericabrahamsen.net> <87363w8y7g.fsf@gnu.org> Date: Sun, 06 Sep 2020 10:44:33 -0700 In-Reply-To: <87363w8y7g.fsf@gnu.org> (Bastien's message of "Sat, 05 Sep 2020 09:44:19 +0200") Message-ID: <877dt6u7em.fsf@ericabrahamsen.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/06 13:44:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=ericabrahamsen.net header.s=mail header.b=n5/xa2VP; dmarc=pass (policy=none) header.from=ericabrahamsen.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: X6SZxa7RzJuO --=-=-= Content-Type: text/plain Bastien writes: > Hi Eric, > > sorry for the late reply -- I don't use attachments that much > but I see how this could be useful once correctly advertized and > documented. > > Eric Abrahamsen writes: > >> Would something along these lines be considered for inclusion? > > Yes, sure, for after 9.4 -- please go ahead with a proper patch. How does this look? It occurred to me that having a global `org-export-directory' option would be a good thing -- it makes sense to me that a user might want all their exported files put in one place -- but in the interest of one-thing-at-a-time I didn't do that. This additional property doesn't actually have anything to do with org-attach. I'd originally thought that, with this option, I could write an export filter that would check for: :EXPORT_DIRECTORY: and replace it to point at whatever the attach dir was/should be for that heading. If that's something that many users would like to have, we could look at adding it in org-attach.el. But in the meantime, the attached patch makes it possible to do it yourself. Thanks, Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-EXPORT_DIRECTORY-property.patch >From 0e80a6ed7ad955259c4e11ea74ed249696ba9b46 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 6 Sep 2020 10:36:34 -0700 Subject: [PATCH] Add EXPORT_DIRECTORY property * lisp/ox.el (org-export-output-file-name): Check for this property and place the exported output file there. * doc/org-manual.org: Document. --- doc/org-manual.org | 8 +++++++- lisp/ox.el | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 46498bd22..6f256a569 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -11479,7 +11479,7 @@ global variables, include: - =CREATOR= :: #+cindex: @samp{CREATOR}, keyword - #+vindex: org-expot-creator-string + #+vindex: org-export-creator-string Entity responsible for output generation (~org-export-creator-string~). @@ -11539,6 +11539,12 @@ global variables, include: generates the file name based on the buffer name and the extension based on the back-end format. +- =EXPORT_DIRECTORY= :: + + #+cindex: @samp{EXPORT_DIRECTORY}, keyword + An alternate directory in which to place the output file. + Otherwise, output files are placed alongside the original Org file. + The =OPTIONS= keyword is a compact form. To configure multiple options, use several =OPTIONS= lines. =OPTIONS= recognizes the following arguments. diff --git a/lisp/ox.el b/lisp/ox.el index 9852cfd21..2d2c1ddb0 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -6428,6 +6428,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_DIRECTORY" 'selective)) + (org-with-point-at (point-min) + (catch :found + (let ((case-fold-search t)) + (while (re-search-forward + "^[ \t]*#\\+EXPORT_DIRECTORY:[ \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 -- 2.28.0 --=-=-=--