[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Don't move to eol in end-of-defun?
From: |
Alan Mackenzie |
Subject: |
Re: Don't move to eol in end-of-defun? |
Date: |
Mon, 1 Aug 2022 17:50:20 +0000 |
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).
- Re: Don't move to eol in end-of-defun?,
Alan Mackenzie <=
- Re: Don't move to eol in end-of-defun?, Richard Stallman, 2022/08/02
- Re: Don't move to eol in end-of-defun?, Filipp Gunbin, 2022/08/03
- Re: Don't move to eol in end-of-defun?, Richard Stallman, 2022/08/04
- Re: Don't move to eol in end-of-defun?, Filipp Gunbin, 2022/08/04
- Re: Don't move to eol in end-of-defun?, Richard Stallman, 2022/08/05
- Re: Don't move to eol in end-of-defun?, Alan Mackenzie, 2022/08/06
- Re: Don't move to eol in end-of-defun?, Richard Stallman, 2022/08/07
- Re: Don't move to eol in end-of-defun?, Filipp Gunbin, 2022/08/08