emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Uwe Brauer <oub@mat.ucm.es>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: how to export an org file, to 2 different locations (in to different formats)
Date: Sat, 28 May 2022 07:23:13 +0000	[thread overview]
Message-ID: <87h75a2k9q.fsf@posteo.net> (raw)
In-Reply-To: <87h75a5fl4.fsf@mat.ucm.es> (Uwe Brauer's message of "Sat, 28 May 2022 08:36:07 +0200")

Uwe Brauer writes:

> When I run it I obtain 
> if: Symbol’s value as variable is void: my-latex-export-path
>
> Another point is if I decide to export it to ods, I need to modify that
> advice, but I agree the new function is more convenient.

You must add the variables to the document as local variables, at the
end of the document, like this:

# Local Variables:
# my-latex-export-path: "~/path/myfile.tex"
# my-html-export-path: "~/path/myfile.html"
# End:

But (it's important, I didn't tell you, sorry) before you must globally
define the variables with nil value, so that you don't get an error in
other documents:

(setq my-latex-export-path nil
      my-html-export-path nil)

With this 'define-advice' procedure you don't need the other code I gave
you. You can export in the usual way, using the dispatcher. The only
difference is that in any document where these variables exist, the
resulting file will be saved in the directory/name specified in the
variables, depending on whether you export to latex or html.

To add more cases, like odt, simply:

(1) you define a new variable:

  (setq my-latex-export-path nil
	my-html-export-path nil
	my-odt-export-path nil)

and locally:

# Local Variables:
# my-latex-export-path: "~/path/myfile.tex"
# my-html-export-path: "~/path/myfile.html"
# my-odt-export-path: "~/path/myfile.html"
# End:

(2) And you add a new condition at the end of the define-advice:

[...]
(if (and my-latex-export-path
	     my-html-export-path
	     my-odt-export-path)
	(cond ((equal extension ".tex")
	       my-latex-export-path)
	      ((equal extension ".html")
	       my-html-export-path)
	      ((equal extension ".odt")
	       my-odt-export-path))
      (apply old-func args)))

It means that: if those variables exist, it returns as a result the
path/name that you have specified for each case. Otherwise, the
org-export-output-file-name function is executed normally.

Best regards,

Juan Manuel 


  reply	other threads:[~2022-05-28  7:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 16:23 how to export an org file, to 2 different locations (in to different formats) Uwe Brauer
2022-05-27 18:42 ` Juan Manuel Macías
2022-05-28  0:18   ` Juan Manuel Macías
2022-05-28  6:36     ` Uwe Brauer
2022-05-28  7:23       ` Juan Manuel Macías [this message]
2022-05-28  8:40         ` Uwe Brauer
2022-05-28  9:06           ` Juan Manuel Macías
2022-05-29 11:44           ` Ihor Radchenko
2022-05-28  6:21   ` Uwe Brauer
2022-05-28  6:47   ` [ODT?] (was: how to export an org file, to 2 different locations (in to different formats)) Uwe Brauer
2022-05-31 15:10 ` how to export an org file, to 2 different locations (in to different formats) Nick Dokos

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=87h75a2k9q.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=oub@mat.ucm.es \
    /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).