* Virtually prefix headlines according to content
@ 2021-06-29 11:25 Rodrigo Morales
2021-06-29 12:52 ` Eric S Fraga
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Rodrigo Morales @ 2021-06-29 11:25 UTC (permalink / raw)
To: emacs-orgmode
* The context
When taking notes in Org Mode, I usually store Github links of the
repositories that are relevant to the topic I'm taking notes as
headlines. For this reason, I've multiple headlines of the form within
my notes (from my notes on Graph Theory):
#+BEGIN_SRC org
* cytoscape/cytoscape.js: Library for visualisation and analysis
:PROPERTIES:
:GITHUB: cytoscape/cytoscape.js
:END:
* simongray/clojure-graph-resources: List of Clojure resources
:PROPERTIES:
:GITHUB: simongray/clojure-graph-resources
:END:
* DONE What is an undirected graph? ...
* DONE What is a directed graph? ...
#+END_SRC
* The question
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).
#+BEGIN_SRC org
* GH cytoscape/cytoscape.js: Library for visualisation and analysis ...
* GH simongray/clojure-graph-resources: List of Clojure resources ...
* TODO What is an undirected graph? ...
* TODO What is a directed graph? ...
#+END_SRC
The reason why I'm asking this is because thus when collapsing
headlines, I would know that an specific headline is a Github
repository. In general terms, to ease the readibility of my Org Mode
file.
* Additional context
A similar behavior is provided by org-num-mode (built-in function), so I
guess that some way to accomplish this would be to look at the
implementation of that mode and try to understand how that is
accomplished.
Any help is appreciated,
Rodrigo Morales.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Virtually prefix headlines according to content
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
2 siblings, 0 replies; 6+ messages in thread
From: Eric S Fraga @ 2021-06-29 12:52 UTC (permalink / raw)
To: Rodrigo Morales; +Cc: emacs-orgmode
On Tuesday, 29 Jun 2021 at 06:25, Rodrigo Morales wrote:
> 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).
I don't think there is anything specifically designed to do what you
want. However, you could modify how you enter these headlines: maybe
define an org capture rule for this purpose (e.g. a github rule) that
automatically adds the GH to the headline.
Another alternative is to use column view to show all your headlines
with the specific property as one of the columns. This is what I do for
certain org files where headlines have a number of different properties
(e.g. my bibliography file).
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-571-gc591be
: Latest paper written in org: https://arxiv.org/abs/2106.05096
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Virtually prefix headlines according to content
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
2 siblings, 0 replies; 6+ messages in thread
From: indieterminacy @ 2021-06-29 13:26 UTC (permalink / raw)
To: Rodrigo Morales, emacs-orgmode
Hi Rodrigo,
regarding syntax, it would be cool if you aligned the style to match Emacs' Hyperboles GitHub style:
=> https://github.com/rswgnu/hyperbole/blob/master/DEMO
```
** Github (Remote) References
For software developers who use Github for publishing and version control,
Github links are similar to social media links but reference specific Github
web pages.
Press the Action Key on github@rswgnu to go to RSW's gihub home page.
gh@rswgnu works too.
References to project home pages look like this (the / is required):
github#/hyperbole (uses user default setting)
github#/rswgnu/hyperbole
References to specific commits use the # hash symbol and short versions
of the git commit hash code:
gh#rswgnu/hyperbole/5ae3550 (if include user, must include project)
github#hyperbole/5ae3550 (project can be given with user default)
gh#5ae3550 (user and project defaults are used)
An Action Key press on the first commit reference above works because
user, project and commit hash code are all included. The second and
third versions require the setup of default values, as explained in
the commentary near the top of "hib-social.el".
Similarly, the same file above explains how to link to pull requests,
issues, branches and tags.
```
FYI, Hyperbole has been making improvements with regards to utility with Orgmode.
It may be worth you looking into how that functionality is implemented.
Kind regards,
Jonathan McHugh
June 29, 2021 1:27 PM, "Rodrigo Morales" <moralesrodrigo1100@gmail.com> wrote:
> * The context
>
> When taking notes in Org Mode, I usually store Github links of the
> repositories that are relevant to the topic I'm taking notes as
> headlines. For this reason, I've multiple headlines of the form within
> my notes (from my notes on Graph Theory):
>
> #+BEGIN_SRC org
> * cytoscape/cytoscape.js: Library for visualisation and analysis
> :PROPERTIES:
> :GITHUB: cytoscape/cytoscape.js
> :END:
>
> * simongray/clojure-graph-resources: List of Clojure resources
> :PROPERTIES:
> :GITHUB: simongray/clojure-graph-resources
> :END:
>
> * DONE What is an undirected graph? ...
> * DONE What is a directed graph? ...
> #+END_SRC
>
> * The question
>
> 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).
>
> #+BEGIN_SRC org
> * GH cytoscape/cytoscape.js: Library for visualisation and analysis ...
> * GH simongray/clojure-graph-resources: List of Clojure resources ...
> * TODO What is an undirected graph? ...
> * TODO What is a directed graph? ...
> #+END_SRC
>
> The reason why I'm asking this is because thus when collapsing
> headlines, I would know that an specific headline is a Github
> repository. In general terms, to ease the readibility of my Org Mode
> file.
>
> * Additional context
>
> A similar behavior is provided by org-num-mode (built-in function), so I
> guess that some way to accomplish this would be to look at the
> implementation of that mode and try to understand how that is
> accomplished.
>
> Any help is appreciated,
> Rodrigo Morales.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Virtually prefix headlines according to content
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
2 siblings, 1 reply; 6+ messages in thread
From: Juan Manuel Macías @ 2021-06-29 13:34 UTC (permalink / raw)
To: Rodrigo Morales; +Cc: orgmode
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Virtually prefix headlines according to content
2021-06-29 13:34 ` Juan Manuel Macías
@ 2021-06-29 13:53 ` John Kitchin
2021-06-29 20:44 ` Samuel Wales
0 siblings, 1 reply; 6+ messages in thread
From: John Kitchin @ 2021-06-29 13:53 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: orgmode, Rodrigo Morales
[-- 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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Virtually prefix headlines according to content
2021-06-29 13:53 ` John Kitchin
@ 2021-06-29 20:44 ` Samuel Wales
0 siblings, 0 replies; 6+ messages in thread
From: Samuel Wales @ 2021-06-29 20:44 UTC (permalink / raw)
To: John Kitchin; +Cc: Juan Manuel Macías, Rodrigo Morales, orgmode
along similar lines one possibility is to stick a symbol into the
stars. similar code could also indicate that scheduled and deadline.
On 6/29/21, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> 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
>>
>>
>>
>
--
The Kafka Pandemic
Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-29 20:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2021-06-29 20:44 ` Samuel Wales
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).