From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.bugs Subject: bug#6157: narrow-to-defun fix when point is on function beginning Date: Wed, 21 Sep 2011 22:19:37 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1316636702 12848 80.91.229.12 (21 Sep 2011 20:25:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Sep 2011 20:25:02 +0000 (UTC) Cc: 6157@debbugs.gnu.org To: Lars Magne Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 21 22:24:57 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R6TLj-0000Ll-Tj for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Sep 2011 22:24:56 +0200 Original-Received: from localhost ([::1]:36547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6TLj-0008Sq-4v for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Sep 2011 16:24:55 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6TLe-0008S3-Gw for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2011 16:24:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6TLZ-0000Nn-Vq for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2011 16:24:50 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6TLZ-0000Nj-UE for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2011 16:24:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1R6TLq-0005eL-Cf for bug-gnu-emacs@gnu.org; Wed, 21 Sep 2011 16:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lennart Borgman Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Sep 2011 20:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6157 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 6157-submit@debbugs.gnu.org id=B6157.131663669921708 (code B ref 6157); Wed, 21 Sep 2011 20:25:02 +0000 Original-Received: (at 6157) by debbugs.gnu.org; 21 Sep 2011 20:24:59 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6TLn-0005e5-7h for submit@debbugs.gnu.org; Wed, 21 Sep 2011 16:24:59 -0400 Original-Received: from mail-fx0-f44.google.com ([209.85.161.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R6TLk-0005dx-DJ for 6157@debbugs.gnu.org; Wed, 21 Sep 2011 16:24:57 -0400 Original-Received: by fxd18 with SMTP id 18so1903609fxd.3 for <6157@debbugs.gnu.org>; Wed, 21 Sep 2011 13:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ZMvq0oPaRVAUtVXJAGnB7O40hW6xIFW+10Mn5vnkN4E=; b=Uv0/G2A3UaMJb3MVY5G3CVF82niKAclDoWHg+EtK2Jkv0+4Re3KnbIEiHCnM7DXsrK UIAMUNcZDYzIlDud9vXXj814uW/Mr4Hdga6Du4xEHwoyZDcLB5i3jgeST7lcXJAcpKly Ra18o/IkdlBgK6Q+zZfH7p+j19Vsyh1vl118Q= Original-Received: by 10.223.8.2 with SMTP id f2mr1634220faf.23.1316636397276; Wed, 21 Sep 2011 13:19:57 -0700 (PDT) Original-Received: by 10.152.20.229 with HTTP; Wed, 21 Sep 2011 13:19:37 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 21 Sep 2011 16:25:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:51593 Archived-At: On Wed, Sep 21, 2011 at 22:03, Lars Magne Ingebrigtsen wro= te: > Lennart Borgman writes: > >> `beginning-of-defun' goes to previous function when point is on the >> first character of a function. This is not currently taken care of in >> `narrow-to-defun'. This patch fixes this: >> >> c:\emacs-lp\bld\emacs\emacsw32\lisp\emacs-lisp>bzr diff --old >> c:\emacs-lp\bld\emacs\trunk -p trunk/:patched/ lisp.el >> =3D=3D=3D modified file 'lisp/emacs-lisp/lisp.el' >> --- trunk/lisp/emacs-lisp/lisp.el =C2=A0 =C2=A0 2010-04-27 17:57:32 +000= 0 >> +++ patched/lisp/emacs-lisp/lisp.el =C2=A0 2010-05-10 14:21:59 +0000 >> @@ -438,7 +438,20 @@ >> =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Try first in this order for the sake of la= nguages with nested >> =C2=A0 =C2=A0 =C2=A0 =C2=A0;; functions where several can end at the sam= e place as with >> =C2=A0 =C2=A0 =C2=A0 =C2=A0;; the offside rule, e.g. Python. >> - =C2=A0 =C2=A0 =C2=A0(beginning-of-defun) >> + >> + =C2=A0 =C2=A0 =C2=A0;; Finding the start of the function is a bit prob= lematic since >> + =C2=A0 =C2=A0 =C2=A0;; `beginning-of-defun' when we are on the first c= haracter of >> + =C2=A0 =C2=A0 =C2=A0;; the function might go to the previous function. >> + =C2=A0 =C2=A0 =C2=A0;; >> + =C2=A0 =C2=A0 =C2=A0;; Therefor we first move one character forward an= d then call >> + =C2=A0 =C2=A0 =C2=A0;; `beginning-of-defun'. =C2=A0However now we must= check that we did >> + =C2=A0 =C2=A0 =C2=A0;; not move into the next function. >> + =C2=A0 =C2=A0 =C2=A0(let ((here (point))) >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(unless (eobp) (forward-char)) >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(beginning-of-defun) >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (< (point) here) >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char here) >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(beginning-of-defun))) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq beg (point)) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0(end-of-defun) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq end (point)) > > This patch was apparently approved by Stefan, but not applied, as far as > I can tell. =C2=A0Did it turn out to not be correct after all? I think it was correct, but the problem is that I never submit anything to the repository. (Since I did not trust myself to make the submission in a correct way...)