Cleanup robe processes killing last ruby buffer
Experimental?
This commit is contained in:
parent
f5f87ee0a3
commit
00d6e7b9ca
2 changed files with 19 additions and 3 deletions
15
modules/lang/ruby/autoload.el
Normal file
15
modules/lang/ruby/autoload.el
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
;;; lang/ruby/autoload.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +ruby|cleanup-robe-servers ()
|
||||||
|
"Clean up dangling inf robe processes if there are no more `enh-ruby-mode'
|
||||||
|
buffers open."
|
||||||
|
;; FIXME This should wait X seconds before cleaning up
|
||||||
|
(unless (or (not robe-mode) (doom-buffers-in-mode 'enh-ruby-mode))
|
||||||
|
(let (inf-buffer kill-buffer-query-functions)
|
||||||
|
(while (setq inf-buffer (robe-inf-buffer))
|
||||||
|
(let ((process (get-buffer-process inf-buffer))
|
||||||
|
confirm-kill-processes)
|
||||||
|
(when (processp process)
|
||||||
|
(kill-process (get-buffer-process inf-buffer))
|
||||||
|
(kill-buffer inf-buffer)))))))
|
|
@ -78,9 +78,10 @@ environment variables."
|
||||||
;; robe-start errors if you hit no.
|
;; robe-start errors if you hit no.
|
||||||
(defun +ruby|init-robe ()
|
(defun +ruby|init-robe ()
|
||||||
(when (executable-find "ruby")
|
(when (executable-find "ruby")
|
||||||
(cl-letf (((symbol-function #'yes-or-no-p)
|
(cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t)))
|
||||||
(lambda (&rest _) t)))
|
(ignore-errors (robe-start))
|
||||||
(ignore-errors (robe-start)))))
|
(when (robe-running-p)
|
||||||
|
(add-hook 'kill-buffer-hook #'+ruby|cleanup-robe-servers nil t)))))
|
||||||
(add-hook 'enh-ruby-mode-hook #'+ruby|init-robe)
|
(add-hook 'enh-ruby-mode-hook #'+ruby|init-robe)
|
||||||
:config
|
:config
|
||||||
(set-company-backend! 'robe-mode 'company-robe))
|
(set-company-backend! 'robe-mode 'company-robe))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue