emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>,
	Rodrigo Morales <moralesrodrigo1100@gmail.com>
Subject: Re: Virtually prefix headlines according to content
Date: Tue, 29 Jun 2021 09:53:12 -0400	[thread overview]
Message-ID: <CAJ51ETrroBy4KxxjMmG=3YNDDj5pifOH+LTbgLiJ=9O7gdXCUw@mail.gmail.com> (raw)
In-Reply-To: <87bl7okd53.fsf@posteo.net>

[-- Attachment #1: Type: text/plain, Size: 1815 bytes --]

you could use this alternative to just change the display without adding
the tag:

(org-map-entries (lambda ()
  (looking-at org-heading-regexp)
  (put-text-property (match-beginning 2) (match-end 2) 'display (concat "GH
" (match-string 2))))
                 "+GITHUB={.+}")

There might be some clever way to tie that onto fontlock, or some kind of
hook to make it also work for entries as you create them.
John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Tue, Jun 29, 2021 at 9:35 AM Juan Manuel Macías <maciaschain@posteo.net>
wrote:

> Rodrigo Morales writes:
>
> > What I would like to know is whether it is possible to format a headline
> > by taking into consideration the properties it has. For example, in this
> > specific scenario, I would like to make all headlines that have a
> > "GITHUB" to show "GH" before the actual headline (the content would look
> > like this).
>
> You can define a function with `org-map-entries' that adds (for example) a
> tag :github: to all headers with the property GITHUB:
>
> #+begin_src emacs-lisp
>   (defun add-github-tag ()
>     (interactive)
>     (org-map-entries (lambda ()
>                        (save-restriction
>                          (save-excursion
>                            (org-narrow-to-subtree)
>                            (goto-char (point-min))
>                            (end-of-line)
>                            (insert "  :github:"))))
>                      "+GITHUB={.+}"))
>
> (add-hook 'org-mode-hook #'add-github-tag)
> #+end_src
>
> Best regards,
>
> Juan Manuel
>
>
>

[-- Attachment #2: Type: text/html, Size: 2679 bytes --]

  reply	other threads:[~2021-06-29 13:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29 11:25 Virtually prefix headlines according to content Rodrigo Morales
2021-06-29 12:52 ` Eric S Fraga
2021-06-29 13:26 ` indieterminacy
2021-06-29 13:34 ` Juan Manuel Macías
2021-06-29 13:53   ` John Kitchin [this message]
2021-06-29 20:44     ` Samuel Wales

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='CAJ51ETrroBy4KxxjMmG=3YNDDj5pifOH+LTbgLiJ=9O7gdXCUw@mail.gmail.com' \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    --cc=moralesrodrigo1100@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).