Re: Help: how to extend org-mode markup?
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 cont...@phfrohring.com Skype: pierre.henry.frohring ‐‐‐ Original Message ‐‐‐ On Friday, September 25, 2020 10:31 AM, Pierre-Henry F. 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 yanta...@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." cont...@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 yanta...@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." cont...@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
Re: Help: how to extend org-mode markup?
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 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." cont...@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 yanta...@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." cont...@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
Re: Help: how to extend org-mode markup?
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 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." 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 >> 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." cont...@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
Re: Help: how to extend org-mode markup?
> 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." 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 > 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." cont...@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
Re: Help: how to extend org-mode markup?
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 > 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." cont...@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
Re: Help: how to extend org-mode markup?
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
Re: Help: how to extend org-mode markup?
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 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." cont...@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
Re: Help: how to extend org-mode markup?
> (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." 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
Re: Help: how to extend org-mode markup?
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