diff options
| author | Yuan Fu | 2022-11-19 00:25:57 -0800 |
|---|---|---|
| committer | Yuan Fu | 2022-11-19 00:25:57 -0800 |
| commit | c6384e9bfbc765229ea9676ba1044b9db28fec2d (patch) | |
| tree | 1d2aba794d06f2b4cda7c5b2b22393a5947d9867 /lisp/progmodes/python.el | |
| parent | 2f03053e568f38a1dce5ffe02ad1359069ef84c8 (diff) | |
| download | emacs-c6384e9bfbc765229ea9676ba1044b9db28fec2d.tar.gz emacs-c6384e9bfbc765229ea9676ba1044b9db28fec2d.zip | |
Fix python-mode tree-sitter fontification
Forgot to update python-mode's code when I added the tree-sitter
notifier facility. Now it doesn't need any special treatment anymore.
Leaving it as is causes some incorrect fontification.
* lisp/progmodes/python.el (python--treesit-fontify-string): Accept
the string node rather than the quote node.
(python--treesit-settings): Capture string node.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 22485a025e0..b9b71a57d7d 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1014,16 +1014,15 @@ It makes underscores and dots word constituent chars.") | |||
| 1014 | 1014 | ||
| 1015 | (defun python--treesit-fontify-string (node override start end &rest _) | 1015 | (defun python--treesit-fontify-string (node override start end &rest _) |
| 1016 | "Fontify string. | 1016 | "Fontify string. |
| 1017 | NODE is the leading quote in the string. Do not fontify the | 1017 | NODE is the string node. Do not fontify the initial f for |
| 1018 | initial f for f-strings. OVERRIDE is the override flag described | 1018 | f-strings. OVERRIDE is the override flag described in |
| 1019 | in `treesit-font-lock-rules'. START and END marks the region to | 1019 | `treesit-font-lock-rules'. START and END marks the region to be |
| 1020 | be fontified." | 1020 | fontified." |
| 1021 | (let* ((string (treesit-node-parent node)) | 1021 | (let* ((string-beg (treesit-node-start node)) |
| 1022 | (string-beg (treesit-node-start string)) | 1022 | (string-end (treesit-node-end node)) |
| 1023 | (string-end (treesit-node-end string)) | ||
| 1024 | (maybe-defun (treesit-node-parent | 1023 | (maybe-defun (treesit-node-parent |
| 1025 | (treesit-node-parent | 1024 | (treesit-node-parent |
| 1026 | (treesit-node-parent string)))) | 1025 | (treesit-node-parent node)))) |
| 1027 | (face (if (member (treesit-node-type maybe-defun) | 1026 | (face (if (member (treesit-node-type maybe-defun) |
| 1028 | '("function_definition" | 1027 | '("function_definition" |
| 1029 | "class_definition")) | 1028 | "class_definition")) |
| @@ -1043,8 +1042,7 @@ be fontified." | |||
| 1043 | :feature 'string | 1042 | :feature 'string |
| 1044 | :language 'python | 1043 | :language 'python |
| 1045 | :override t | 1044 | :override t |
| 1046 | ;; TODO Document on why we do this. | 1045 | '((string) @python--treesit-fontify-string) |
| 1047 | '((string :anchor "\"" @python--treesit-fontify-string)) | ||
| 1048 | 1046 | ||
| 1049 | :feature 'string-interpolation | 1047 | :feature 'string-interpolation |
| 1050 | :language 'python | 1048 | :language 'python |