[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: |
Sat, 6 Aug 2022 09:33:39 +0000 |
Hello, Richard.
On Fri, Aug 05, 2022 at 23:41:39 -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. ]]]
> > We have nested defuns here.
> A "defun" in Emacs is not the same thing as a function definition
> (or class definition).
> class C {
> void foo() {
> }
> }
> has two nested definitions, but only the outermost one counts as a
> defun in Emacs parlance.
> A defun is a construct which is top-level, or appears locally to be.
> In Lisp that usually means an open-paren in column 0. In some other
> languages, there are other ways to find defuns.
> > I just want to make movement to eol conditional, with default value
> > meaning "like before", to not break anything.
To clarify, Filipp's problem is the current implementation of
end-of-defun in lisp/emacs-lisp/lisp.el. There are two alternatives in
this function. Either it moves up the parenthesis structure, like for
Emacs Lisp Mode, or it calls the mode specific function
end-of-defun-function instead.
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.
I think Filipp is asking for the coding of end-of-defun to be revisited.
> Doing it that way might be ok. At any rate, no disaster. But it
> leaves the question, should we really try to support nested defuns?
> It is a can of worms.
CC Mode has supported these nested defuns for many years, now.
For example, in C++, it is common for a source file to begin with
namespace foo {
, and the rest of the functions/methods/classes in the file to be
enclosed within that namespace.
In these circumstances, for C-M-a to go to the outermost "defun"
wouldn't be useful. CC Mode has C-M-a moving to the previous start of
defun at the current level of namespace/class/struct nesting, or the
next level outwards when we bump up against the defining
namespace/class/struct start. C-M-e works likewise.
This works well, and there have been remarkably few bug reports about it
(I can't actually remember any).
> --
> Dr Richard Stallman (https://stallman.org)
> Chief GNUisance of the GNU Project (https://gnu.org)
> Founder, Free Software Foundation (https://fsf.org)
> Internet Hall-of-Famer (https://internethalloffame.org)
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Don't move to eol in end-of-defun?, Alan Mackenzie, 2022/08/01
- 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 <=
- 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