jschaf / powershell.el

An Emacs mode for editing and running Microsoft PowerShell code.
91 stars 30 forks source link

Tab-Completion #4

Open bluekeys opened 9 years ago

bluekeys commented 9 years ago

Is there any way to enable tab-completion when using the shell?

jschaf commented 9 years ago

There's some old commented-out tab completion code in powershell.el. I'll give it a whirl tomorrow and see if it works.

jschaf commented 9 years ago

There should be limited completion provided by cominit-dynamic-completion-functions. What does describe-key report for <tab>? Mine tab key is bound to completion-at-point.

As far as better powershell completion. I think that'll require calling out to PowerTab or PSReadline.

I'm a bit short on time right now but this would be a nice feature for sure.

bluekeys commented 9 years ago

I'm new to both emacs and powershell... This will take some thinking.

bluekeys commented 9 years ago

Only just got round to looking at this.

Here is the output from describe-key

<tab> runs the command yas-expand, which is an alias for
`yas-expand-from-trigger-key' in `yasnippet.el'.

It is bound to <tab>, <menu-bar> <YASnippet> <Expand trigger>.

(yas-expand &optional FIELD)

Expand a snippet before point. If no snippet
expansion is possible, call command `completion-at-point'.

Optional argument FIELD is for non-interactive use and is an
object satisfying `yas--field-p' to restrict the expansion to.

Running M-x completion-at-point isn't showing anything, but I'm new to emacs. So this could be slow and painful to watch.

jschaf commented 9 years ago

Just to confirm: you're having trouble getting tab completion in the *powershell* buffer, right? Tab completion while editing code in .ps1 file is a harder problem.

So, if yasnippet doesn't have anything to expand, it defaults to yas-fallback-behavior. What does C-h v say for yas-fallback-behavior. If it's call-other-command, that means it's using whatever was previously bound too, which is hopefully completion-at-point.

The reason M-x doesn't show anything for completion-at-point is because it's not interactive, meaning it's not a command, just a function for programmatic use. You can run non-interactive, regular functions in a buffer using eval-expression, bound to M-:

In your *powershell* buffer, with the point just after where you want to complete something, try the following: