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 mNNIDw7V414oVwAA0tVLHw (envelope-from ) for ; Fri, 12 Jun 2020 19:18:38 +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 MOvUCg7V417vbgAAB5/wlQ (envelope-from ) for ; Fri, 12 Jun 2020 19:18:38 +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 DCDF59404C5 for ; Fri, 12 Jun 2020 19:18:37 +0000 (UTC) Received: from localhost ([::1]:37214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjpCG-0001MS-No for larch@yhetil.org; Fri, 12 Jun 2020 15:18:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjpBw-0001ME-Hu for emacs-orgmode@gnu.org; Fri, 12 Jun 2020 15:18:16 -0400 Received: from ciao.gmane.io ([159.69.161.202]:58418) by eggs.gnu.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjpBu-000115-Mt for emacs-orgmode@gnu.org; Fri, 12 Jun 2020 15:18:16 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jjpBt-000Xxx-15 for emacs-orgmode@gnu.org; Fri, 12 Jun 2020 21:18:13 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Eric Abrahamsen Subject: [PATCH] Re: Export to attach directory? Date: Fri, 12 Jun 2020 12:18:07 -0700 Message-ID: <87a718m6ts.fsf@ericabrahamsen.net> References: <87o8q18isr.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:Kp4AFpwKTVlHXuSUCZFkcvXJdtw= Received-SPF: pass client-ip=159.69.161.202; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/12 12:10:03 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=ericabrahamsen.net (policy=none); 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.59 X-TUID: RJaKNpwfKJ+J --=-=-= Content-Type: text/plain Eric Abrahamsen writes: > I think the last thing I'm missing before my Org set up is Absolutely > Perfect and never needs to be tweaked again (ha!) is the ability to > export Org files/subtrees to their relevant ATTACH directories, if any. > It might be overkill to have a global setting for this, but I would > love to be able to say: > > * Report #25 :ATTACH: > :PROPERTIES: > :ID: 3da327aa-b51e-444a-ae5c-95bb56d025a9 > :EXPORT_FILE_NAME: report_25 > :EXPORT_TO_ATTACH: t > :END: Nobody seems super excited about this but... I went poking to see how difficult it would be to do this only using hooks and whatnot. It seemed a bit awkward: I can munge the export file name altogether, but there's no good way to say "use whatever file name you would have come up with, but put the resulting file in such-and-such directory". Mostly it's not possible to sneak in and add/alter the PUB-DIR argument to `org-export-output-file-name' -- that argument only seems to be used in the publishing framework. The attached patch to `org-export-output-file-name' has it also check for a EXPORT_PUB_DIR property at the heading level or document level; that would allow libraries like org-attach.el a way to get at exporting via a hook. (Maybe EXPORT_DIRECTORY would be a better name.) Would something along these lines be considered for inclusion? Thanks, Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=export-pub-dir-option.diff 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 --=-=-=--