GNU bug report logs - #19748
python.el: navigate to beginning of defun gets stucked

Previous Next

Package: emacs;

Reported by: Carlos Pita <carlosjosepita <at> gmail.com>

Date: Mon, 2 Feb 2015 21:31:01 UTC

Severity: normal

Tags: notabug, patch

Merged with 19665

Fixed in version 25.0.50

Done: fgallina <at> gnu.org (Fabián Ezequiel Gallina)

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Carlos Pita <carlosjosepita <at> gmail.com>
Subject: bug#19748: closed (python.el: navigate to beginning of defun gets
 stucked)
Date: Sat, 07 Feb 2015 21:54:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#19748: python.el: navigate to beginning of defun gets stucked

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 19748 <at> debbugs.gnu.org.

-- 
19748: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19748
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: fgallina <at> gnu.org (Fabián Ezequiel Gallina)
To: 19748-done <at> debbugs.gnu.org
Subject: python.el: navigate to beginning of defun gets stucked
Date: Sat, 07 Feb 2015 18:53:51 -0300
This doesn't happen with master's python.el.

The regression you are experiencing seems to be happening because you
are working on a patched python.el version that includes the change you
proposed in http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19665


Cheers,
Fabián.

[Message part 3 (message/rfc822, inline)]
From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: galli.87 <at> gmail.com
Subject: python.el: navigate to beginning of defun gets stucked
Date: Mon, 02 Feb 2015 18:29:39 -0300
[Message part 4 (text/plain, inline)]
This report is for python.el in the current master
(c10828bd8520db83cc06a2ad5de6f8a1ad74b83c).

Pressing C-M-a one time correctly positions the point at the beginning
of the current class or defun statement. Pressing C-M-a multiple times
is futile, as the point gets stucked where the first movement left
it. This is not consistent with the usual emacs behavior and it's not
very convenient to navigate code anyway.

The problem is in python-nav--beginning-of-defun:

            (when (and (> arg 0)
                       (python-info-looking-at-beginning-of-defun))
              (end-of-line 1))

This puts the point at the end of the line when the point is at a defun
or class line and the navigation is backward. So the next
re-search-backward will match the current line. This is fine when the
point is *after* the column where the defun or class statement starts,
but not quite so when the point is *over the indentation* whitespace
(that is, before the beginning of the defun/class keyword).

One simple solution is to add another condition:

            (when (and (> arg 0)
                       (> (current-column) (current-indentation))
                       (python-info-looking-at-beginning-of-defun))
              (end-of-line 1))

[beg-defun.patch (text/x-diff, inline)]
diff --git a/.emacs.d/lisp/python.el b/.emacs.d/lisp/python.el
index 788d09f..ca69b68 100644
--- a/.emacs.d/lisp/python.el
+++ b/.emacs.d/lisp/python.el
@@ -1295,6 +1295,7 @@ With positive ARG search backwards, else search forwards."
          (found
           (progn
             (when (and (> arg 0)
+                       (> (current-column) (current-indentation))
                        (python-info-looking-at-beginning-of-defun))
               (end-of-line 1))
             (while (and (funcall re-search-fn

This bug report was last modified 9 years and 323 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.