diff options
| author | Po Lu | 2023-05-27 09:49:49 +0800 |
|---|---|---|
| committer | Po Lu | 2023-05-27 09:49:49 +0800 |
| commit | cdca0fddcc3352bcd01bec147c264be1b2a04e12 (patch) | |
| tree | 3b15e37936fecc34314883a41a355873c2b9133c /lisp/progmodes/python.el | |
| parent | 0eb1f4e57125117006f109a5549082008fc9fbb1 (diff) | |
| parent | e77e986a9b7d735c0e39198c8b80a34a29005fc5 (diff) | |
| download | emacs-cdca0fddcc3352bcd01bec147c264be1b2a04e12.tar.gz emacs-cdca0fddcc3352bcd01bec147c264be1b2a04e12.zip | |
Merge remote-tracking branch 'origin/master' into feature/android
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4f57eda3cfc..8c716ffb313 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 |
| @@ -6078,8 +6082,7 @@ point's current `syntax-ppss'." | |||
| 6078 | (let ((counter 1) | 6082 | (let ((counter 1) |
| 6079 | (indentation (current-indentation)) | 6083 | (indentation (current-indentation)) |
| 6080 | (backward-sexp-point) | 6084 | (backward-sexp-point) |
| 6081 | (re (concat "[uU]?[rR]?" | 6085 | (re "[uU]?[rR]?[\"']")) |
| 6082 | (python-rx string-delimiter)))) | ||
| 6083 | (when (and | 6086 | (when (and |
| 6084 | (not (python-info-assignment-statement-p)) | 6087 | (not (python-info-assignment-statement-p)) |
| 6085 | (looking-at-p re) | 6088 | (looking-at-p re) |
| @@ -6100,9 +6103,7 @@ point's current `syntax-ppss'." | |||
| 6100 | backward-sexp-point)) | 6103 | backward-sexp-point)) |
| 6101 | (setq last-backward-sexp-point | 6104 | (setq last-backward-sexp-point |
| 6102 | backward-sexp-point)) | 6105 | backward-sexp-point)) |
| 6103 | (looking-at-p | 6106 | (looking-at-p re)))) |
| 6104 | (concat "[uU]?[rR]?" | ||
| 6105 | (python-rx string-delimiter)))))) | ||
| 6106 | ;; Previous sexp was a string, restore point. | 6107 | ;; Previous sexp was a string, restore point. |
| 6107 | (goto-char backward-sexp-point) | 6108 | (goto-char backward-sexp-point) |
| 6108 | (cl-incf counter)) | 6109 | (cl-incf counter)) |
| @@ -6754,8 +6755,6 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6754 | 6755 | ||
| 6755 | (setq-local prettify-symbols-alist python-prettify-symbols-alist) | 6756 | (setq-local prettify-symbols-alist python-prettify-symbols-alist) |
| 6756 | 6757 | ||
| 6757 | (python-skeleton-add-menu-items) | ||
| 6758 | |||
| 6759 | (make-local-variable 'python-shell-internal-buffer) | 6758 | (make-local-variable 'python-shell-internal-buffer) |
| 6760 | 6759 | ||
| 6761 | (add-hook 'flymake-diagnostic-functions #'python-flymake nil t)) | 6760 | (add-hook 'flymake-diagnostic-functions #'python-flymake nil t)) |
| @@ -6769,9 +6768,9 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6769 | `(,python-font-lock-keywords | 6768 | `(,python-font-lock-keywords |
| 6770 | nil nil nil nil | 6769 | nil nil nil nil |
| 6771 | (font-lock-syntactic-face-function | 6770 | (font-lock-syntactic-face-function |
| 6772 | . python-font-lock-syntactic-face-function) | 6771 | . python-font-lock-syntactic-face-function))) |
| 6773 | (font-lock-extend-after-change-region-function | 6772 | (add-hook 'font-lock-extend-region-functions |
| 6774 | . python-font-lock-extend-region))) | 6773 | #'python-font-lock-extend-region nil t) |
| 6775 | (setq-local syntax-propertize-function | 6774 | (setq-local syntax-propertize-function |
| 6776 | python-syntax-propertize-function) | 6775 | python-syntax-propertize-function) |
| 6777 | (setq-local imenu-create-index-function | 6776 | (setq-local imenu-create-index-function |
| @@ -6779,6 +6778,8 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6779 | 6778 | ||
| 6780 | (add-hook 'which-func-functions #'python-info-current-defun nil t) | 6779 | (add-hook 'which-func-functions #'python-info-current-defun nil t) |
| 6781 | 6780 | ||
| 6781 | (python-skeleton-add-menu-items) | ||
| 6782 | |||
| 6782 | (when python-indent-guess-indent-offset | 6783 | (when python-indent-guess-indent-offset |
| 6783 | (python-indent-guess-indent-offset))) | 6784 | (python-indent-guess-indent-offset))) |
| 6784 | 6785 | ||
| @@ -6805,6 +6806,8 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6805 | #'python--treesit-defun-name) | 6806 | #'python--treesit-defun-name) |
| 6806 | (treesit-major-mode-setup) | 6807 | (treesit-major-mode-setup) |
| 6807 | 6808 | ||
| 6809 | (python-skeleton-add-menu-items) | ||
| 6810 | |||
| 6808 | (when python-indent-guess-indent-offset | 6811 | (when python-indent-guess-indent-offset |
| 6809 | (python-indent-guess-indent-offset)) | 6812 | (python-indent-guess-indent-offset)) |
| 6810 | 6813 | ||