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:
(ac-clang-filechanged))
(save-restriction
(widen)
(process-send-string proc "COMPLETION\n")
@@ -448,6 +453,27 @@
(ac-clang-send-cmdline-args ac-clang-completion-process)
(message "`ac-clang-cflags' should be a list of strings")))
;; NOTE: although auto-complete would filter the result for us, but when there's
;; a HUGE number of candidates avaliable it would cause auto-complete to
;; block. So we filter it uncompletely here, then let auto-complete filter
@@ -541,20 +567,29 @@
(setq ac-clang-status 'preempted)))
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)
;; NOTE: although auto-complete would filter the result for us, but when there's ;; a HUGE number of candidates avaliable it would cause auto-complete to ;; block. So we filter it uncompletely here, then let auto-complete filter @@ -541,20 +567,29 @@ (setq ac-clang-status 'preempted)))
(defun ac-clang-launch-completion-process ()
+)))
(set-process-filter ac-clang-completion-process 'ac-clang-filter-output) (set-process-query-on-exit-flag ac-clang-completion-process nil) ;; Pre-parse source code. (ac-clang-send-reparse-request ac-clang-completion-process)
(add-hook 'kill-emacs-hook 'ac-clang-shutdown-process nil t) (add-hook 'before-save-hook 'ac-clang-reparse-buffer)
(local-set-key (kbd ".") 'ac-clang-async-preemptive) diff -Nur emacs-clang-complete-async-master/src/msg_callback.h emacs-clang-complete-async-mastern/src/msg_callback.h --- emacs-clang-complete-async-master/src/msg_callback.h 2012-10-28 00:51:28.000000000 +0800 +++ emacs-clang-complete-async-mastern/src/msg_callback.h 2012-12-04 22:52:01.296830076 +0800 @@ -46,6 +46,7 @@ void completion_doCompletion(completion_Session session, FILE *fp); / COMPLETION _/ void completion_doSourcefile(completionSession session, FILE fp); / SOURCEFILE _/ void completion_doCmdlineArgs(completionSession session, FILE fp); / CMDLINEARGS _/ +void completion_doFileChanged(completionSession session, FILE fp); / FILECHANGED _/ void completion_doReparse(completionSession session, FILE fp); / REPARSE _/ void completion_doSyntaxCheck(completionSession session, FILE fp); / SYNTAXCHECK _/ void completion_doShutdown(completionSession session, FILE fp); / SHUTDOWN */ diff -Nur emacs-clang-complete-async-master/src/msg_dispatcher.c emacs-clang-complete-async-mastern/src/msg_dispatcher.c --- emacs-clang-complete-async-master/src/msg_dispatcher.c 2012-10-28 00:51:28.000000000 +0800 +++ emacs-clang-complete-async-mastern/src/msg_dispatcher.c 2012-12-04 22:52:01.296830076 +0800 @@ -17,6 +17,7 @@ {"COMPLETION", completion_doCompletion}, {"SOURCEFILE", completion_doSourcefile}, {"CMDLINEARGS", completion_doCmdlineArgs},
+/* Update command line arguments and source files passing to clang translation unit. Format