emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 7c5408c 57/78: company-clang--start-process: Kill the exis


From: Dmitry Gutov
Subject: [elpa] master 7c5408c 57/78: company-clang--start-process: Kill the existing process, if any
Date: Sun, 18 Feb 2018 07:40:26 -0500 (EST)

branch: master
commit 7c5408c40929c1e51460f74eaf0108ed0ad31216
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]