Re: setting export_file_name during export

2023-01-10 Thread Leo Butler
On Tue, Jan 10 2023, Nick Dokos  wrote:

> Leo Butler  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

Re: setting export_file_name during export

2023-01-10 Thread Nick Dokos
Leo Butler  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





Re: setting export_file_name during export

2023-01-06 Thread Alain . Cochard
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.coch...@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 ]




Re: setting export_file_name during export

2023-01-06 Thread Leo Butler
On Fri, Jan 06 2023, alain.coch...@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 


Re: setting export_file_name during export

2023-01-06 Thread Alain . Cochard
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.coch...@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 ]




setting export_file_name during export

2023-01-06 Thread Leo Butler
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

#+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=.