From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: beginning-of-defun (again) Date: Thu, 29 Oct 2015 14:14:03 +0000 Message-ID: <20151029141402.GD2510@acm.fritz.box> References: <56320200.4050503@online.de> <20151029124605.GC2510@acm.fritz.box> <56321791.8040809@online.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1446127964 3462 80.91.229.3 (29 Oct 2015 14:12:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Oct 2015 14:12:44 +0000 (UTC) Cc: emacs-devel@gnu.org To: Andreas =?iso-8859-1?Q?R=F6hler?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 29 15:12:33 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZrnwO-0007TT-O6 for ged-emacs-devel@m.gmane.org; Thu, 29 Oct 2015 15:12:32 +0100 Original-Received: from localhost ([::1]:44290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnwO-0002a6-2r for ged-emacs-devel@m.gmane.org; Thu, 29 Oct 2015 10:12:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnwE-0002Sg-V7 for emacs-devel@gnu.org; Thu, 29 Oct 2015 10:12:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrnwB-0004a5-NU for emacs-devel@gnu.org; Thu, 29 Oct 2015 10:12:22 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:44549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnwB-0004Zs-Cw for emacs-devel@gnu.org; Thu, 29 Oct 2015 10:12:19 -0400 Original-Received: (qmail 28115 invoked by uid 3782); 29 Oct 2015 14:12:17 -0000 Original-Received: from acm.muc.de (p548A58AB.dip0.t-ipconnect.de [84.138.88.171]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 29 Oct 2015 15:12:17 +0100 Original-Received: (qmail 3417 invoked by uid 1000); 29 Oct 2015 14:14:03 -0000 Content-Disposition: inline In-Reply-To: <56321791.8040809@online.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 193.149.48.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192902 Archived-At: Hello, Andreas On Thu, Oct 29, 2015 at 01:56:49PM +0100, Andreas Röhler wrote: > On 29.10.2015 13:46, Alan Mackenzie wrote: > > On Thu, Oct 29, 2015 at 12:24:48PM +0100, Andreas Röhler wrote: > >> Hi guys, > >> maybe it's time to have a reasonable default-behavior of > >> beginning-of-defun in Emacs Lisp. > >> IMO there is no reason for stuff like > >> open-paren-in-column-0-is-defun-start > > Unfortunately, there is. Setting it to nil ensures accurate recognition > > of non-nested parens, > Sorry, Alan, but if there is no syntax expecting a start in column 0, > there is no reason to assume that. > Relying on such means working in some cases, in other not. You won't > want that. Note that o-p-i-c-0-i-d-s being non-nil doesn't mean that this is the only way defun starts are recognised. It is an additional facility in addition to however else a major mode detects defun starts. > > though this can be slow, sometimes very slow. > > Setting it to non-nil makes it fast, but sometimes so inaccurate it > > looks like a bug. > >> A function resp. top-level-form starts if the beginning of a list is > >> followed by a respective keyword. > > Not necessarily: how does Emacs know whether something looking like a > > "top-level-form" is actually at the top level or not? > Top-level here is the beginning of a not nested list. > Remains to set the keywords more or less restrictive. Like I said, without that variable, Emacs scans all the way from the beginning of the buffer each time it needs to test the non-nestedness. Sometimes this is what you want, sometimes not. It's up to the user (or, perhaps, the writer of the major mode) to set o-p-i-c-0-i-d-s appropriately. > > When > > open-paren-in-column-0-is-defun-start is non-nil, it need scan no > > further back than the first such paren encountered. When > > o-p-i-c-0-i-d-s is nil, it must scan all the way from the beginning of > > the file. > >> The list of keywords being customizable seems a plus :) > > This would not work in all modes. > The default can't work in all modes but be reliable in Emacs Lisp. -- Alan Mackenzie (Nuremberg, Germany).