At $dayjob I take notes using org-mode and from time to time end up sharing these as exported PDF's or HTML files. When I export a subtree these notes end up overwriting the same file over and over again, the file
workbook-2021.pdf when using i.e.
C-c C-e C-s l p. I would like to have subtrees export to a file named
Using code shared by Melioratus on the Emacs Stack Exchange I was able to write a function that finds the current headline and removes non-alphanumeric characters.
(defun headline-title() (let* ((headline (save-mark-and-excursion (outline-previous-heading) (org-element-property :title (org-element-at-point))))) (replace-regexp-in-string "[^[:alnum:]-_]" "-" headline)))
I then want for this string to be appended to the filename of the current org-file when exporting the subtree. So given the following file named
export-subtree.org and that the cursor is standing under the heading of "Works of wizards" then the file name would be
* Week 1 ** 2021-01-01 *** Concerning Hobbits A word or two about their lore. *** Works of wizards Many more about wandering| wizards.
But this is where my Emacs foo comes short. I really don't know where to start. Because I do not want to be adding a property to every headline I want to export with a different name as many other answers on this network suggests.