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: Mon, 10 May 2010 16:51:11 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1273503420 9675 80.91.229.12 (10 May 2010 14:57:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 10 May 2010 14:57:00 +0000 (UTC) To: 6157@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 10 16:56:58 2010 connect(): No such file or directory Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OBUPf-0005rA-EI for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 May 2010 16:56:57 +0200 Original-Received: from localhost ([127.0.0.1]:55381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBUPd-0002IH-7W for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 May 2010 10:56:53 -0400 Original-Received: from [140.186.70.92] (port=39628 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBUPJ-0002DX-AD for bug-gnu-emacs@gnu.org; Mon, 10 May 2010 10:56:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OBUPD-0003zy-P1 for bug-gnu-emacs@gnu.org; Mon, 10 May 2010 10:56:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39641) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBUPD-0003zt-Mr for bug-gnu-emacs@gnu.org; Mon, 10 May 2010 10:56:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OBUKv-0005vZ-Ll; Mon, 10 May 2010 10:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lennart Borgman Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 May 2010 14:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 6157 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Emacs Bugs Original-Received: via spool by submit@debbugs.gnu.org id=B.127350311122776 (code B ref -1); Mon, 10 May 2010 14:52:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 May 2010 14:51:51 +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 1OBUKk-0005vJ-Sw for submit@debbugs.gnu.org; Mon, 10 May 2010 10:51:51 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBUKi-0005vE-Ud for submit@debbugs.gnu.org; Mon, 10 May 2010 10:51:49 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:53395) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OBUKe-00031D-2W for submit@debbugs.gnu.org; Mon, 10 May 2010 10:51:44 -0400 Original-Received: from [140.186.70.92] (port=60242 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBUKY-0007eH-T4 for bug-gnu-emacs@gnu.org; Mon, 10 May 2010 10:51:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OBUKS-00028J-H5 for bug-gnu-emacs@gnu.org; Mon, 10 May 2010 10:51:38 -0400 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:57283) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBUKS-00027z-CE for bug-gnu-emacs@gnu.org; Mon, 10 May 2010 10:51:32 -0400 Original-Received: by fxm9 with SMTP id 9so773394fxm.0 for ; Mon, 10 May 2010 07:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=y2bRoZuefgWbpQsk749baRVNCi0ZGdRFmpRCuA36vvk=; b=l27TlMZjqfZZFgSXKFltSZCWLuDX+Qc9+55cX+hxCU+vEvqypDjMNP87dSLXVqXH52 iRaGvdp5usQaTYo7mE96mkozDQaDrI9KJrS7JdBf8+HCsEcjJDQhkHSb2dHWw9saPHg5 MlToTYw4asaPHxTrqRMmQ9kF4bku7v9zNe7HE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=TthuDhHXQysdl6t12IVTfJCPh4N1REagcdNQkECXyvSeRVEieqjs8lQrYwUAy9FAUO MKJpsaPOyqp9aPegT6+ed2xwLC6msRciLyBhX+qNMvXDwXn8rqRooRxSSDlqhu3Qsn5D MjX0EUcKDPfTLovGqHtuZk9YMTj4ucaa1mHZQ= Original-Received: by 10.239.155.134 with SMTP id i6mr360673hbc.1.1273503091207; Mon, 10 May 2010 07:51:31 -0700 (PDT) Original-Received: by 10.239.164.81 with HTTP; Mon, 10 May 2010 07:51:11 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 10 May 2010 10:52:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36833 Archived-At: `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 === modified file 'lisp/emacs-lisp/lisp.el' --- trunk/lisp/emacs-lisp/lisp.el 2010-04-27 17:57:32 +0000 +++ patched/lisp/emacs-lisp/lisp.el 2010-05-10 14:21:59 +0000 @@ -438,7 +438,20 @@ ;; Try first in this order for the sake of languages with nested ;; functions where several can end at the same place as with ;; the offside rule, e.g. Python. - (beginning-of-defun) + + ;; Finding the start of the function is a bit problematic since + ;; `beginning-of-defun' when we are on the first character of + ;; the function might go to the previous function. + ;; + ;; Therefor we first move one character forward and then call + ;; `beginning-of-defun'. However now we must check that we did + ;; not move into the next function. + (let ((here (point))) + (unless (eobp) (forward-char)) + (beginning-of-defun) + (when (< (point) here) + (goto-char here) + (beginning-of-defun))) (setq beg (point)) (end-of-defun) (setq end (point))