emacs-humanities
[Top][All Lists]
Advanced

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

Re: [emacs-humanities] highlighting parts of the org file


From: l@tlo
Subject: Re: [emacs-humanities] highlighting parts of the org file
Date: Tue, 13 Jun 2023 16:41:08 +0900


> On Jun 13, 2023, at 15:20, Edgar Vincent <e-v@posteo.net> wrote:
> 
> "l@tlo" <lists@traduction-libre.org> writes:
> 
>> Edgar,
>> 
>> Thank you for the proposition.
>> 
> 
> […]
> 
>>> Hi Jean-Christophe,
>>> 
>>> Perhaps you could try something like this to make the highlighting 
>>> permanent?
>>> 
>>> ┌────
>>> │ ;; Alist of the form '((REGEXP . FACE) …)
>>> │ (setq ev/hi-lock-permanent-keywords
>>> │       '(("@(.+)" . hi-red-b)))
>>> │ 
>>> │ (defun ev/hi-lock-permanent-highlight ()
>>> │   (hi-lock-mode 1)
>>> │   (mapc (lambda (r)
>>> │           (highlight-regexp (car r) (cdr r)))
>>> │         ev/hi-lock-permanent-keywords))
>>> │ 
>>> │ (add-hook 'org-mode-hook 'ev/hi-lock-permanent-highlight)
>>> └────
>> 
>> 
>> What is the difference with:
>> 
>> ;; ajouter une colorisation pour mes notes @ dans le texte
>> (setq font-lock-keyword-org-extra-comments
>>     '(("(@[^)]*)\\|@([^)]+)\\|@[^\s\n\r]+"
>>        (0
>>         '(:background "light yellow"
>>           :foreground "red")
>>         prepend))))
>> 
>> ;; Add this after having required org-mode
>> (font-lock-add-keywords 'org-mode
>>                      font-lock-keyword-org-extra-comments
>>                      t)
>> 
>> (require 'org)
>> 
>> 
>> in terms of mechanism
>> 
>> My understanding is that I'm calling the function when I enter org-mode, 
>> with the hook, so it simulates the permanency by calling the function on 
>> file opening, correct?
> 
> Sorry, I'd missed that snippet that you mentioned earlier. Your
> understanding is correct and your snippet is probably cleaner
> (although both probably work similarly under the bonnet).

The only thing I don't understand in that snippet is why it requires (require 
'org) to work.

-- 
Jean-Christophe Helary @jchelary@emacs.ch
https://traductaire-libre.org
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/




reply via email to

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