From 2dcb0f8f5241d0fcdcdb3da10d3eb4d7916e4869 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 31 Jul 2021 18:44:02 +0200 Subject: Add new user option python-forward-sexp-function * lisp/progmodes/python.el (python-forward-sexp-function): New user option (bug#41361). (python-mode): Use it. --- lisp/progmodes/python.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f7267bdef29..2557704e403 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -54,14 +54,7 @@ ;; `python-nav-backward-statement', ;; `python-nav-beginning-of-statement', `python-nav-end-of-statement', ;; `python-nav-beginning-of-block', `python-nav-end-of-block' and -;; `python-nav-if-name-main' are included but no bound to any key. At -;; last but not least the specialized `python-nav-forward-sexp' allows -;; easy navigation between code blocks. If you prefer `cc-mode'-like -;; `forward-sexp' movement, setting `forward-sexp-function' to nil is -;; enough, You can do that using the `python-mode-hook': - -;; (add-hook 'python-mode-hook -;; (lambda () (setq forward-sexp-function nil))) +;; `python-nav-if-name-main' are included but no bound to any key. ;; Shell interaction: is provided and allows opening Python shells ;; inside Emacs and executing any block of code of your current buffer @@ -5505,6 +5498,13 @@ By default messages are considered errors." :type '(alist :key-type (regexp) :value-type (symbol))) +(defcustom python-forward-sexp-function #'python-nav-forward-sexp + "Function to use when navigating between expressions." + :version "28.1" + :type '(choice (const :tag "Python blocks" python-nav-forward-sexp) + (const :tag "CC-mode like" nil) + function)) + (defvar-local python--flymake-proc nil) (defun python--flymake-parse-output (source proc report-fn) @@ -5602,7 +5602,7 @@ REPORT-FN is Flymake's callback function." (setq-local parse-sexp-lookup-properties t) (setq-local parse-sexp-ignore-comments t) - (setq-local forward-sexp-function #'python-nav-forward-sexp) + (setq-local forward-sexp-function python-forward-sexp-function) (setq-local font-lock-defaults `(,python-font-lock-keywords -- cgit v1.2.1