branch: master commit 7c5408c40929c1e51460f74eaf0108ed0ad31216 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
company-clang--start-process: Kill the existing process, if any Fixes to completions in this case. To repro: set idle delay to 0, then quickly type two chars. --- company-clang.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/company-clang.el b/company-clang.el index a8b0098..74846ea 100644 --- a/company-clang.el +++ b/company-clang.el @@ -201,12 +201,13 @@ or automatically through a custom `company-clang-prefix-guesser'." (goto-char (point-min)))))) (defun company-clang--start-process (prefix callback &rest args) - (let ((objc (derived-mode-p 'objc-mode)) - (buf (get-buffer-create "*clang-output*")) - ;; Looks unnecessary in Emacs 25.1 and later. - (process-adaptive-read-buffering nil)) - (if (get-buffer-process buf) - (funcall callback nil) + (let* ((objc (derived-mode-p 'objc-mode)) + (buf (get-buffer-create "*clang-output*")) + ;; Looks unnecessary in Emacs 25.1 and later. + (process-adaptive-read-buffering nil) + (existing-process (get-buffer-process buf))) + (when existing-process + (kill-process existing-process)) (with-current-buffer buf (erase-buffer) (setq buffer-undo-list t)) @@ -216,7 +217,7 @@ or automatically through a custom `company-clang-prefix-guesser'." (set-process-sentinel process (lambda (proc status) - (unless (string-match-p "hangup" status) + (unless (string-match-p "hangup\\|killed" status) (funcall callback (let ((res (process-exit-status proc))) @@ -228,7 +229,7 @@ or automatically through a custom `company-clang-prefix-guesser'." (unless (company-clang--auto-save-p) (send-region process (point-min) (point-max)) (send-string process "\n") - (process-send-eof process)))))) + (process-send-eof process))))) (defsubst company-clang--build-location (pos) (save-excursion