GNU bug report logs - #63622
lisp/progmodes/python.el: performance regression introduced by multiline font-lock

Previous Next

Package: emacs;

Reported by: Tom Gillespie <tgbugs <at> gmail.com>

Date: Sun, 21 May 2023 03:15:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: kobarity <kobarity <at> gmail.com>
Cc: Tom Gillespie <tgbugs <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>, 63622 <at> debbugs.gnu.org
Subject: bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock
Date: Mon, 22 May 2023 11:08:35 -0400
> @@ -869,18 +869,20 @@ python-font-lock-keywords
>  Which one will be chosen depends on the value of
>  `font-lock-maximum-decoration'.")
>  
> -(defun python-font-lock-extend-region (beg end _old-len)
> -  "Extend font-lock region given by BEG and END to statement boundaries."
> -  (save-excursion
> -    (save-match-data
> -      (goto-char beg)
> -      (python-nav-beginning-of-statement)
> -      (setq beg (point))
> -      (goto-char end)
> -      (python-nav-end-of-statement)
> -      (setq end (point))
> -      (cons beg end))))
> -
> +(defvar font-lock-beg)
> +(defvar font-lock-end)
> +(defun python-font-lock-extend-region ()
> +  "Extend font-lock region to statement boundaries."
> +  (let ((beg font-lock-beg)
> +        (end font-lock-end))
> +    (goto-char beg)
> +    (python-nav-beginning-of-statement)
> +    (setq font-lock-beg (point))
> +    (goto-char end)
> +    (python-nav-end-of-statement)
> +    (when (not (eobp)) (forward-char))
> +    (setq font-lock-end (point))
> +    (or (/= beg font-lock-beg) (/= end font-lock-end))))
>  
>  (defconst python-syntax-propertize-function
>    (syntax-propertize-rules

Looks fine to me (I assume you've checked that it behaves about as well
as the previous code).

> @@ -6708,8 +6710,8 @@ python-mode
>                  nil nil nil nil
>                  (font-lock-syntactic-face-function
>                   . python-font-lock-syntactic-face-function)
> -                (font-lock-extend-after-change-region-function
> -                 . python-font-lock-extend-region)))
> +                (font-lock-extend-region-functions
> +                 . (python-font-lock-extend-region))))
>    (setq-local syntax-propertize-function
>                python-syntax-propertize-function)
>    (setq-local imenu-create-index-function

This is bound to break in some cases.  Please use `add-hook` instead.


        Stefan





This bug report was last modified 1 year and 361 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.