unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: Richard Stallman <rms@gnu.org>
Cc: Alan Mackenzie <acm@muc.de>,  emacs-devel@gnu.org
Subject: Re: Don't move to eol in end-of-defun?
Date: Mon, 08 Aug 2022 17:29:50 +0300	[thread overview]
Message-ID: <m24jymolk1.fsf@fastmail.fm> (raw)
In-Reply-To: <E1oKXpc-0007IB-3m@fencepost.gnu.org> (Richard Stallman's message of "Sun, 07 Aug 2022 00:24:04 -0400")

On 07/08/2022 00:24 -0400, Richard Stallman wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > The problem is that e-o-d moves point somewhere else _before_ it calls
>   > end-of-defun-function, and that somewhere else can easily be in a
>   > different (nested) defun.
>
> Is there a case which is incorrect _now_?  If so, what case is it,
> and what happens now in that case?

Yes, my example from previous messages.

>   > I think Filipp is asking for the coding of end-of-defun to be revisited.
>
> Code can be changed if it is broken, but the question behind that
> needs to be, "What is the right thing in this case?"

It's not broken, but rather clearly wasn't intended for nested defuns.
AFAICS, cc-mode overrides beginning/end-of-defun completely.

In my mode, I implemented just beginning/end-of-defun-function, while
using standard beginning/end-of-defun functions, and it works well
except for this case (and, yes, one more rare bug during narrowing, I'm
yet to investigate it).

Currently cc-mode and my implementation for Java work differently: as
Alan said, cc-mode goes outside the enclosing block, while I stay
inside.  I find it convenient to think about nested things in this way:
C-M-a and C-M-e should behave as if we were narrowed to the current
enclosing block, like if its contained methods/whatever were top-level.

>   > In these circumstances, for C-M-a to go to the outermost "defun"
>   > wouldn't be useful.
>
> Yes, we do need to be able to have outer groupings which we designate
> as "does not count as a defun", so that things inside it which look like
> defuns do count as  defuns.
>
> This requires a way for the programmer to mark them so that C-M-a
> mostly ignores them.
>
> However, any old nested function definition shouldn't be treated as a
> defun.

In Java, you can have "local" classes, these are classes defined and
used inside a method:

class C {

  void foo() {
    class D {
      void bar() {
      }
    }

    D d = new D();
    ...
  }
}

So I chose to "honestly" parse & handle context right from the start.

Filipp



      reply	other threads:[~2022-08-08 14:29 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
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 [this message]

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=m24jymolk1.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /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).