Use 'font-lock-extend-region-functions' in python-mode

* lisp/progmodes/python.el (python-font-lock-extend-region): Change
arguments and return value for 'font-lock-extend-region-functions'.
(python-mode): Change from
'font-lock-extend-after-change-region-function' to
'font-lock-extend-region-functions'.  (Bug#63622)
This commit is contained in:
kobarity 2023-05-24 22:06:51 +09:00 committed by Eli Zaretskii
parent b7b82ecb2b
commit aa5158630e

View file

@ -869,18 +869,22 @@ decorators, exceptions, and assignments.")
Which one will be chosen depends on the value of Which one will be chosen depends on the value of
`font-lock-maximum-decoration'.") `font-lock-maximum-decoration'.")
(defun python-font-lock-extend-region (beg end _old-len) (defvar font-lock-beg)
"Extend font-lock region given by BEG and END to statement boundaries." (defvar font-lock-end)
(save-excursion (defun python-font-lock-extend-region ()
(save-match-data "Extend font-lock region to statement boundaries."
(goto-char beg) (let ((beg font-lock-beg)
(python-nav-beginning-of-statement) (end font-lock-end))
(setq beg (point)) (goto-char beg)
(goto-char end) (python-nav-beginning-of-statement)
(python-nav-end-of-statement) (beginning-of-line)
(setq end (point)) (when (< (point) beg)
(cons beg end)))) (setq font-lock-beg (point)))
(goto-char end)
(python-nav-end-of-statement)
(when (< end (point))
(setq font-lock-end (point)))
(or (/= beg font-lock-beg) (/= end font-lock-end))))
(defconst python-syntax-propertize-function (defconst python-syntax-propertize-function
(syntax-propertize-rules (syntax-propertize-rules
@ -6704,9 +6708,9 @@ implementations: `python-mode' and `python-ts-mode'."
`(,python-font-lock-keywords `(,python-font-lock-keywords
nil nil nil nil nil nil nil nil
(font-lock-syntactic-face-function (font-lock-syntactic-face-function
. python-font-lock-syntactic-face-function) . python-font-lock-syntactic-face-function)))
(font-lock-extend-after-change-region-function (add-hook 'font-lock-extend-region-functions
. python-font-lock-extend-region))) #'python-font-lock-extend-region nil t)
(setq-local syntax-propertize-function (setq-local syntax-propertize-function
python-syntax-propertize-function) python-syntax-propertize-function)
(setq-local imenu-create-index-function (setq-local imenu-create-index-function