diff options
| author | kobarity | 2023-05-24 22:06:51 +0900 |
|---|---|---|
| committer | Eli Zaretskii | 2023-05-26 12:59:43 +0300 |
| commit | aa5158630e7113a67ae804d4253911028cb8f984 (patch) | |
| tree | fabbaccf48ac177d2d39596404070705415d9392 /lisp/progmodes/python.el | |
| parent | b7b82ecb2b4c2ce33c11e5388b692cd403ab55e6 (diff) | |
| download | emacs-aa5158630e7113a67ae804d4253911028cb8f984.tar.gz emacs-aa5158630e7113a67ae804d4253911028cb8f984.zip | |
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)
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 032a17c52ff..adaeacc2ec1 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -869,18 +869,22 @@ decorators, exceptions, and assignments.") | |||
| 869 | Which one will be chosen depends on the value of | 869 | Which one will be chosen depends on the value of |
| 870 | `font-lock-maximum-decoration'.") | 870 | `font-lock-maximum-decoration'.") |
| 871 | 871 | ||
| 872 | (defun python-font-lock-extend-region (beg end _old-len) | 872 | (defvar font-lock-beg) |
| 873 | "Extend font-lock region given by BEG and END to statement boundaries." | 873 | (defvar font-lock-end) |
| 874 | (save-excursion | 874 | (defun python-font-lock-extend-region () |
| 875 | (save-match-data | 875 | "Extend font-lock region to statement boundaries." |
| 876 | (goto-char beg) | 876 | (let ((beg font-lock-beg) |
| 877 | (python-nav-beginning-of-statement) | 877 | (end font-lock-end)) |
| 878 | (setq beg (point)) | 878 | (goto-char beg) |
| 879 | (goto-char end) | 879 | (python-nav-beginning-of-statement) |
| 880 | (python-nav-end-of-statement) | 880 | (beginning-of-line) |
| 881 | (setq end (point)) | 881 | (when (< (point) beg) |
| 882 | (cons beg end)))) | 882 | (setq font-lock-beg (point))) |
| 883 | 883 | (goto-char end) | |
| 884 | (python-nav-end-of-statement) | ||
| 885 | (when (< end (point)) | ||
| 886 | (setq font-lock-end (point))) | ||
| 887 | (or (/= beg font-lock-beg) (/= end font-lock-end)))) | ||
| 884 | 888 | ||
| 885 | (defconst python-syntax-propertize-function | 889 | (defconst python-syntax-propertize-function |
| 886 | (syntax-propertize-rules | 890 | (syntax-propertize-rules |
| @@ -6704,9 +6708,9 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6704 | `(,python-font-lock-keywords | 6708 | `(,python-font-lock-keywords |
| 6705 | nil nil nil nil | 6709 | nil nil nil nil |
| 6706 | (font-lock-syntactic-face-function | 6710 | (font-lock-syntactic-face-function |
| 6707 | . python-font-lock-syntactic-face-function) | 6711 | . python-font-lock-syntactic-face-function))) |
| 6708 | (font-lock-extend-after-change-region-function | 6712 | (add-hook 'font-lock-extend-region-functions |
| 6709 | . python-font-lock-extend-region))) | 6713 | #'python-font-lock-extend-region nil t) |
| 6710 | (setq-local syntax-propertize-function | 6714 | (setq-local syntax-propertize-function |
| 6711 | python-syntax-propertize-function) | 6715 | python-syntax-propertize-function) |
| 6712 | (setq-local imenu-create-index-function | 6716 | (setq-local imenu-create-index-function |