drym-org / symex.el

An intuitive way to edit Lisp symbolic expressions ("symexes") structurally in Emacs
Other
271 stars 22 forks source link

eldoc not displaying docs in the echo area #137

Closed pbaille closed 2 months ago

pbaille commented 2 months ago

I noticed that eldoc is not displaying infos in the echo area when I am in symex mode.

It may be due to my particular setup though.

Here a video capture:

https://github.com/drym-org/symex.el/assets/4739483/27141686-9b22-4fe3-bff7-db44d7c285db

Does anyone have experience this too ?

countvajhula commented 2 months ago

I hadn't noticed this before, but I'm seeing the same behavior. It would be great to fix it.

From a quick look, I found this in the eldoc docs:

eldoc-message-commands is a variable defined in ‘eldoc.el’.

[...]

Documentation:
Commands after which it is appropriate to print in the echo area.
ElDoc does not try to print function arglists, etc., after just any command,
because some commands print their own messages in the echo area and these
functions would instantly overwrite them.  But ‘self-insert-command’ as well
as most motion commands are good candidates.
This variable contains an obarray of symbols; do not manipulate it
directly.  Instead, use ‘eldoc-add-command’ and ‘eldoc-remove-command’.

So maybe it is just a matter of (eldoc-add-command #'symex-go-forward) and so on in symex-initialize?

pbaille commented 2 months ago

I've just tried it and it seems to work as intended.

But adding every symex command using eldoc-add-command in initialize seems a bit verbose :) and more importantly will introduce a coupling that we should probably avoid. (each time a new command is introduced we will need to put it there)

Maybe we can automate this, introducing a symex-defcommand macro that would cons to a symex-commands list under the hood. Then we can (apply eldoc-add-command symex-commands) in initialize.

I am not sure about this, introducing a macro for such a simple purpose seems controversial...

countvajhula commented 2 months ago

Good point. I think we only need to do this for motions, so it's likely to be a set of at least approximately constant size (e.g. hjkl, fb, FB, C-f C-b, C-j, C-k, M-hjkl). But still, it would be better to have a macro.

As it happens, we do have such macros in the in-progress Symex 2.0 branch. But the symex-define-command macro defined there is only for commands that transform the code (mutate the buffer) in some way I believe. We could define a similar symex-define-motion macro in symex-traversals.el and replace all the defuns in that file with it. I think that should work. I'm not sure if symex-define-command should also include the eldoc fix or not. I suppose it couldn't hurt, what do you think?

FYI I plan to rebase the 2.0-integration branch soon to include your recent changes from the main branch 🙂

countvajhula commented 2 months ago

This was fixed by #138