From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SD+pAXBqkWKQUQAAbAwnHQ (envelope-from ) for ; Sat, 28 May 2022 02:18:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id AKquAXBqkWKMWQEA9RJhRA (envelope-from ) for ; Sat, 28 May 2022 02:18:56 +0200 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 708DB1D68D for ; Sat, 28 May 2022 02:18:55 +0200 (CEST) Received: from localhost ([::1]:44514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nukAP-0007AJ-DF for larch@yhetil.org; Fri, 27 May 2022 20:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuk9y-0007A9-9v for emacs-orgmode@gnu.org; Fri, 27 May 2022 20:18:26 -0400 Received: from mout02.posteo.de ([185.67.36.66]:32791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuk9v-0000o9-RE for emacs-orgmode@gnu.org; Fri, 27 May 2022 20:18:25 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8DBEB240107 for ; Sat, 28 May 2022 02:18:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1653697101; bh=pgcYAvfC0PCcqPQHBYZxG7ofXU2zZ2bg6RapXenNn+o=; h=From:To:Cc:Subject:Date:From; b=r8y+qMXFO+vyHAZlZ2vpbRk1r8A9xYRXZPzDaUpKhvntJW5Kz0RczL08nXAv5XpDm lHRLL9uT1I/RFsz9qT0WV7uUpl/ZUVdJmzdVktWJcGmyDsEVVZsEjcEhuBRy6Nz/a7 ljlKT8oP6YarjX1cfpnIFnOqBk1hW0MYVT5Lz6nE3n34Tn6ExePafqR3n909gMMsAb DUQCrKQ3UYYYN3YwiGr+Xryzx1G02DoJ2nLx8G54ThwfdanKV8qIhPvIO8oNQodOg/ ld940mtUhuR8VIgmSylVA90DZNscfZSbezMen4/H7jM7bEzCERMAEtY0fPAT+jikux Y3CsBQNto4Kgg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4L92MJ4qQnz9rxF; Sat, 28 May 2022 02:18:20 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: Uwe Brauer Cc: orgmode Subject: Re: how to export an org file, to 2 different locations (in to different formats) References: <87r14flzaa.fsf@mat.ucm.es> <87a6b2stoy.fsf@posteo.net> Date: Sat, 28 May 2022 00:18:18 +0000 In-Reply-To: <87a6b2stoy.fsf@posteo.net> ("Juan Manuel =?utf-8?Q?Mac=C3=AD?= =?utf-8?Q?as=22's?= message of "Fri, 27 May 2022 18:42:53 +0000") Message-ID: <87y1ymqzlh.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653697135; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=LszPLHLgn9JyDQnr9TppdRPiJVKTmb/rah8kFp9Mh/8=; b=FBd6RRO6MfewHplpb0AC3AEqk4MSZYa/5IYmIihzJhDt2ZAJv7R5MEUHhUysSsbKBCvfg4 7gwb+wkpgQF102hUuk+gK8CipXOWRYUTY1ZXC16pk0bzsSVAP/v77rl59/EyseCuziVwda sbA9D/9DLiXqMYpMLiSpTkA7X1a6F1a0f7Ya8gzx94NLNt5g3E1IfNGh1NXxdclOvTqvDl 3OtdxqqMCLdmh1I+3vPUya7gieZsqGUQ6mvo57GrnGMqS2xBsl3vxA6+8v3oYQ3WY16qe+ 9k0ezR5K1p48FrWLpzhB2mAReFNY7ME0SG0uCI2gpZZA/51SRfUQ2tgscpTDkg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653697135; a=rsa-sha256; cv=none; b=Yf3eFqu8NlckiXG22BU6uXWRq886ajiTsEub2I4ocGrmQYhsxKjdUvvLPJ7M/9tfHC3mCF fcjd2V+TCrzQchy4eIhMOn2adwKp9zOriewVNB10A0UhwL6HwUsl7sPiSvGBURl90kMfS/ r/6RpczYN9xVkqLXLNcu+goQGvwP0AR2FTsqrf04EvVUY+3hpTvApLjs3GZ5QQc64LpAtU iYpYR9IkzPuIN/YQWXUNTwMbv/exKYD8sfezR0lOLO2vshvnzy5+RaR4Lz1ZTFwe/clCS5 HABShyGw7Wjq8/iAfKKNvEEdrAaITvCzc2V+Fy1nUYQR8Oq5f4XIrNGkRdqMWw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=r8y+qMXF; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.54 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=r8y+qMXF; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 708DB1D68D X-Spam-Score: -5.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2XgWKevZhBdA Juan Manuel Mac=C3=ADas writes: > One (pedestrian) way to achieve it, with this function: I think it can be done better this way, defining an advice around 'org-export-output-file-name'. In your org file you should add these two local variables: # my-latex-export-path: "~/path/to/myfile.tex" # my-html-export-path "~/path/to/myfile.html" And this is the define-advice code. It should export to one or another path= /file every time you export your document to LaTeX or html. I haven't tried it much: (define-advice org-export-output-file-name (:around (old-func extension &re= st args)) (setq old-func (lambda (extension &optional subtreep pub-dir) (let* ((visited-file (buffer-file-name (buffer-base-buffer))) (base-name (concat (file-name-sans-extension (or ;; Check EXPORT_FILE_NAME subtree property. (and subtreep (org-entry-get nil "EXPORT_FILE_NAME" 'selective)) ;; Check #+EXPORT_FILE_NAME keyword. (org-with-point-at (point-min) (catch :found (let ((case-fold-search t)) (while (re-search-forward "^[ \t]*#\\+EXPORT_FILE_NAME:[ \t]+\\S-" nil t) (let ((element (org-element-at-point))) (when (eq 'keyword (org-element-type element)) (throw :found (org-element-property :value element)))))))) ;; Extract from buffer's associated file, if any. (and visited-file (file-name-nondirectory ;; For a .gpg visited file, remove the .gpg extension: (replace-regexp-in-string "\\.gpg\\'" "" visited-file))) ;; Can't determine file name on our own: ask user. (read-file-name "Output file: " pub-dir nil nil nil (lambda (n) (string=3D extension (file-name-extension n t)))))) extension)) (output-file ;; Build file name. Enforce EXTENSION over whatever user ;; may have come up with. PUB-DIR, if defined, always has ;; precedence over any provided path. (cond (pub-dir (concat (file-name-as-directory pub-dir) (file-name-nondirectory base-name))) ((file-name-absolute-p base-name) base-name) (t base-name)))) ;; If writing to OUTPUT-FILE would overwrite original file, append ;; EXTENSION another time to final name. (if (and visited-file (file-equal-p visited-file output-file)) (concat output-file extension) output-file)))) (if (and my-latex-export-path my-html-export-path) (cond ((equal extension ".tex") my-latex-export-path) ((equal extension ".html") my-html-export-path)) (apply old-func args))) Best regards, Juan Manuel=20