emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: emacs-orgmode@gnu.org
Cc: Ihor Radchenko <yantar92@gmail.com>
Subject: [PATCH] ~org-font-lock-add-priority-faces~: ensure priority cookies are in a headline
Date: Fri, 26 Feb 2021 20:58:35 +0100	[thread overview]
Message-ID: <a9f0fc01-2f32-8831-ac8b-0f0fe9e00a4d@posteo.eu> (raw)
In-Reply-To: <b8d7a477-2b68-acbf-806a-9e5c650a2ad7@posteo.eu>

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

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

[-- Attachment #2: 0001-org.el-org-font-lock-add-priority-faces-Speed-up-reg.patch --]
[-- Type: text/x-patch, Size: 966 bytes --]

From a348a3834b79608a20bfd4e28815ae3995c7eb5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@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	other threads:[~2021-02-26 20:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 18:24 Typing latency Sébastien Miquel
2021-02-09  2:16 ` Russell Adams
2021-02-09 14:06   ` Sébastien Miquel
2021-02-09  3:23 ` Ihor Radchenko
2021-02-09 14:56   ` Sébastien Miquel
2021-02-09 15:33     ` Ihor Radchenko
2021-02-09 22:30       ` Sébastien Miquel
2021-02-10  3:38         ` Ihor Radchenko
2021-02-10  6:18       ` Timothy
2021-02-10  6:58         ` Ihor Radchenko
2021-02-10  8:56       ` Eric S Fraga
2021-02-10 23:09         ` Samuel Wales
2021-02-14  4:39         ` Timothy
2021-02-14 10:36           ` Eric S Fraga
2021-02-14 12:45             ` Timothy
2021-02-15 11:33               ` Eric S Fraga
2021-02-15 18:29               ` Sébastien Miquel
2021-02-26 19:58                 ` Sébastien Miquel [this message]
2021-03-02  5:10                   ` [PATCH] ~org-font-lock-add-priority-faces~: ensure priority cookies are in a headline Kyle Meyer
2021-02-09  9:38 ` Typing latency Eric S Fraga
2021-02-09 14:09   ` Sébastien Miquel
2021-02-09 14:23   ` Christian Thäter
2021-02-11 16:21     ` Eric S Fraga
2021-02-11 16:25 ` Maxim Nikulin
2021-02-11 16:59   ` Ihor Radchenko
2021-02-13 15:49     ` Maxim Nikulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9f0fc01-2f32-8831-ac8b-0f0fe9e00a4d@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).