summaryrefslogtreecommitdiff
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina <fgallina@gnu.org>2015-07-06 01:03:46 -0300
committerFabián Ezequiel Gallina <fgallina@gnu.org>2015-07-06 01:04:00 -0300
commita5e39bfae8fe8950a01e01b1ae1ad864f5f523b4 (patch)
tree7452a926b25a45f793fe5c3a9d6fb4e25bc5ea0a /lisp/progmodes/python.el
parent342ed936e1957c0af32b96d6dee13fa0c84452c1 (diff)
downloademacs-a5e39bfae8fe8950a01e01b1ae1ad864f5f523b4.tar.gz
emacs-a5e39bfae8fe8950a01e01b1ae1ad864f5f523b4.tar.bz2
emacs-a5e39bfae8fe8950a01e01b1ae1ad864f5f523b4.zip
python.el: Fix mark-defun behavior (Bug#19665)
* lisp/progmodes/python.el: (python-mark-defun): New function. * test/automated/python-tests.el (python-mark-defun-1) (python-mark-defun-2, python-mark-defun-3): New tests.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f641880428c..fbf944f9c68 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -284,6 +284,7 @@
(define-key map [remap backward-sentence] 'python-nav-backward-block)
(define-key map [remap forward-sentence] 'python-nav-forward-block)
(define-key map [remap backward-up-list] 'python-nav-backward-up-list)
+ (define-key map [remap mark-defun] 'python-mark-defun)
(define-key map "\C-c\C-j" 'imenu)
;; Indent specific
(define-key map "\177" 'python-indent-dedent-line-backspace)
@@ -1251,6 +1252,21 @@ the line will be re-indented automatically if needed."
(python-indent-region dedenter-pos current-pos)))))))))
+;;; Mark
+
+(defun python-mark-defun (&optional allow-extend)
+ "Put mark at end of this defun, point at beginning.
+The defun marked is the one that contains point or follows point.
+
+Interactively (or with ALLOW-EXTEND non-nil), if this command is
+repeated or (in Transient Mark mode) if the mark is active, it
+marks the next defun after the ones already marked."
+ (interactive "p")
+ (when (python-info-looking-at-beginning-of-defun)
+ (end-of-line 1))
+ (mark-defun allow-extend))
+
+
;;; Navigation
(defvar python-nav-beginning-of-defun-regexp