From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: beginning-of-defun (again) Date: Fri, 30 Oct 2015 10:29:58 +0100 Message-ID: <87twp8wvop.fsf@gmail.com> References: <56320200.4050503@online.de> <87twp951ug.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446197383 22076 80.91.229.3 (30 Oct 2015 09:29:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Oct 2015 09:29:43 +0000 (UTC) Cc: andreas.roehler@online.de, emacs-devel@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 30 10:29:42 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 1Zs60D-0002fT-Pb for ged-emacs-devel@m.gmane.org; Fri, 30 Oct 2015 10:29:41 +0100 Original-Received: from localhost ([::1]:49282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs60C-0005RZ-Ty for ged-emacs-devel@m.gmane.org; Fri, 30 Oct 2015 05:29:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs609-0005RT-UO for emacs-devel@gnu.org; Fri, 30 Oct 2015 05:29:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zs605-00089l-RP for emacs-devel@gnu.org; Fri, 30 Oct 2015 05:29:37 -0400 Original-Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:38431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs605-00089h-Kd; Fri, 30 Oct 2015 05:29:33 -0400 Original-Received: by wmeg8 with SMTP id g8so7188645wme.1; Fri, 30 Oct 2015 02:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=f5I1DVSA6ZT6LaB5F18muxDrThKniMz83uRVAXI3wZY=; b=07ERmcpfnzDuF6i4zCIi3AMdU16sz29Y3tOkwlXQ5tOEdwRX4RuudYs8iUNONyU55W x5clKsedo0ywpTZ/+Jf/oH0hgSB3d66sxvLUq+O4ZHaL/nOJUQpTMtD14BH+QLRz6vgR JtSalOAgNgaWgqOmHcQrQrVUkMwWRcWI3DQ+2eErVaEYJ8QuiUkpRw3tpJh0uhiV3xSw sQm/M3aGy8efUiRFtwqCtAfQ812tLmtDEWwrxIeuUZEz57NsHjGE6R0WmhORGFKRqNIe S2Eh7C1QED4ztudJnIEIXQtTrBcZuHWA2Hsx150jdWIHxrYBZ5FWpEFjYRY2MYvLbxwu 6rxQ== X-Received: by 10.28.51.78 with SMTP id z75mr2042441wmz.51.1446197373092; Fri, 30 Oct 2015 02:29:33 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id 184sm1942445wmk.10.2015.10.30.02.29.32 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 30 Oct 2015 02:29:32 -0700 (PDT) In-Reply-To: (John Wiegley's message of "Thu, 29 Oct 2015 19:20:00 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::230 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:192953 Archived-At: John Wiegley writes: >>>>>> Richard Stallman writes: > >> Is there a specific practical reason why it is important for the defuns in >> init.el not to start in column 0? > > They are within macros controlling whether they are evaluated or compiled or > not, based on available packages on the system. If they are within macros, they're data and not defuns in my mind. For me, a defun is a top-level expression with "(" at column 0. It doesn't even need to define something callable (like `defun' or `defmacro'), so a `defcustom' statement is a defun for purposes of `beginning-of-defun'. > I'm not particularly disturbed by the fact that beginning-of-defun doesn't > work for these functions, however. Nor it should, unless we hook up a static code analyzer to Emacs and make `beginning-of-defun' use that data: (defun semantic-beginning-of-defun () (interactive) (semantic-mode 1) (let ((tag-starts (mapcar (lambda (x) (semantic-tag-start x)) (cl-remove-if-not (lambda (x) (eq (semantic-tag-class x) 'function)) (semantic-fetch-tags)))) pt) (while (and tag-starts (< (car tag-starts) (point))) (setq pt (pop tag-starts))) (goto-char pt))) But it would be silly to use the above approach unless `semantic-fetch-tags' is made somehow very fast and very smart. The column 0 heuristic is a perfectly fine and fast alternative. Besides, guess where the above function would bring me from this situation (| is the point): (defun ...) (defvar ...) (defvar ...) (defvar ...|) Would anyone actually want that behavior on "C-M-a", which is basically (re-search-backward "(defun") at this point?