emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Help: how to extend org-mode markup?
@ 2020-09-25  6:51 Pierre-Henry F.
  2020-09-25  7:24 ` Christian Moe
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Pierre-Henry F. @ 2020-09-25  6:51 UTC (permalink / raw)
  To: emacs-orgmode\@gnu.org

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

Hello,

I would like to extend the org-mode markup.

For example, I would like to change the face of a keyword, say: :next: .

Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.

I tried this:

(defun org-add-my-extra-markup ()
(add-to-list 'org-font-lock-extra-keywords
'("[^\\w]\\(:next:\\)[^\\w]"
(1 font-lock-warning-face t))))

(add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)

But it does not work.

So: how to extend org-mode markup?

Many thanks,
PHF

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  6:51 Help: how to extend org-mode markup? Pierre-Henry F.
@ 2020-09-25  7:24 ` Christian Moe
  2020-09-25  7:26 ` Ihor Radchenko
  2020-09-25  7:55 ` Eric S Fraga
  2 siblings, 0 replies; 10+ messages in thread
From: Christian Moe @ 2020-09-25  7:24 UTC (permalink / raw)
  To: Pierre-Henry F.; +Cc: emacs-orgmode@gnu.org


Hello,

In your example, `:next:' is a tag. Tags and keywords are different
entities.
https://orgmode.org/worg/dev/org-syntax.html

You should be able to do what you want by customizing `org-tag-faces'.

Yours,
Christian 

Pierre-Henry F. writes:

> Hello,
>
> I would like to extend the org-mode markup.
>
> For example, I would like to change the face of a keyword, say: :next: .
>
> Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
>
> I tried this:
>
> (defun org-add-my-extra-markup ()
> (add-to-list 'org-font-lock-extra-keywords
> '("[^\\w]\\(:next:\\)[^\\w]"
> (1 font-lock-warning-face t))))
>
> (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
>
> But it does not work.
>
> So: how to extend org-mode markup?
>
> Many thanks,
> PHF


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  6:51 Help: how to extend org-mode markup? Pierre-Henry F.
  2020-09-25  7:24 ` Christian Moe
@ 2020-09-25  7:26 ` Ihor Radchenko
  2020-09-25  7:38   ` Pierre-Henry F.
  2020-09-25  7:55 ` Eric S Fraga
  2 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2020-09-25  7:26 UTC (permalink / raw)
  To: Pierre-Henry F., emacs-orgmode\@gnu.org

> (add-to-list 'org-font-lock-extra-keywords

It is internal variable. You should not use it.

Simply use font-lock-add-keywords instead.

Best,
Ihor

"Pierre-Henry F." <contact@phfrohring.com> writes:

> Hello,
>
> I would like to extend the org-mode markup.
>
> For example, I would like to change the face of a keyword, say: :next: .
>
> Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
>
> I tried this:
>
> (defun org-add-my-extra-markup ()
> (add-to-list 'org-font-lock-extra-keywords
> '("[^\\w]\\(:next:\\)[^\\w]"
> (1 font-lock-warning-face t))))
>
> (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
>
> But it does not work.
>
> So: how to extend org-mode markup?
>
> Many thanks,
> PHF


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  7:26 ` Ihor Radchenko
@ 2020-09-25  7:38   ` Pierre-Henry F.
  2020-09-25  8:07     ` Christian Moe
  2020-09-25  8:13     ` Ihor Radchenko
  0 siblings, 2 replies; 10+ messages in thread
From: Pierre-Henry F. @ 2020-09-25  7:38 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode\\@gnu.org

Thank you very much for your replies.

Here is the use case:

|-----------+--------|
| something | :next: |
|-----------+--------|

I would like :next: to show up using an arbitrary face.


As suggested by Ihor, I tried:

(font-lock-add-keywords 'org-mode
  '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))

in my init.el

It does not work either.


@Christian yes, it's the same syntax as tags, I would like to extend it eventually.


Thanks,
PHF

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, September 25, 2020 9:26 AM, Ihor Radchenko <yantar92@gmail.com> wrote:

> > (add-to-list 'org-font-lock-extra-keywords
>
> It is internal variable. You should not use it.
>
> Simply use font-lock-add-keywords instead.
>
> Best,
> Ihor
>
> "Pierre-Henry F." contact@phfrohring.com writes:
>
> > Hello,
> > I would like to extend the org-mode markup.
> > For example, I would like to change the face of a keyword, say: :next: .
> > Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
> > I tried this:
> > (defun org-add-my-extra-markup ()
> > (add-to-list 'org-font-lock-extra-keywords
> > '("[^\\w]\\(:next:\\)[^\\w]"
> > (1 font-lock-warning-face t))))
> > (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
> > But it does not work.
> > So: how to extend org-mode markup?
> > Many thanks,
> > PHF




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  6:51 Help: how to extend org-mode markup? Pierre-Henry F.
  2020-09-25  7:24 ` Christian Moe
  2020-09-25  7:26 ` Ihor Radchenko
@ 2020-09-25  7:55 ` Eric S Fraga
  2 siblings, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2020-09-25  7:55 UTC (permalink / raw)
  To: Pierre-Henry F.; +Cc: emacs-orgmode@gnu.org

One alternative, that I use for specific org files, is
~hi-lock-mode~.  Based on regular expressions, you can highlight any
bits you want without affecting the underlying org font lock settings.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-29-gbc9664


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  7:38   ` Pierre-Henry F.
@ 2020-09-25  8:07     ` Christian Moe
  2020-09-25  8:13     ` Ihor Radchenko
  1 sibling, 0 replies; 10+ messages in thread
From: Christian Moe @ 2020-09-25  8:07 UTC (permalink / raw)
  To: Pierre-Henry F.; +Cc: emacs-orgmode\@gnu.org


Please disregard my response. I misunderstood both your intention and
the use of font-lock keywords. Sorry for the noise. :-(

Yours,
Christian

Pierre-Henry F. writes:

> Thank you very much for your replies.
>
> Here is the use case:
>
> |-----------+--------|
> | something | :next: |
> |-----------+--------|
>
> I would like :next: to show up using an arbitrary face.
>
>
> As suggested by Ihor, I tried:
>
> (font-lock-add-keywords 'org-mode
>   '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
>
> in my init.el
>
> It does not work either.
>
>
> @Christian yes, it's the same syntax as tags, I would like to extend it eventually.
>
>
> Thanks,
> PHF
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Friday, September 25, 2020 9:26 AM, Ihor Radchenko <yantar92@gmail.com> wrote:
>
>> > (add-to-list 'org-font-lock-extra-keywords
>>
>> It is internal variable. You should not use it.
>>
>> Simply use font-lock-add-keywords instead.
>>
>> Best,
>> Ihor
>>
>> "Pierre-Henry F." contact@phfrohring.com writes:
>>
>> > Hello,
>> > I would like to extend the org-mode markup.
>> > For example, I would like to change the face of a keyword, say: :next: .
>> > Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
>> > I tried this:
>> > (defun org-add-my-extra-markup ()
>> > (add-to-list 'org-font-lock-extra-keywords
>> > '("[^\\w]\\(:next:\\)[^\\w]"
>> > (1 font-lock-warning-face t))))
>> > (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
>> > But it does not work.
>> > So: how to extend org-mode markup?
>> > Many thanks,
>> > PHF


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  7:38   ` Pierre-Henry F.
  2020-09-25  8:07     ` Christian Moe
@ 2020-09-25  8:13     ` Ihor Radchenko
  2020-09-25  8:14       ` Ihor Radchenko
  2020-09-25  8:31       ` Pierre-Henry F.
  1 sibling, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2020-09-25  8:13 UTC (permalink / raw)
  To: Pierre-Henry F.; +Cc: emacs-orgmode\\@gnu.org

> As suggested by Ihor, I tried:
>
> (font-lock-add-keywords 'org-mode
>   '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))

You need to fontify it _after_ all other org-mode font settings:

(font-lock-add-keywords 'org-mode
  '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend) 'append))

Best,
Ihor


"Pierre-Henry F." <contact@phfrohring.com> writes:

> Thank you very much for your replies.
>
> Here is the use case:
>
> |-----------+--------|
> | something | :next: |
> |-----------+--------|
>
> I would like :next: to show up using an arbitrary face.
>
>
> As suggested by Ihor, I tried:
>
> (font-lock-add-keywords 'org-mode
>   '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
>
> in my init.el
>
> It does not work either.
>
>
> @Christian yes, it's the same syntax as tags, I would like to extend it eventually.
>
>
> Thanks,
> PHF
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Friday, September 25, 2020 9:26 AM, Ihor Radchenko <yantar92@gmail.com> wrote:
>
>> > (add-to-list 'org-font-lock-extra-keywords
>>
>> It is internal variable. You should not use it.
>>
>> Simply use font-lock-add-keywords instead.
>>
>> Best,
>> Ihor
>>
>> "Pierre-Henry F." contact@phfrohring.com writes:
>>
>> > Hello,
>> > I would like to extend the org-mode markup.
>> > For example, I would like to change the face of a keyword, say: :next: .
>> > Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
>> > I tried this:
>> > (defun org-add-my-extra-markup ()
>> > (add-to-list 'org-font-lock-extra-keywords
>> > '("[^\\w]\\(:next:\\)[^\\w]"
>> > (1 font-lock-warning-face t))))
>> > (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
>> > But it does not work.
>> > So: how to extend org-mode markup?
>> > Many thanks,
>> > PHF


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  8:13     ` Ihor Radchenko
@ 2020-09-25  8:14       ` Ihor Radchenko
  2020-09-25  8:31       ` Pierre-Henry F.
  1 sibling, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2020-09-25  8:14 UTC (permalink / raw)
  To: Pierre-Henry F.; +Cc: emacs-orgmode\\@gnu.org


Sorry, misplaced the argument. 'append should be the last argument to
font-lock-add-keywords:

(font-lock-add-keywords 'org-mode
  '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)) 'append)


Ihor Radchenko <yantar92@gmail.com> writes:

>> As suggested by Ihor, I tried:
>>
>> (font-lock-add-keywords 'org-mode
>>   '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
>
> You need to fontify it _after_ all other org-mode font settings:
>
> (font-lock-add-keywords 'org-mode
>   '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend) 'append))
>
> Best,
> Ihor
>
>
> "Pierre-Henry F." <contact@phfrohring.com> writes:
>
>> Thank you very much for your replies.
>>
>> Here is the use case:
>>
>> |-----------+--------|
>> | something | :next: |
>> |-----------+--------|
>>
>> I would like :next: to show up using an arbitrary face.
>>
>>
>> As suggested by Ihor, I tried:
>>
>> (font-lock-add-keywords 'org-mode
>>   '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
>>
>> in my init.el
>>
>> It does not work either.
>>
>>
>> @Christian yes, it's the same syntax as tags, I would like to extend it eventually.
>>
>>
>> Thanks,
>> PHF
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Friday, September 25, 2020 9:26 AM, Ihor Radchenko <yantar92@gmail.com> wrote:
>>
>>> > (add-to-list 'org-font-lock-extra-keywords
>>>
>>> It is internal variable. You should not use it.
>>>
>>> Simply use font-lock-add-keywords instead.
>>>
>>> Best,
>>> Ihor
>>>
>>> "Pierre-Henry F." contact@phfrohring.com writes:
>>>
>>> > Hello,
>>> > I would like to extend the org-mode markup.
>>> > For example, I would like to change the face of a keyword, say: :next: .
>>> > Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
>>> > I tried this:
>>> > (defun org-add-my-extra-markup ()
>>> > (add-to-list 'org-font-lock-extra-keywords
>>> > '("[^\\w]\\(:next:\\)[^\\w]"
>>> > (1 font-lock-warning-face t))))
>>> > (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
>>> > But it does not work.
>>> > So: how to extend org-mode markup?
>>> > Many thanks,
>>> > PHF


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  8:13     ` Ihor Radchenko
  2020-09-25  8:14       ` Ihor Radchenko
@ 2020-09-25  8:31       ` Pierre-Henry F.
  2020-09-25  9:52         ` Pierre-Henry F.
  1 sibling, 1 reply; 10+ messages in thread
From: Pierre-Henry F. @ 2020-09-25  8:31 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode\\\\@gnu.org

Thank you Ihor,

It does work... too good now :-)

all the other faces are gone

Well, OK...

I will check that an other time.

Thank you all for your replies !

PHF

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, September 25, 2020 10:13 AM, Ihor Radchenko <yantar92@gmail.com> wrote:

> > As suggested by Ihor, I tried:
>
> > (font-lock-add-keywords 'org-mode
> > '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
>
> You need to fontify itafter all other org-mode font settings:
>
> (font-lock-add-keywords 'org-mode
> '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend) 'append))
>
> Best,
> Ihor
>
> "Pierre-Henry F." contact@phfrohring.com writes:
>
> > Thank you very much for your replies.
> > Here is the use case:
> > |-----------+--------|
> > | something | :next: |
> > |-----------+--------|
> > I would like :next: to show up using an arbitrary face.
> > As suggested by Ihor, I tried:
> > (font-lock-add-keywords 'org-mode
> > '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
> > in my init.el
> > It does not work either.
> > @Christian yes, it's the same syntax as tags, I would like to extend it eventually.
> > Thanks,
> > PHF
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > On Friday, September 25, 2020 9:26 AM, Ihor Radchenko yantar92@gmail.com wrote:
> >
> > > > (add-to-list 'org-font-lock-extra-keywords
> > >
> > > It is internal variable. You should not use it.
> > > Simply use font-lock-add-keywords instead.
> > > Best,
> > > Ihor
> > > "Pierre-Henry F." contact@phfrohring.com writes:
> > >
> > > > Hello,
> > > > I would like to extend the org-mode markup.
> > > > For example, I would like to change the face of a keyword, say: :next: .
> > > > Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
> > > > I tried this:
> > > > (defun org-add-my-extra-markup ()
> > > > (add-to-list 'org-font-lock-extra-keywords
> > > > '("[^\\w]\\(:next:\\)[^\\w]"
> > > > (1 font-lock-warning-face t))))
> > > > (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
> > > > But it does not work.
> > > > So: how to extend org-mode markup?
> > > > Many thanks,
> > > > PHF




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Help: how to extend org-mode markup?
  2020-09-25  8:31       ` Pierre-Henry F.
@ 2020-09-25  9:52         ` Pierre-Henry F.
  0 siblings, 0 replies; 10+ messages in thread
From: Pierre-Henry F. @ 2020-09-25  9:52 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode\\\\@gnu.org

Well, this works!
Thank you all!

    (defun user-custom-keywords ()
      ;; M-x list-faces-display
      (let ((user-custom-keywords
              '((":next:" . 'org-habit-clear-face)
                 (":wait:" . 'org-habit-alert-face)
                 (":failed:" . 'org-habit-overdue-face)
                 (":success:" . 'org-habit-ready-face)
                 (":unscheduled:" . 'avy-lead-face-0))))

        (dolist (elt user-custom-keywords)
          (let ((regex (car elt))
                 (face (cdr elt)))
            (font-lock-add-keywords
              nil
              `((,regex 0 ,face t))
              'append)))))


Cordialement,
Pierre-Henry FRÖHRING
+33 6 34 48 17 57
contact@phfrohring.com
Skype: pierre.henry.frohring

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, September 25, 2020 10:31 AM, Pierre-Henry F. <contact@phfrohring.com> wrote:

> Thank you Ihor,
>
> It does work... too good now :-)
>
> all the other faces are gone
>
> Well, OK...
>
> I will check that an other time.
>
> Thank you all for your replies !
>
> PHF
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Friday, September 25, 2020 10:13 AM, Ihor Radchenko yantar92@gmail.com wrote:
>
> > > As suggested by Ihor, I tried:
> >
> > > (font-lock-add-keywords 'org-mode
> > > '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
> >
> > You need to fontify itafter all other org-mode font settings:
> > (font-lock-add-keywords 'org-mode
> > '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend) 'append))
> > Best,
> > Ihor
> > "Pierre-Henry F." contact@phfrohring.com writes:
> >
> > > Thank you very much for your replies.
> > > Here is the use case:
> > > |-----------+--------|
> > > | something | :next: |
> > > |-----------+--------|
> > > I would like :next: to show up using an arbitrary face.
> > > As suggested by Ihor, I tried:
> > > (font-lock-add-keywords 'org-mode
> > > '(("\\W\\(:next:\\)\\W" 1 font-lock-warning-face prepend)))
> > > in my init.el
> > > It does not work either.
> > > @Christian yes, it's the same syntax as tags, I would like to extend it eventually.
> > > Thanks,
> > > PHF
> > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > > On Friday, September 25, 2020 9:26 AM, Ihor Radchenko yantar92@gmail.com wrote:
> > >
> > > > > (add-to-list 'org-font-lock-extra-keywords
> > > >
> > > > It is internal variable. You should not use it.
> > > > Simply use font-lock-add-keywords instead.
> > > > Best,
> > > > Ihor
> > > > "Pierre-Henry F." contact@phfrohring.com writes:
> > > >
> > > > > Hello,
> > > > > I would like to extend the org-mode markup.
> > > > > For example, I would like to change the face of a keyword, say: :next: .
> > > > > Whenever :next: is displayed from an org-mode buffer, it should show up in using an arbitrary face.
> > > > > I tried this:
> > > > > (defun org-add-my-extra-markup ()
> > > > > (add-to-list 'org-font-lock-extra-keywords
> > > > > '("[^\\w]\\(:next:\\)[^\\w]"
> > > > > (1 font-lock-warning-face t))))
> > > > > (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
> > > > > But it does not work.
> > > > > So: how to extend org-mode markup?
> > > > > Many thanks,
> > > > > PHF




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-09-25  9:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25  6:51 Help: how to extend org-mode markup? Pierre-Henry F.
2020-09-25  7:24 ` Christian Moe
2020-09-25  7:26 ` Ihor Radchenko
2020-09-25  7:38   ` Pierre-Henry F.
2020-09-25  8:07     ` Christian Moe
2020-09-25  8:13     ` Ihor Radchenko
2020-09-25  8:14       ` Ihor Radchenko
2020-09-25  8:31       ` Pierre-Henry F.
2020-09-25  9:52         ` Pierre-Henry F.
2020-09-25  7:55 ` Eric S Fraga

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).