emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Wales <samologist@gmail.com>
To: Tim Visher <tim.visher@gmail.com>
Cc: Emacs Org Mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Automatically use Heading Content as EXPORT_FILE_NAME?
Date: Tue, 26 Apr 2022 19:27:55 -0700	[thread overview]
Message-ID: <CAJcAo8tYFW38AYr4Tcyp2YhY7v3g45g96ZYgWYKw5J3L7Y854Q@mail.gmail.com> (raw)
In-Reply-To: <CAHa53uzr+qOZETL0gk1Mu+LO6fufHyKbsjOZpwacrgkFy9CFbA@mail.gmail.com>

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

(alpha-make-valid-path
                        (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
>    "EXPORT_FILE_NAME"
>    (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:
https://thekafkapandemic.blogspot.com


      reply	other threads:[~2022-04-27  2:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 15:54 Automatically use Heading Content as EXPORT_FILE_NAME? Tim Visher
2022-04-26 16:24 ` Tim Visher
2022-04-27  2:27   ` Samuel Wales [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=CAJcAo8tYFW38AYr4Tcyp2YhY7v3g45g96ZYgWYKw5J3L7Y854Q@mail.gmail.com \
    --to=samologist@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tim.visher@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).