Skip to content

Commit

Permalink
fix interactive use of company-elm, fix error with company-mode initi…
Browse files Browse the repository at this point in the history
…alization when opening an empty file
  • Loading branch information
savuori committed Nov 21, 2015
1 parent 244c311 commit e0318eb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions elm-interactive.el
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ Runs `elm-reactor' first."
(end (match-end 0)))
(s-trim (buffer-substring-no-properties beg end)))))


(defun elm-oracle--completion-namelist (completions)
"Extract a list of identifier names from the COMPLETIONS alists."
(-map (lambda (candidate)
Expand Down Expand Up @@ -694,14 +695,17 @@ Add this function to your `elm-mode-hook'."
(defun company-elm (command &optional arg &rest ignored)
"Set up a company backend for elm."
(interactive (list 'interactive))
(let* ((prefix (elm-oracle--completion-prefix-at-point))
(completions (elm-oracle--get-completions-cached prefix)))
(case command
(interactive (company-begin-backend 'company-elm-backend))
(prefix prefix)
(doc-buffer (elm-oracle--completion-docbuffer completions arg))
(candidates (elm-oracle--completion-namelist completions))
(meta (elm-oracle--completion-signature completions arg)))))
(case command
(init t)
(interactive (company-begin-backend 'company-elm))
(t
(let* ((prefix (elm-oracle--completion-prefix-at-point))
(completions (elm-oracle--get-completions-cached prefix)))
(case command
(prefix prefix)
(doc-buffer (elm-oracle--completion-docbuffer completions arg))
(candidates (elm-oracle--completion-namelist completions))
(meta (elm-oracle--completion-signature completions arg)))))))


(provide 'elm-interactive)
Expand Down

0 comments on commit e0318eb

Please sign in to comment.