GNU bug report logs - #2379
[PATCH?] lisp.el: beginning-of-defun

Previous Next

Package: emacs;

Reported by: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>

Date: Thu, 19 Feb 2009 02:45:04 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: 2379 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#2379: [PATCH?] lisp.el: beginning-of-defun
Date: Thu, 19 Feb 2009 12:31:22 -0500
> There's some strange programming style in `beginning-of-defun-raw' for
> Emacs 22.2, perhaps this is what was meant by the use of this `progn'
> syntax?

> -	 (progn (goto-char (1- (match-end 0)))) t))
> +	 (progn (goto-char (1- (match-end 0))) t)))

I think that was the intention.  Note that it turns out that the two
forms are equivalent in this context (because goto-char never returns
nil).

> Then, once that is figured out, why doesn't `beginning-of-defun'
> manage zero arguments like many of the movement commands do?

I'd rather not touch its behavior for 0.  Basically, it should never be
called with a 0 argument (see below).

> Support for a zero argument in these functions is important for
> situations where you want to be programmatic with
> `beginning-of-defun',   Can this be fixed?

AFAICT, proper support for 0 would require a serious rethink of BOD's
semantics: currently if you're inside defun number N, then (BOD i) moves
to (N-(i-1)) is i is positive and to (N-i) if i is negative.  I.e. it
moves to N if i=1 and to N+1 if i=-1, so where should 0 move to: there
is no other defun between those two.


        Stefan





This bug report was last modified 16 years and 91 days ago.

Previous Next


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