[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatically use Heading Content as EXPORT_FILE_NAME?

From: Samuel Wales
Subject: Re: Automatically use Heading Content as EXPORT_FILE_NAME?
Date: Tue, 26 Apr 2022 19:27:55 -0700

fwiw, what i do is export to a buffer, then write to a file whose name
is derived from the header.

                        (with-current-buffer org-buffer
(org-get-heading 'no-tags 'no-todo)))

(defun alpha-make-valid-path (s)
  "Make a string into a filesystem path."
  ;; see files.el for this and tramp
  (subst-char-in-string ?/ ?!
                         (replace-regexp-in-string "!" "!!" s)))

i think it might have some issues with long headers and some basename
limit on linux.  you seem to truncate for that.

On 4/26/22, Tim Visher <tim.visher@gmail.com> wrote:
> On Tue, Apr 26, 2022 at 11:54 AM Tim Visher <tim.visher@gmail.com> wrote:
>> I'm currently going to hack around it I think by simply making a function
>> that updates the EXPORT_FILE_NAME property with the current heading text.
> That's something like
> ```
> (defun timvisher-org-set-export_file_name-property-to-heading-text
>     ()
>   (interactive)
>   (org-set-property
>    (let ((stripped-heading
>           (replace-regexp-in-string
>            "[^-A-Za-z0-9_.~#+ ]"
>            ""
>            (substring-no-properties (org-get-heading t t t t)))))
>      (substring-no-properties
>       stripped-heading
>       0
>       (min (length stripped-heading) 250)))))
> ```

The Kafka Pandemic

A blog about science, health, human rights, and misopathy:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]