unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19748: python.el: navigate to beginning of defun gets stucked
@ 2015-02-02 21:29 Carlos Pita
  2015-02-07 21:53 ` Fabián Ezequiel Gallina
  2015-02-09 16:45 ` bug#19748: Carlos Pita
  0 siblings, 2 replies; 3+ messages in thread
From: Carlos Pita @ 2015-02-02 21:29 UTC (permalink / raw)
  To: 19748; +Cc: galli.87

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

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))


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 518 bytes --]

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-09 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-02 21:29 bug#19748: python.el: navigate to beginning of defun gets stucked Carlos Pita
2015-02-07 21:53 ` Fabián Ezequiel Gallina
2015-02-09 16:45 ` bug#19748: Carlos Pita

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).