all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* setting export_file_name during export
@ 2023-01-06 21:38 Leo Butler
  2023-01-06 22:15 ` Alain.Cochard
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Butler @ 2023-01-06 21:38 UTC (permalink / raw)
  To: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

Hello,

I am trying something new this semester: all my lecture notes are
organized into a single org file. A minor problem: I want to export each
lecture (see below) as a separate pdf file. I would like to know if
anyone has ``solved'' this problem or has a suggestion on how to do it.

Ideally, I would like to have a single function that retains only the
current subtree that contains point, sets EXPORT_FILE_NAME based on the
top heading, and exports it as a complete beamer pdf.

TIA,
Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: example.org --]
[-- Type: text/x-org; name="lectures.org", Size: 376 bytes --]

#+AUTHOR: Leo Butler
#+TITLE: Lectures in Math
#+OPTIONS: H:2 toc:t num:t
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [presentation]
#+STARTUP: beamer
#+EXPORT_FILE_NAME: lectures

* Lecture 1
** Lecture 1
In the beginning...This subtree should be exported to =lecture-1.pdf=.
* Lecture 2
** Lecture 2
Next...This subtree should be exported to =lecture-2.pdf=.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: setting export_file_name during export
  2023-01-06 21:38 setting export_file_name during export Leo Butler
@ 2023-01-06 22:15 ` Alain.Cochard
  2023-01-06 22:52   ` Leo Butler
  0 siblings, 1 reply; 6+ messages in thread
From: Alain.Cochard @ 2023-01-06 22:15 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode Mailing List

Leo Butler writes on Fri  6 Jan 2023 21:38:
 > Hello,
 > 
 > I am trying something new this semester: all my lecture notes are
 > organized into a single org file. A minor problem: I want to export each
 > lecture (see below) as a separate pdf file. I would like to know if
 > anyone has ``solved'' this problem or has a suggestion on how to do it.
 > 
 > Ideally, I would like to have a single function that retains only the
 > current subtree that contains point, sets EXPORT_FILE_NAME based on the
 > top heading, and exports it as a complete beamer pdf.

Hi.  Sorry if you already know this and want something more automated
it is not too clear to me.  (What is not clear either is why you have
'* Lecture 1' _and_ '** Lecture 1', etc., i.e., why not just
'* Lecture 1'.)

So: if you insert 

  :PROPERTIES:
  :EXPORT_FILE_NAME: lecture-1.pdf
  :END:

right after '** Lecture 1' and, with the point inside that subtree,
do:

  C-c C-e C-s l O

it seems to me it does the job.

 > #+AUTHOR: Leo Butler
 > #+TITLE: Lectures in Math
 > #+OPTIONS: H:2 toc:t num:t
 > #+LATEX_CLASS: beamer
 > #+LATEX_CLASS_OPTIONS: [presentation]
 > #+STARTUP: beamer
 > #+EXPORT_FILE_NAME: lectures
 > 
 > * Lecture 1
 > ** Lecture 1
 > In the beginning...This subtree should be exported to =lecture-1.pdf=.
 > * Lecture 2
 > ** Lecture 2
 > Next...This subtree should be exported to =lecture-2.pdf=.

-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 110]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France     | [ slot available for rent ]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: setting export_file_name during export
  2023-01-06 22:15 ` Alain.Cochard
@ 2023-01-06 22:52   ` Leo Butler
  2023-01-06 23:03     ` Alain.Cochard
  2023-01-10 16:46     ` Nick Dokos
  0 siblings, 2 replies; 6+ messages in thread
From: Leo Butler @ 2023-01-06 22:52 UTC (permalink / raw)
  To: Alain.Cochard@unistra.fr; +Cc: Org Mode Mailing List

On Fri, Jan 06 2023, Alain.Cochard@unistra.fr wrote:

> Leo Butler writes on Fri  6 Jan 2023 21:38:
>  > Hello,
>  > 
>  > I am trying something new this semester: all my lecture notes are
>  > organized into a single org file. A minor problem: I want to export each
>  > lecture (see below) as a separate pdf file. I would like to know if
>  > anyone has ``solved'' this problem or has a suggestion on how to do it.
>  > 
>  > Ideally, I would like to have a single function that retains only the
>  > current subtree that contains point, sets EXPORT_FILE_NAME based on the
>  > top heading, and exports it as a complete beamer pdf.
>
> Hi.  Sorry if you already know this and want something more automated
> it is not too clear to me.  (What is not clear either is why you have
> '* Lecture 1' _and_ '** Lecture 1', etc., i.e., why not just
> '* Lecture 1'.)

For my setup, each heading is a separate lecture, each subheading is a
separate beamer slide, etc.

>
> So: if you insert 
>
>   :PROPERTIES:
>   :EXPORT_FILE_NAME: lecture-1.pdf
>   :END:
>

Aha! Thank you very much. I had forgotten about using property
drawers. It would be a simple matter to create a filter to insert that
property drawer under the heading that contains point.

> right after '** Lecture 1' and, with the point inside that subtree,
> do:
>
>   C-c C-e C-s l O
>
> it seems to me it does the job.

Yes, it does! Thanks again.

Leo

>
>  > #+AUTHOR: Leo Butler
>  > #+TITLE: Lectures in Math
>  > #+OPTIONS: H:2 toc:t num:t
>  > #+LATEX_CLASS: beamer
>  > #+LATEX_CLASS_OPTIONS: [presentation]
>  > #+STARTUP: beamer
>  > #+EXPORT_FILE_NAME: lectures
>  > 
>  > * Lecture 1
>  > ** Lecture 1
>  > In the beginning...This subtree should be exported to =lecture-1.pdf=.
>  > * Lecture 2
>  > ** Lecture 2
>  > Next...This subtree should be exported to =lecture-2.pdf=.


*and* that I needed to 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: setting export_file_name during export
  2023-01-06 22:52   ` Leo Butler
@ 2023-01-06 23:03     ` Alain.Cochard
  2023-01-10 16:46     ` Nick Dokos
  1 sibling, 0 replies; 6+ messages in thread
From: Alain.Cochard @ 2023-01-06 23:03 UTC (permalink / raw)
  To: Leo Butler; +Cc: Alain.Cochard@unistra.fr, Org Mode Mailing List

Leo Butler writes on Fri  6 Jan 2023 22:52:

 > It would be a simple matter to create a filter to insert that
 > property drawer under the heading that contains point.

Well, feel free to enlighten me: I don't have any idea of even
how/where to start, but often face similar challen... err, simple
matters :-)

-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 110]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France     | [ slot available for rent ]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: setting export_file_name during export
  2023-01-06 22:52   ` Leo Butler
  2023-01-06 23:03     ` Alain.Cochard
@ 2023-01-10 16:46     ` Nick Dokos
  2023-01-10 20:01       ` Leo Butler
  1 sibling, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2023-01-10 16:46 UTC (permalink / raw)
  To: emacs-orgmode

Leo Butler <Leo.Butler@umanitoba.ca> writes:

>>
>> So: if you insert 
>>
>>   :PROPERTIES:
>>   :EXPORT_FILE_NAME: lecture-1.pdf
>>   :END:
>>
>
> Aha! Thank you very much. I had forgotten about using property
> drawers. It would be a simple matter to create a filter to insert that
> property drawer under the heading that contains point.
>

IIUC, you really don't need to insert things dynamically: you can add
an appropriate property drawer after every top-level heading once and
for all.

-- 
Nick




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: setting export_file_name during export
  2023-01-10 16:46     ` Nick Dokos
@ 2023-01-10 20:01       ` Leo Butler
  0 siblings, 0 replies; 6+ messages in thread
From: Leo Butler @ 2023-01-10 20:01 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode@gnu.org

On Tue, Jan 10 2023, Nick Dokos <ndokos@gmail.com> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>>>
>>> So: if you insert 
>>>
>>>   :PROPERTIES:
>>>   :EXPORT_FILE_NAME: lecture-1.pdf
>>>   :END:
>>>
>>
>> Aha! Thank you very much. I had forgotten about using property
>> drawers. It would be a simple matter to create a filter to insert that
>> property drawer under the heading that contains point.
>>
>
> IIUC, you really don't need to insert things dynamically: you can add
> an appropriate property drawer after every top-level heading once and
> for all.

Yes, you are correct. And, in fact, the naïve way to insert the property
dynamically (using ~org-export-before-processing-hook~) does not work:

#+name: does-not-work
#+begin_src emacs-lisp :exports none
  (defun ltb-org-insert-export-file-name (backend)
    (save-excursion
      (goto-char (point-min))
      (while (search-forward-regexp "^[*] Lecture \\([0-9]+\\)" nil t)
	(forward-line 1)
	(let ((num (match-string 1)))
	  (unless (looking-at "^:PROPERTIES:")
	    (let ((pty (format ":PROPERTIES:\n:EXPORT_FILE_NAME: lecture-%s.pdf\n:END:\n" num)))
	      (insert pty)
	      (message (buffer-substring-no-properties (point-min) (point-max)))))))))
  (add-hook 'org-export-before-processing-hook 'ltb-org-insert-export-file-name)
#+end_src

The property drawer is ignored, presumably because org has already
scanned the file and determined the filename. I guess one would need to
reach inside the document structure and alter the filename there, but I
don't have that knowledge.

Suggestions are welcome.

Leo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-10 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-06 21:38 setting export_file_name during export Leo Butler
2023-01-06 22:15 ` Alain.Cochard
2023-01-06 22:52   ` Leo Butler
2023-01-06 23:03     ` Alain.Cochard
2023-01-10 16:46     ` Nick Dokos
2023-01-10 20:01       ` Leo Butler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.