mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Add jupyter-completion-post-completion
method
This way kernel languages can override the default behavior. The default implementation expands the candidate snippet if one is available.
This commit is contained in:
parent
8ccd41fe89
commit
ab44407fdf
1 changed files with 11 additions and 5 deletions
|
@ -2030,16 +2030,22 @@ Use the `company-doc-buffer' to insert the results."
|
|||
(defun jupyter-completion--post-completion (arg status)
|
||||
"If ARG is a completion with a snippet, expand the snippet.
|
||||
Do this only if STATUS is sole or finished."
|
||||
(when (and (memq status '(sole finished))
|
||||
(get-text-property 0 'snippet arg))
|
||||
(when (and (require 'yasnippet nil t)
|
||||
(not yas-minor-mode))
|
||||
(when (memq status '(sole finished))
|
||||
(jupyter-completion-post-completion arg)))
|
||||
|
||||
(cl-defgeneric jupyter-completion-post-completion (candidate)
|
||||
"Called when CANDIDATE was selected as the completion candidate.
|
||||
The default implementation expands the snippet in CANDIDATE's
|
||||
snippet text property, if any, and if `yasnippet' is available."
|
||||
(when (and (get-text-property 0 'snippet candidate)
|
||||
(require 'yasnippet nil t))
|
||||
(unless yas-minor-mode
|
||||
(yas-minor-mode 1))
|
||||
;; Due to packages like smartparens
|
||||
(when (eq (char-after) ?\))
|
||||
(delete-char 1))
|
||||
(yas-expand-snippet
|
||||
(get-text-property 0 'snippet arg)
|
||||
(get-text-property 0 'snippet candidate)
|
||||
(save-excursion
|
||||
(forward-sexp -1)
|
||||
(point))
|
||||
|
|
Loading…
Add table
Reference in a new issue