emacs-libvterm icon indicating copy to clipboard operation
emacs-libvterm copied to clipboard

Add vterm-dabbrev-expand

Open wigust opened this issue 4 years ago • 7 comments

This commit add dabbrev-expand as requested in #362

wigust avatar Sep 16 '20 22:09 wigust

Thanks for this PR. I am not sure if this is the best way to solve the problem. One issue I can see is that if one has autocompletion (e.g. in fish, or zsh with autocompletion) the thing at the point will be the entire command (even if part of it will be greyed out).

I suspect that what will happen is: say one wants to autocomplete "python", having typed "py", vterm-dabbrev-expand will yield pythonthon.

Possible ingredients we can use: dabbrev--last-expansion (where dabbrev is run in a cloned buffer), vterm-undo, vterm-send-C-w.

I don't have the solution, but I think we can find something more robust than your counting the number of characters and deleting them.

Can you please test vterm-dabbrev-expand on a terminal with autocompletion?

Sbozzolo avatar Sep 17 '20 01:09 Sbozzolo

Thanks for the review. I applied your suggestions. Now vterm-dabbrev-expand works greats in Fish shell with autocompletion.

wigust avatar Sep 17 '20 18:09 wigust

Thanks, I see some room for improvement, but overall I think the general strategy is good. Can you please explain why you need the check on thing-at-point in the second function?

Sbozzolo avatar Sep 27 '20 01:09 Sbozzolo

Could this be generalized to work with completion-at-point?

okamsn avatar Sep 27 '20 20:09 okamsn

@Sbozzolo thing-at-point is required in case you have a cursor after space, in which case vterm-dabbrev-expand completes a word after a matching word as dabbrev-expand, e.g. after space after "This" word the vterm-dabbrev-expand will complete buffer.

;; This buffer is for text that is not saved, and for Lisp evaluation.
...

@okamsn i don't see how completion-at-point could be used, because it only shows completion in a separate window. Maybe we could have a completion-at-point-functions, but I don't see the point to do so to replace current implementation.

wigust avatar Sep 29 '20 07:09 wigust

@okamsn i don't see how completion-at-point could be used, because it only shows completion in a separate window. Maybe we could have a completion-at-point-functions, but I don't see the point to do so to replace current implementation.

What I mean to ask is whether there is a way to make this insertion of text generally work for other commands too, such as completion-at-point? I found code to complete file names at point, and it would be nice to use in Vterm.

okamsn avatar Oct 01 '20 11:10 okamsn

What I mean to ask is whether there is a way to make this insertion of text generally work for other commands too, such as completion-at-point? I found code to complete file names at point, and it would be nice to use in Vterm.

completion-at-point and file name completion has nothing to do with dabbrev-expand and vterm-dabbrev-expand which tries to mimic dabbrev-expand.

wigust avatar Oct 01 '20 17:10 wigust