From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Visher Subject: Re: Set heading text from elisp? Date: Wed, 13 Nov 2019 08:25:17 -0500 Message-ID: References: <878sokui3w.fsf@eml.cc> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d87f3c05973a4dc5" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:43900) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUsei-0005wm-Hh for emacs-orgmode@gnu.org; Wed, 13 Nov 2019 08:25:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUseh-0004wS-46 for emacs-orgmode@gnu.org; Wed, 13 Nov 2019 08:25:56 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:42355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUseg-0004w4-TP for emacs-orgmode@gnu.org; Wed, 13 Nov 2019 08:25:55 -0500 Received: by mail-wr1-x434.google.com with SMTP id a15so2344359wrf.9 for ; Wed, 13 Nov 2019 05:25:54 -0800 (PST) In-Reply-To: <878sokui3w.fsf@eml.cc> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Mikhail Skorzhinskii Cc: emacs-orgmode@gnu.org --000000000000d87f3c05973a4dc5 Content-Type: text/plain; charset="UTF-8" Nice! That looks like exactly what I wanted. Not sure how I missed that in my apropos search. I think I may have only searched for `headline` or something. On Wed, Nov 13, 2019 at 7:08 AM Mikhail Skorzhinskii wrote: > 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 > > --000000000000d87f3c05973a4dc5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Nice! That looks like exactly what I wanted. Not sure how = I missed that in my apropos search. I think I may have only searched for `h= eadline` or something.

On Wed, Nov 13, 2019 at 7:08 AM Mikhail Skorzhinskii = <mskorzhinskiy@eml.cc> wrote:

I am not sure if this is exactly what you're asking, but for programati= c 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 ex= ecuted personal helpers I think this is OK.

I&#= 39;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-Headi= ng-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 wo= ndering if there's builtin support for editing components of the headin= g? I'm trying to set the text component (i.e. `(nth 4 (org-heading-comp= onents))`) 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
=C2=A0 (org-back-to-heading t)
=C2=A0 (let (case-fold-= search)
=C2=A0 =C2=A0 (looking-at org-complex-heading-regexp)
=C2=A0 = =C2=A0 (replace-match text t t nil 4)
=C2=A0 =C2=A0 (org-align-tags)))
```

--000000000000d87f3c05973a4dc5--