unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: "Daniel Martín" <mardani29@yahoo.es>, emacs-devel@gnu.org
Subject: Re: Don't move to eol in end-of-defun?
Date: Mon, 1 Aug 2022 17:50:20 +0000	[thread overview]
Message-ID: <YugSXGHylcMYZ3nM@ACM> (raw)
In-Reply-To: <m2k07sud6n.fsf@fastmail.fm>

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 <fgunbin@fastmail.fm> 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).



  reply	other threads:[~2022-08-01 17:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 12:40 Don't move to eol in end-of-defun? Filipp Gunbin
2022-07-30 23:40 ` Daniel Martín
2022-07-31 22:31   ` Filipp Gunbin
2022-08-01 17:50     ` Alan Mackenzie [this message]
2022-08-01 20:49       ` Filipp Gunbin
2022-08-01 22:01       ` Filipp Gunbin
2022-08-03  3:46 ` Richard Stallman
2022-08-03 12:37   ` Filipp Gunbin
2022-08-04  4:04     ` Richard Stallman
2022-08-04 14:58       ` Filipp Gunbin
2022-08-06  3:41         ` Richard Stallman
2022-08-06  9:33           ` Alan Mackenzie
2022-08-07  4:24             ` Richard Stallman
2022-08-08 14:29               ` Filipp Gunbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YugSXGHylcMYZ3nM@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=mardani29@yahoo.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).