Skip to content

Commit

Permalink
emacs-company: use named function in emacs-company kill-emacs-hook
Browse files Browse the repository at this point in the history
Merge pull request mdempsky#104 from dakra/emacs-company-named-kill-hook-function
  • Loading branch information
stamblerre authored Feb 3, 2019
2 parents be056ad + f531cad commit 7fb6523
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions emacs-company/company-go.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
(require 'go-mode)
(require 'company)

;; Close gocode daemon at exit unless it was already running
(eval-after-load "go-mode"
'(progn
(let* ((user (or (getenv "USER") "all"))
(sock (format (concat temporary-file-directory "gocode-daemon.%s") user)))
(unless (file-exists-p sock)
(add-hook 'kill-emacs-hook #'(lambda ()
(ignore-errors
(call-process company-go-gocode-command nil nil nil "close"))))))))

(defgroup company-go nil
"Completion back-end for Go."
Expand Down Expand Up @@ -68,6 +59,20 @@ symbol is preceded by a \".\", ignoring `company-minimum-prefix-length'."
:group 'company-go
:type 'string)


(defun company-go--close-daemon ()
"Close gocode daemon."
(ignore-errors
(call-process company-go-gocode-command nil nil nil "close")))

;; Close gocode daemon at exit unless it was already running
(eval-after-load "go-mode"
'(progn
(let* ((user (or (getenv "USER") "all"))
(sock (format (concat temporary-file-directory "gocode-daemon.%s") user)))
(unless (file-exists-p sock)
(add-hook 'kill-emacs-hook #'company-go--close-daemon)))))

(defun company-go--invoke-autocomplete ()
(let ((code-buffer (current-buffer))
(gocode-args (append company-go-gocode-args
Expand Down

0 comments on commit 7fb6523

Please sign in to comment.