aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorEli Zaretskii2023-06-03 05:50:58 -0400
committerEli Zaretskii2023-06-03 05:50:58 -0400
commit970f94a2dd8bc4be4d71f1075421093ca6f87d28 (patch)
tree56ad75121692fa68fd1ec158a6b975dd2e902cbd /lisp/progmodes/python.el
parent68b87288aa54c2ec701fdf4333fc92e32313c83b (diff)
parentede3535051a8f3b209b830adcaba9cb1ddf58685 (diff)
downloademacs-970f94a2dd8bc4be4d71f1075421093ca6f87d28.tar.gz
emacs-970f94a2dd8bc4be4d71f1075421093ca6f87d28.zip
Merge from origin/emacs-29
ede3535051a ; Fix last change 8ec786349e1 Fix apostrophe handling in rust-ts-mode and go-ts-mode (B... 0eba9cf6511 * test/infra/Dockerfile.emba (emacs-base): Install also g... 4897c98b6c4 Fix 'python-util-clone-local-variables' 6b2c8dc9050 Revert "Enhance Python font-lock to support multilines" 348e4504c6d Fix typo in calc.texi 03663b8798a Update to Transient v0.4.1 dc7acb1aafe Avoid errors in 'delete-forward-char' deleting static com... 2f94f6de9d6 Make VS-15 and VS-16 compositions work correctly 753f8aa1f14 Fix project-name for vc-aware backend in non-file buffers 17c7915ab94 ; Fix 'package-install-upgrade-built-in' check for packag... e252ce26eab Add type_predicate 'is' as keyword in typescript-ts-mode ... 0a354d65784 Fix infloop in info-look.el 83b22139e4c Fix several todo-mode.el item editing bugs (bug#63811) ed4cd3eddf7 dockerfile-ts-mode: Prevent empty categories in imenu (Bu... 2e20e318da2 Brush up doc strings and terminology in plstore.el 372bc1278c2 Add internal documentation on plstore.el 23a14e7b902 Add compact_constructor_declaration font-locking to java-... 500abc4dc37 * lisp/tmm.el (tmm-completion-delete-prompt): Add more ch... afc1f329356 Allow to disable the DWIMish behavior of 'x' in package menu 08104c01504 Allow dired to invoke secondary browser a3063f0bc87 Add a binding for enriched-toggle-markup d8ba28fa394 Fix order of tmm-menubar when 'tmm-mid-prompt' is nil # Conflicts: # etc/NEWS
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el52
1 files changed, 17 insertions, 35 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 8c716ffb313..86bbf51dab7 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -415,7 +415,6 @@ instead."
415 "Python mode specialized rx macro. 415 "Python mode specialized rx macro.
416This variant of `rx' supports common Python named REGEXPS." 416This variant of `rx' supports common Python named REGEXPS."
417 `(rx-let ((sp-bsnl (or space (and ?\\ ?\n))) 417 `(rx-let ((sp-bsnl (or space (and ?\\ ?\n)))
418 (sp-nl (or space (and (? ?\\) ?\n)))
419 (block-start (seq symbol-start 418 (block-start (seq symbol-start
420 (or "def" "class" "if" "elif" "else" "try" 419 (or "def" "class" "if" "elif" "else" "try"
421 "except" "finally" "for" "while" "with" 420 "except" "finally" "for" "while" "with"
@@ -650,9 +649,9 @@ the {...} holes that appear within f-strings."
650 finally return (and result-valid result)))) 649 finally return (and result-valid result))))
651 650
652(defvar python-font-lock-keywords-level-1 651(defvar python-font-lock-keywords-level-1
653 `((,(python-rx symbol-start "def" (1+ sp-bsnl) (group symbol-name)) 652 `((,(python-rx symbol-start "def" (1+ space) (group symbol-name))
654 (1 font-lock-function-name-face)) 653 (1 font-lock-function-name-face))
655 (,(python-rx symbol-start "class" (1+ sp-bsnl) (group symbol-name)) 654 (,(python-rx symbol-start "class" (1+ space) (group symbol-name))
656 (1 font-lock-type-face))) 655 (1 font-lock-type-face)))
657 "Font lock keywords to use in `python-mode' for level 1 decoration. 656 "Font lock keywords to use in `python-mode' for level 1 decoration.
658 657
@@ -792,12 +791,12 @@ sign in chained assignment."
792 ;; [*a] = 5, 6 791 ;; [*a] = 5, 6
793 ;; are handled separately below 792 ;; are handled separately below
794 (,(python-font-lock-assignment-matcher 793 (,(python-font-lock-assignment-matcher
795 (python-rx (? (or "[" "(") (* sp-nl)) 794 (python-rx (? (or "[" "(") (* space))
796 grouped-assignment-target (* sp-nl) ?, (* sp-nl) 795 grouped-assignment-target (* space) ?, (* space)
797 (* assignment-target (* sp-nl) ?, (* sp-nl)) 796 (* assignment-target (* space) ?, (* space))
798 (? assignment-target (* sp-nl)) 797 (? assignment-target (* space))
799 (? ?, (* sp-nl)) 798 (? ?, (* space))
800 (? (or ")" "]") (* sp-bsnl)) 799 (? (or ")" "]") (* space))
801 (group assignment-operator))) 800 (group assignment-operator)))
802 (1 font-lock-variable-name-face) 801 (1 font-lock-variable-name-face)
803 (2 'font-lock-operator-face) 802 (2 'font-lock-operator-face)
@@ -813,9 +812,9 @@ sign in chained assignment."
813 ;; c: Collection = {1, 2, 3} 812 ;; c: Collection = {1, 2, 3}
814 ;; d: Mapping[int, str] = {1: 'bar', 2: 'baz'} 813 ;; d: Mapping[int, str] = {1: 'bar', 2: 'baz'}
815 (,(python-font-lock-assignment-matcher 814 (,(python-font-lock-assignment-matcher
816 (python-rx (or line-start ?\;) (* sp-bsnl) 815 (python-rx (or line-start ?\;) (* space)
817 grouped-assignment-target (* sp-bsnl) 816 grouped-assignment-target (* space)
818 (? ?: (* sp-bsnl) (+ not-simple-operator) (* sp-bsnl)) 817 (? ?: (* space) (+ not-simple-operator) (* space))
819 (group assignment-operator))) 818 (group assignment-operator)))
820 (1 font-lock-variable-name-face) 819 (1 font-lock-variable-name-face)
821 (2 'font-lock-operator-face)) 820 (2 'font-lock-operator-face))
@@ -824,10 +823,10 @@ sign in chained assignment."
824 ;; [a] = 5, 823 ;; [a] = 5,
825 ;; [*a] = 5, 6 824 ;; [*a] = 5, 6
826 (,(python-font-lock-assignment-matcher 825 (,(python-font-lock-assignment-matcher
827 (python-rx (or line-start ?\; ?=) (* sp-bsnl) 826 (python-rx (or line-start ?\; ?=) (* space)
828 (or "[" "(") (* sp-nl) 827 (or "[" "(") (* space)
829 grouped-assignment-target (* sp-nl) 828 grouped-assignment-target (* space)
830 (or ")" "]") (* sp-bsnl) 829 (or ")" "]") (* space)
831 (group assignment-operator))) 830 (group assignment-operator)))
832 (1 font-lock-variable-name-face) 831 (1 font-lock-variable-name-face)
833 (2 'font-lock-operator-face)) 832 (2 'font-lock-operator-face))
@@ -869,22 +868,6 @@ decorators, exceptions, and assignments.")
869Which one will be chosen depends on the value of 868Which one will be chosen depends on the value of
870`font-lock-maximum-decoration'.") 869`font-lock-maximum-decoration'.")
871 870
872(defvar font-lock-beg)
873(defvar font-lock-end)
874(defun python-font-lock-extend-region ()
875 "Extend font-lock region to statement boundaries."
876 (let ((beg font-lock-beg)
877 (end font-lock-end))
878 (goto-char beg)
879 (python-nav-beginning-of-statement)
880 (beginning-of-line)
881 (when (< (point) beg)
882 (setq font-lock-beg (point)))
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))))
888 871
889(defconst python-syntax-propertize-function 872(defconst python-syntax-propertize-function
890 (syntax-propertize-rules 873 (syntax-propertize-rules
@@ -6171,7 +6154,8 @@ Optional argument REGEXP selects variables to clone and defaults
6171to \"^python-\"." 6154to \"^python-\"."
6172 (mapc 6155 (mapc
6173 (lambda (pair) 6156 (lambda (pair)
6174 (and (symbolp (car pair)) 6157 (and (consp pair)
6158 (symbolp (car pair))
6175 (string-match (or regexp "^python-") 6159 (string-match (or regexp "^python-")
6176 (symbol-name (car pair))) 6160 (symbol-name (car pair)))
6177 (set (make-local-variable (car pair)) 6161 (set (make-local-variable (car pair))
@@ -6769,8 +6753,6 @@ implementations: `python-mode' and `python-ts-mode'."
6769 nil nil nil nil 6753 nil nil nil nil
6770 (font-lock-syntactic-face-function 6754 (font-lock-syntactic-face-function
6771 . python-font-lock-syntactic-face-function))) 6755 . python-font-lock-syntactic-face-function)))
6772 (add-hook 'font-lock-extend-region-functions
6773 #'python-font-lock-extend-region nil t)
6774 (setq-local syntax-propertize-function 6756 (setq-local syntax-propertize-function
6775 python-syntax-propertize-function) 6757 python-syntax-propertize-function)
6776 (setq-local imenu-create-index-function 6758 (setq-local imenu-create-index-function