emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Nick Dokos <ndokos@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: setting export_file_name during export
Date: Tue, 10 Jan 2023 20:01:13 +0000	[thread overview]
Message-ID: <87fscinoqf.fsf@t14.reltub.ca> (raw)
In-Reply-To: <87tu0ynxr0.fsf@alphaville.usersys.redhat.com> (Nick Dokos's message of "Tue, 10 Jan 2023 11:46:27 -0500")

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

      reply	other threads:[~2023-01-10 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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=87fscinoqf.fsf@t14.reltub.ca \
    --to=leo.butler@umanitoba.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@gmail.com \
    /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).