embark icon indicating copy to clipboard operation
embark copied to clipboard

defun target finder matches too often

Open minad opened this issue 3 years ago • 4 comments

In our action keymaps we assume that defuns are expressions. However defuns match something else in text modes. Does it make sense to refine this, distinguish general defun-like targets and elisp-defuns which are expressions? We could also consider to restrict the defun target to elisp buffers only. Related #421.

minad avatar Dec 11 '21 20:12 minad

@oantolin What do you think about this? After we got #421 I am less concernced with this issue. My only remaining gripe is:

In our action keymaps we assume that defuns are expressions.

We have a type error :-P

minad avatar Dec 14 '21 19:12 minad

Also, most of the actions in the defun map only makes sense in Emacs Lisp buffers. So I think we probably should separate the defun target into several targets, but I think I need to through the list of actions to see which make sense in which modes to decide whether to just split it into Emacs Lisp vs everything else, or into 3: Emacs Lisp, other prog modes, non prog modes.

oantolin avatar Dec 16 '21 00:12 oantolin

Right. Three different modes make sense: elisp (possibly deriving from prog), prog and text.

However from a user perspective defuns in text modes don't make much sense. They are abused as some kind of navigational unit. Therefore one could also consider to drop support for text modes.

Also note that it is good to retain defun support in text modes but in the sense that the actions are acting on elisp defuns/expressions (org code snippets, literate code). I must admit that back then when I proposed defun/expression support I didn't really get this and did not consider that defun finders are overwritten and weirdly redefined in modes where defuns are not really defuns. My intention was just to support lisp defuns in literate text and I didn't think far enough.

minad avatar Dec 16 '21 00:12 minad

With this one ends up with:

  • elisp defun in elisp, which are also expressions
  • elisp defun in text (literate, org src blocks etc)
  • prog defuns (mode specific). This is a bit heretical but on could also consider dropping support since there are not many useful general actions. I am looking forward to treesitter which will change this. Then one will get much more general treesitter targets (in comparison to the limited defun target). There seems to be a lot of movement in this space. We should keep it in mind.
  • text defuns (nosense, at least the name :-P). Maybe drop support for this?

minad avatar Dec 16 '21 00:12 minad