bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-ma


From: Tassilo Horn
Subject: bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-marker-p return) in eglot--post-self-insert-hook
Date: Sun, 23 Jul 2023 09:21:54 +0200
User-agent: mu4e 1.11.10; emacs 30.0.50

João Távora <joaotavora@gmail.com> writes:

Hi João,

> Even before Stefan answers, 'last-command-event' sounds right to me.
> In latest master, I've replaced the previous hacky solution with a
> simplified one based on this 'last-command-event' and it doesn't need
> any translation and works correctly on both TTY and GUI Emacs.
>
> Tassilo, can you test?

I can say at least that the error is gone.  Thank you!

(The below isn't actually related to the bug but to the feature the code
is providing.)

And now I also looked what that code is actually doing: you do
eglot-format after some trigger characters which seem to be queried from
the LS.  In my case of rust-analyzer, that seems to be

  (:firstTriggerCharacter "=" :moreTriggerCharacter ["." ">" "{"])

eglot-format works good in that buffer and seems to do exactly what
rustfmt also does.  Here I have a problem with rust-ts-mode which seems
to have a sightly different idea about the indentation of some
constructs, e.g., eglot-format and rustfmt say this is "correct"

    fn is_prev_next_window_variant(&self) -> bool {
        matches!(
            self,
            SwayrCommand::NextWindow { .. }
                | SwayrCommand::PrevWindow { .. }
                | SwayrCommand::NextTiledWindow { .. }
                | SwayrCommand::PrevTiledWindow { .. }
                | SwayrCommand::NextTabbedOrStackedWindow { .. }
                | SwayrCommand::PrevTabbedOrStackedWindow { .. }
                | SwayrCommand::NextFloatingWindow { .. }
                | SwayrCommand::PrevFloatingWindow { .. }
                | SwayrCommand::NextWindowOfSameLayout { .. }
                | SwayrCommand::PrevWindowOfSameLayout { .. }
                | SwayrCommand::NextMatchingWindow { .. }
                | SwayrCommand::PrevMatchingWindow { .. }
        )
    }

while rust-ts-mode prefers this:

    fn is_prev_next_window_variant(&self) -> bool {
        matches!(
            self,
            SwayrCommand::NextWindow { .. }
            | SwayrCommand::PrevWindow { .. }
            | SwayrCommand::NextTiledWindow { .. }
            | SwayrCommand::PrevTiledWindow { .. }
            | SwayrCommand::NextTabbedOrStackedWindow { .. }
            | SwayrCommand::PrevTabbedOrStackedWindow { .. }
            | SwayrCommand::NextFloatingWindow { .. }
            | SwayrCommand::PrevFloatingWindow { .. }
            | SwayrCommand::NextWindowOfSameLayout { .. }
            | SwayrCommand::PrevWindowOfSameLayout { .. }
            | SwayrCommand::NextMatchingWindow { .. }
            | SwayrCommand::PrevMatchingWindow { .. }
        )
    }

I actually like the rust-ts-mode variant better but don't find a
(stable) knob in the rustfmt.config to make it agree.  Anyway, I have no
strong preference but frequently produce such needless whitespace
changes during editing (which, of course, cargo fmt will "repair").

So is there a way to stop the indentation wars?  Maybe if I could make
it so that return and tab would also be considered as trigger characters
for eglot-format?

Bye,
Tassilo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]