Golevka / emacs-clang-complete-async

An emacs plugin to complete C and C++ code using libclang
360 stars 71 forks source link

Patch, make clang_complete only one instance. #15

Closed cjacker closed 11 years ago

cjacker commented 11 years ago

I noticed that clang_complete server will be launched for every source buffer in emacs. When emacs opend too many source files, there are too many clang_complete server runs.

Here is a patch to enable it run only one instance and switch the buffer and files when you enter a new source buffer.

diff -Nur emacs-clang-complete-async-master/auto-complete-clang-async.el emacs-clang-complete-async-mastern/auto-complete-clang-async.el --- emacs-clang-complete-async-master/auto-complete-clang-async.el 2012-12-04 22:51:26.237823425 +0800 +++ emacs-clang-complete-async-mastern/auto-complete-clang-async.el 2012-12-04 22:52:26.942833706 +0800 @@ -1,4 +1,4 @@ -;;; auto-complete-clang-async.el --- Auto Completion source for clang for GNU Emacs +;;; auto-complete-clang-async-once.el --- Auto Completion source for clang for GNU Emacs

;; Copyright (C) 2010 Brian Jiang ;; Copyright (C) 2012 Taylan Ulrich Bayirli/Kammer @@ -6,6 +6,7 @@ ;; Authors: Brian Jiang brianjcj@gmail.com ;; Golevka(?) [https://github.com/Golevka] ;; Taylan Ulrich Bayirli/Kammer taylanbayirli@gmail.com +;; Cjacker cjacker@gmail.com ;; Many others ;; Keywords: completion, convenience ;; Version: 0 @@ -29,7 +30,7 @@ ;; Auto Completion source for clang. ;; Uses a "completion server" process to utilize libclang.

;; Also provides flymake syntax checking.

+;; Cjacker: Made clang-complete server only run once for one emacs instance, and change the source file internally ;;; Code:

@@ -396,9 +397,11 @@ (defvar ac-clang-completion-process nil) (defvar ac-clang-saved-prefix "")

-(make-variable-buffer-local 'ac-clang-status) -(make-variable-buffer-local 'ac-clang-current-candidate) -(make-variable-buffer-local 'ac-clang-completion-process) +(defvar current-clang-file "") + +;;(make-variable-buffer-local 'ac-clang-status) +;;(make-variable-buffer-local 'ac-clang-current-candidate) +;;(make-variable-buffer-local 'ac-clang-completion-process)

;;; ;;; Functions to speak with the clang-complete process @@ -423,6 +426,8 @@ (process-send-string proc "REPARSE\n\n")))

(defun ac-clang-send-completion-request (proc)

+(defun ac-clang-send-filechanged (proc)

+/* Update command line arguments and source files passing to clang translation unit. Format

Golevka commented 11 years ago

Thanks for the patch. I tried it and found no problem. This patch was applied to the newly created test branch.