emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Set heading text from elisp?


From: Mikhail Skorzhinskii
Subject: Re: Set heading text from elisp?
Date: Wed, 13 Nov 2019 12:25:59 +0100
User-agent: mu4e 1.3.5; emacs 26.3

I am not sure if this is exactly what you're asking, but for programatic heading edits I am using this snippet:

(let ((headline-only-text (org-get-heading t t t t)))
  (org-edit-headline (concat "Web-page: " headline-only-text)))

Probably the better way is to use org element API, but for small, rarely executed personal helpers I think this is OK.

I'm Wondering If There's Builtin Support For Editing Components Of The Heading? I'm Trying To Set The Text Component (I.E. `(Nth 4 (Org-Heading-Components))`) Without Altering Anything Else And While I Can Obviously Achieve This With Generic Elisp I Wanted To Be Sure I Had To.I'm wondering if there's builtin support for editing components of the heading? I'm trying to set the text component (i.e. `(nth 4 (org-heading-components))`) without altering anything else and while I can obviously achieve this with generic elisp I wanted to be sure I had to.


The cleanest elisp I came up with was:

```
(save-excursion
  (org-back-to-heading t)
  (let (case-fold-search)
    (looking-at org-complex-heading-regexp)
    (replace-match text t t nil 4)
    (org-align-tags)))

```

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


reply via email to

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