copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.79k stars 126 forks source link

Assigned key maps aren't working inside YASnippet field #159

Closed daedsidog closed 1 year ago

daedsidog commented 1 year ago

I have the following key maps:

(define-key copilot-completion-map (kbd "S-SPC") 'copilot-accept-completion-by-word)
(define-key copilot-completion-map (kbd "S-RET") 'copilot-accept-completion-by-line)
(define-key copilot-completion-map (kbd "S-<return>") 'copilot-accept-completion-by-line)
(define-key copilot-completion-map (kbd "M-]") 'copilot-next-completion)
(define-key copilot-completion-map (kbd "M-[") 'copilot-previous-completion)

When completing normally in Org mode, doing C-h k S-SPC during the completion prompt correctly says that

S-SPC runs the command copilot-accept-completion-by-word (found in
copilot-completion-map), which is an interactive byte-compiled Lisp
function in ‘copilot.el’.

It is bound to S-SPC.

(copilot-accept-completion-by-word &optional N)

Not documented.

but when inside a YASnippet field, doing the same results in

SPC (translated from S-SPC) runs the command org-self-insert-command
(found in org-mode-map), which is an interactive byte-compiled Lisp
function in ‘org.el’.

It is bound to SPC..~, €.. .

(org-self-insert-command N)

Like ‘self-insert-command’, use overwrite-mode for whitespace in tables.
If the cursor is in a table looking at whitespace, the whitespace is
overwritten, and the table is not marked as requiring realignment.

I can work around this issue by mapping my keys to copilot-mode-map instead of copilot-completetion-map, but I would prefer to avoid this because I do want S-SPC to be translated to SPC when the completion overlay is inactive. Note that I used S-SPC here as an example, but this issue appears in all my key mappings.

Any solution? Why does this happen?

zerolfx commented 1 year ago

Can you try to increase the priority property of copilot's overlay? If it helps, I can make it configurable.

https://github.com/zerolfx/copilot.el/blob/4f83577b3a3c120e9b1063b5a793c20a6ed9ece0/copilot.el#L499C50-L499C50

daedsidog commented 1 year ago

Can you try to increase the priority property of copilot's overlay? If it helps, I can make it configurable.

https://github.com/zerolfx/copilot.el /blob/4f83577b3a3c120e9b1063b5a793c20a6ed9ece0/copilot.el#L499C50-L499C50

Changing the priority to be in the thousands, and then in the millions, had no effect. Note that yas-overlay-priority is set to 100 as well. But is this the issue? It seems like its Org's maps that are busting my key bindings, not YASnippet.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.