Priority cookies are always in a headline.

The attached patch speeds up fontification of a 1k lines buffer by 0.1
second.

Note that the variable org-priority-regexp can't be modified since
it is used in the agenda and in org-get-priority.

Regards,

--
Sébastien Miquel
>From a348a3834b79608a20bfd4e28815ae3995c7eb5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miq...@posteo.eu>
Date: Fri, 26 Feb 2021 18:02:32 +0100
Subject: [PATCH] org.el (org-font-lock-add-priority-faces): Speed up regexp

* org.el (org-font-lock-add-priority-faces): Speed up regexp.

Only fontify priority cookies in headlines.

TINYCHANGE
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 00596564f..8c976213d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5855,7 +5855,7 @@ If TAG is a number, get the corresponding match group."
 
 (defun org-font-lock-add-priority-faces (limit)
   "Add the special priority faces."
-  (while (re-search-forward org-priority-regexp limit t)
+  (while (re-search-forward (concat "^\\*+" org-priority-regexp) limit t)
     (let ((beg (match-beginning 1))
 	  (end (1+ (match-end 2))))
       (add-face-text-property
-- 
2.30.1

Reply via email to