Subject: bug#19665: 25.0.50; python.el: mark defun bug when point is in class statement

From: Carlos Pita <[email-masked]>
Date: Mon, 9 Feb 2015 13:46:03 -0300

Updated patch, see detailed discussion in

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19748

On Fri, Jan 23, 2015 at 1:13 PM, GNU bug Tracking System
<[email-masked]> wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  [email-masked]
>
> If you wish to submit further information on this problem, please
> send it to [email-masked].
>
> Please do not send mail to [email-masked] unless you wish
> to report a problem with the Bug-tracking system.
>
> --
> 19665: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19665
> GNU Bug Tracking System
> Contact [email-masked] with problems
diff --git a/.emacs.d/lisp/python.el b/.emacs.d/lisp/python.el
index 30b62f5..0337a17 100644
--- a/.emacs.d/lisp/python.el
+++ b/.emacs.d/lisp/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)
@@ -1285,7 +1286,7 @@ With positive ARG search backwards, else search forwards."
                      0))))
          (found
           (progn
-            (when (and (< arg 0)
+            (when (and (> arg 0)
                        (python-info-looking-at-beginning-of-defun))
               (end-of-line 1))
             (while (and (funcall re-search-fn
@@ -4460,6 +4461,12 @@ default to utf-8."
 
 ;;; Utility functions
 
+(defun python-mark-defun ()
+  (interactive)
+  (when (python-info-looking-at-beginning-of-defun)
+    (end-of-line 1))
+  (mark-defun))
+
 (defun python-util-goto-line (line-number)
   "Move point to LINE-NUMBER."
   (goto-char (point-min))