aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorJakub Ječmínek2025-06-29 23:56:13 +0200
committerEli Zaretskii2025-08-02 17:14:50 +0300
commite52ed1b5d1531e7dc15f3f8ddf7042b0a7e71f50 (patch)
treecb803625c3e3e292ac8773812ed437141a06460e /lisp/progmodes/python.el
parent2846dd8842cc6d6e9ff6395a4822456f130ce4a8 (diff)
downloademacs-e52ed1b5d1531e7dc15f3f8ddf7042b0a7e71f50.tar.gz
emacs-e52ed1b5d1531e7dc15f3f8ddf7042b0a7e71f50.zip
Improve region deletion handling in python.el
* lisp/progmodes/python.el (python-indent-dedent-line-backspace): Delete the text in the region if Transient Mark mode is enabled, the mark is active, and prefix arg is 1. (Bug#48695) * test/lisp/progmodes/python-tests.el (python-indent-dedent-line-backspace-4): Add new test.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f4f0518dbfd..8b5ffae57d6 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1967,10 +1967,13 @@ indentation levels from right to left."
1967 1967
1968(defun python-indent-dedent-line-backspace (arg) 1968(defun python-indent-dedent-line-backspace (arg)
1969 "De-indent current line. 1969 "De-indent current line.
1970Argument ARG is passed to `backward-delete-char-untabify' when 1970Argument ARG is passed to `backward-delete-char-untabify' when point is
1971point is not in between the indentation." 1971not in between the indentation or when Transient Mark mode is enabled,
1972the mark is active, and ARG is 1."
1972 (interactive "*p") 1973 (interactive "*p")
1973 (unless (python-indent-dedent-line) 1974 (when (or
1975 (and (use-region-p) (= arg 1))
1976 (not (python-indent-dedent-line)))
1974 (backward-delete-char-untabify arg))) 1977 (backward-delete-char-untabify arg)))
1975 1978
1976(put 'python-indent-dedent-line-backspace 'delete-selection 'supersede) 1979(put 'python-indent-dedent-line-backspace 'delete-selection 'supersede)