[V] Re: beginning-of-defun bug
Stephen J. Turnbull
stephen at xemacs.org
Sat Oct 10 15:44:15 EDT 2009
Andreas Roehler writes:
> The task was to make "M-x beginning-of-defun" work in python- and
> related modes.
> I'm saying: if M-x beginning-of-defun has no predictable result for
> users, its a bug.
That's true. By that definition, M-x beginning-of-defun is not buggy.
In almost all cases, beginning-of-defun does what its docstring say,
which makes it predictable. Only in one case does it do something
different, which is unpredictable, and buggy. That's when
beginning-of-defun-function is set to py-beginning-of-def-or-class.
You are confusing the historical behavior of C-M-a in python-mode with
the predictability of beginning-of-defun. That is an error, both in
theory as explained above, and in practice because you can simply bind
C-M-a to py-beginning-of-def-or-class and get the behavior you prefer.
> What about to try it instead of reasoning?
Just to make you happy, I've tried it, with your patch.
Unsurprisingly, it behaves exactly as the docstring of
py-beginning-of-def-or-class says, which is different from the
behavior documented for beginning-of-defun.
Do I like the behavior? No, I don't. I've known for a while that in
code with lots of small method definitions, I very often want to use
C-u C-M-a to navigate to the 4th previous def, more rarely to go to
the beginning of the class. I have
(defun sjt/beginning-of-def (n) (py-beginning-of-def-or-class nil n))
(defun sjt/beginning-of-class (n) (py-beginning-of-def-or-class t n))
(define-key py-mode-map [(control meta a)] sjt/beginning-of-def)
(define-key py-mode-map [(control meta A)] sjt/beginning-of-class)))
in init.el. I never use the repeat count for C-M-A, it turns out, but
since I do use it for C-M-a, I have to split the commands. On TTYs, I
live without C-M-A.
But that doesn't matter, I'm not going to tell you to change
> And again: there is nothing wrong with python-modes implemention.
That's arguable, but this is not the thread for that. What is clear is
that py-beginning-of-def-or-class is not a correct implementation of
beginning-of-defun, because it does not treat the prefix argument as a
> The caller is stupid, far below its capacities.
"Be smarter" is a feature request, not a bug report.
More information about the XEmacs-Patches