From 8c56557cd9dff754b7f28f5fb919ca3b2c58ebf3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 20 May 2023 17:56:40 +0300 Subject: Fix Skeletons menu-bar menu in Python modes * lisp/progmodes/python.el (python-mode, python-ts-mode): Call 'python-skeleton-add-menu-items' here, not in 'python-base-mode', since the "Python" menu is not yet set up in the latter. (Bug#63598) --- lisp/progmodes/python.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f810f1e2164..6fc05b246a6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6694,8 +6694,6 @@ implementations: `python-mode' and `python-ts-mode'." (setq-local prettify-symbols-alist python-prettify-symbols-alist) - (python-skeleton-add-menu-items) - (make-local-variable 'python-shell-internal-buffer) (add-hook 'flymake-diagnostic-functions #'python-flymake nil t)) @@ -6719,6 +6717,8 @@ implementations: `python-mode' and `python-ts-mode'." (add-hook 'which-func-functions #'python-info-current-defun nil t) + (python-skeleton-add-menu-items) + (when python-indent-guess-indent-offset (python-indent-guess-indent-offset))) @@ -6745,6 +6745,8 @@ implementations: `python-mode' and `python-ts-mode'." #'python--treesit-defun-name) (treesit-major-mode-setup) + (python-skeleton-add-menu-items) + (when python-indent-guess-indent-offset (python-indent-guess-indent-offset)) -- cgit v1.2.1 From b7b82ecb2b4c2ce33c11e5388b692cd403ab55e6 Mon Sep 17 00:00:00 2001 From: kobarity Date: Wed, 24 May 2023 22:01:12 +0900 Subject: Fix python-info-docstring-p * lisp/progmodes/python.el (python-info-docstring-p): Stop using python-rx string-delimiter. * test/lisp/progmodes/python-tests.el (python-font-lock-escape-sequence-bytes-newline) (python-font-lock-escape-sequence-hex-octal) (python-font-lock-escape-sequence-unicode) (python-font-lock-raw-escape-sequence): Mark as expected failures until another bug in 'python-info-docstring-p' is corrected. (python-info-docstring-p-7): New test. (Bug#63622) --- lisp/progmodes/python.el | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 6fc05b246a6..032a17c52ff 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6018,8 +6018,7 @@ point's current `syntax-ppss'." (let ((counter 1) (indentation (current-indentation)) (backward-sexp-point) - (re (concat "[uU]?[rR]?" - (python-rx string-delimiter)))) + (re "[uU]?[rR]?[\"']")) (when (and (not (python-info-assignment-statement-p)) (looking-at-p re) @@ -6040,9 +6039,7 @@ point's current `syntax-ppss'." backward-sexp-point)) (setq last-backward-sexp-point backward-sexp-point)) - (looking-at-p - (concat "[uU]?[rR]?" - (python-rx string-delimiter)))))) + (looking-at-p re)))) ;; Previous sexp was a string, restore point. (goto-char backward-sexp-point) (cl-incf counter)) -- cgit v1.2.1 From aa5158630e7113a67ae804d4253911028cb8f984 Mon Sep 17 00:00:00 2001 From: kobarity Date: Wed, 24 May 2023 22:06:51 +0900 Subject: 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) --- lisp/progmodes/python.el | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'lisp/progmodes/python.el') 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.") Which one will be chosen depends on the value of `font-lock-maximum-decoration'.") -(defun python-font-lock-extend-region (beg end _old-len) - "Extend font-lock region given by BEG and END to statement boundaries." - (save-excursion - (save-match-data - (goto-char beg) - (python-nav-beginning-of-statement) - (setq beg (point)) - (goto-char end) - (python-nav-end-of-statement) - (setq end (point)) - (cons beg end)))) - +(defvar font-lock-beg) +(defvar font-lock-end) +(defun python-font-lock-extend-region () + "Extend font-lock region to statement boundaries." + (let ((beg font-lock-beg) + (end font-lock-end)) + (goto-char beg) + (python-nav-beginning-of-statement) + (beginning-of-line) + (when (< (point) beg) + (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 (syntax-propertize-rules @@ -6704,9 +6708,9 @@ implementations: `python-mode' and `python-ts-mode'." `(,python-font-lock-keywords nil nil nil nil (font-lock-syntactic-face-function - . python-font-lock-syntactic-face-function) - (font-lock-extend-after-change-region-function - . python-font-lock-extend-region))) + . python-font-lock-syntactic-face-function))) + (add-hook 'font-lock-extend-region-functions + #'python-font-lock-extend-region nil t) (setq-local syntax-propertize-function python-syntax-propertize-function) (setq-local imenu-create-index-function -- cgit v1.2.1