[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2dcb0f8: Add new user option python-forward-sexp-function
From: |
Lars Ingebrigtsen |
Subject: |
master 2dcb0f8: Add new user option python-forward-sexp-function |
Date: |
Sat, 31 Jul 2021 12:45:10 -0400 (EDT) |
branch: master
commit 2dcb0f8f5241d0fcdcdb3da10d3eb4d7916e4869
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
etc/NEWS | 5 +++++
lisp/progmodes/python.el | 18 +++++++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 40a5e51..1a7f20b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -593,6 +593,11 @@ This is used to fontify non-scalar variables.
** Python mode
+---
+*** New user option 'python-forward-sexp-function'.
+This allows the user to easier customize whether to use block-based
+navigation or not.
+
*** 'python-shell-interpreter' now defaults to python3 on systems with python3.
*** 'C-c C-r' can now be used on arbitrary regions.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f7267bd..2557704 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 2dcb0f8: Add new user option python-forward-sexp-function,
Lars Ingebrigtsen <=