emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Orgmode plain list bullet : change automatically with list depth


From: Edouard Debry
Subject: Re: Orgmode plain list bullet : change automatically with list depth
Date: Sun, 19 Jun 2022 16:49:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (windows-nt)

Thanks for your information complement. Indeed, I know too few about
emacs to guess that by myself.

And it works !

For anyone interested, here are the settings :

(font-lock-add-keywords 'org-mode
                        '(("^ *\\([-]\\) "
                           (0 (let* ((depth (org-list--depth (save-match-data 
(org-element-at-point))))
                                     (bullet (cond ((= depth 1) "●")
                                                   ((= depth 2) "◆")
                                                   ((= depth 3) "▪")
                                                   ((= depth 4) "▸")
                                                   ((= depth 5) "•")
                                                   ((= depth 6) "↪")
                                                   (t "↪"))))
                                (prog1 () (compose-region (match-beginning 1) 
(match-end 1) bullet)))))))

Many thanks for your help.

Regards

Ihor Radchenko <yantar92@gmail.com> writes:

> Edouard Debry <edouard.debry@gmail.com> writes:
>
>> The key point is the regexp. I do not know if it is possible to capture
>> the depth level with a regexp. That is why I tried to use
>> org-list--depth in :
>>
>> ...
>> but it seems that "org-element-at-point" messes things.
>
> Sorry, I though that I gave you enough information to fix the issue.
>
> Just wrap (org-element-at-point) into save-match-data:
> (save-match-data (org-element-at-point))
>
> That's it.
>
> P.S. I actually plan to fix `org-element-at-point' modifying match data
> (which is not documented), but it will probably be a part of a bigger
> font-lock-related patchset.
>
> Best,
> Ihor



reply via email to

[Prev in Thread] Current Thread [Next in Thread]