From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Don't move to eol in end-of-defun? Date: Mon, 1 Aug 2022 17:50:20 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24600"; mail-complaints-to="usenet@ciao.gmane.io" To: Daniel =?iso-8859-1?Q?Mart=EDn?= , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 01 19:53:08 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIZbI-000699-Gn for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Aug 2022 19:53:08 +0200 Original-Received: from localhost ([::1]:53134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIZbH-00020d-Eq for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Aug 2022 13:53:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIZYs-0000S2-Hj for emacs-devel@gnu.org; Mon, 01 Aug 2022 13:50:38 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:33990 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1oIZYq-000467-KI for emacs-devel@gnu.org; Mon, 01 Aug 2022 13:50:38 -0400 Original-Received: (qmail 17995 invoked by uid 3782); 1 Aug 2022 17:50:22 -0000 Original-Received: from acm.muc.de (p4fe15d10.dip0.t-ipconnect.de [79.225.93.16]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 01 Aug 2022 19:50:22 +0200 Original-Received: (qmail 7367 invoked by uid 1000); 1 Aug 2022 17:50:20 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292955 Archived-At: Hello, Filipp. On Mon, Aug 01, 2022 at 01:31:28 +0300, Filipp Gunbin wrote: > On 31/07/2022 01:40 +0200, Daniel Martín wrote: > > Filipp Gunbin writes: > >> In Java, it's a common style to have hanging parentheses: > >> class C <1>{<2> > >> void foo() { > >> }<3> > >> }<4> > >> If we're at position <1> and press C-M-e, then it's logical to move to > >> <4>, and that's what I implement in javaimp package, by defining my own > >> beginning-of-defun-function / end-of-defun-function. Be aware that end-of-defun-function is broken. Before calling e-o-d-f, end-of-defun first moves point somewhere else and then calls it. That somewhere else could easily be in a different function. Say if you have class C <1>{ <2>void foo () { }<3> }<4> and start at <1>, that somewhere else is likely to be <2> from where your e-o-d-f will probably go to <3>. > > If I yank your sample program in a buffer in Java mode, with point at > > <1>, C-M-e goes to <4>, as expected. So I don´t know why you need to > > implement your own end-of-defun-function in your package. > I'd like to not rely on java-mode (part of cc-mode). Be further aware that in languages like Java, you can't do a fully accurate job without scanning braces back to BOB. CC Mode has its own c-end-of-defun function, which uses a cache of brace blocks, for the reasons in this post (amongst others). You're welcome to take stuff from it, if that might help. > Thanks. -- Alan Mackenzie (Nuremberg, Germany).