Discussion:
Request for mode modifcation Cpp/Clang autocompletition
(too old to reply)
p***@gmail.com
2013-10-07 12:41:56 UTC
Permalink
Hi,
Who would be nice enough to help with the modification of emacs autocompletion helper using clang ( c++ compiler from Apple) parser Golevka's https://github.com/Golevka/emacs-clang-complete-async mode. It's the support for popular auto-complete mode https://github.com/auto-complete/auto-complete:

I have mainly two problems , which seems to be connected:

1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.

2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...

If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
w***@gmail.com
2013-10-08 07:34:35 UTC
Permalink
Hi,
For 1a), whether clang can parse your source code correctly? Golevka's helper mainly call clang's C API, so, if the header file can not be parsed, it is most likely to be caused by:
1). Clang can not parse your source code, especially when you are using a lot of c++ templates, or under MS Windows.
2). Not all INCLUDE Folder PATH are passed to clang. By ac-clang-cflags

For 1b). I have encountered the same problems. I solve this by only spawn the child process when I actually modified that c/c++ source code.

The configure mentioned in Golevka's mode's main page is:

(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)

I modified it to
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(add-hook 'first-change-hook
(lambda ()
(if (not ac-clang-completion-process)
(ac-clang-launch-completion-process)))
nil
t)
(yas-minor-mode 1) ;; enable yas, otherwise, it will error with "Exit the snippet first!"
)

So, normally, I only view some C/C++ files, after this change, it will not spawn child process. It will only spawn child process once I modified the source code. Once you have finished modify that file, and want to close that child process, you can "M-x revert-buffer".

Not sure about what happens to problem 2).
Post by p***@gmail.com
Hi,
1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.
2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...
If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
p***@gmail.com
2013-10-10 12:02:49 UTC
Permalink
Hi, I am half the way of using your solution. After modifing your patch, I get
autocompletition for my local files -- that is -- if I do C-x C-s on buffer than the clang-complete would launch . But opposite is for the Ogre3d's include header files -- it does not start processing them ... never ! Either I try to open C-x C-f or do revert-buffer on opened the clang-complete does not start. I cannot do C-x C-s as I do not own permissions on that file.
I don;t know how the 'first-change-hook behaves ...
From previous exp I know the Ogre3d header files are all >>crunchable << for clang-complete, so it's not the problem of binary ... btw the backtrace buffer remains silent , although I do debug-on-error .
Post by w***@gmail.com
Hi,
1). Clang can not parse your source code, especially when you are using a lot of c++ templates, or under MS Windows.
2). Not all INCLUDE Folder PATH are passed to clang. By ac-clang-cflags
For 1b). I have encountered the same problems. I solve this by only spawn the child process when I actually modified that c/c++ source code.
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)
I modified it to
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(add-hook 'first-change-hook
(lambda ()
(if (not ac-clang-completion-process)
(ac-clang-launch-completion-process)))
nil
t)
(yas-minor-mode 1) ;; enable yas, otherwise, it will error with "Exit the snippet first!"
)
So, normally, I only view some C/C++ files, after this change, it will not spawn child process. It will only spawn child process once I modified the source code. Once you have finished modify that file, and want to close that child process, you can "M-x revert-buffer".
Not sure about what happens to problem 2).
Post by p***@gmail.com
Hi,
1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.
2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...
If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
w***@gmail.com
2013-10-11 04:11:05 UTC
Permalink
Hi,
Yes, the 'first-change-hook' only runs when you actually change that file (for example, insert some characters, or save that file). So, it will not launch the child process, when you just read the Ogre3d's file.

And, you only need to do auto-complete for your local files, Right? If that is the case, you don't need to launch clang-complete.exe for those Ogre3d's header files. (Clang will parse those header files automatically, when you are editing your local cpp files which include those header files).
Post by p***@gmail.com
Hi, I am half the way of using your solution. After modifing your patch, I get
autocompletition for my local files -- that is -- if I do C-x C-s on buffer than the clang-complete would launch . But opposite is for the Ogre3d's include header files -- it does not start processing them ... never ! Either I try to open C-x C-f or do revert-buffer on opened the clang-complete does not start. I cannot do C-x C-s as I do not own permissions on that file.
I don;t know how the 'first-change-hook behaves ...
From previous exp I know the Ogre3d header files are all >>crunchable << for clang-complete, so it's not the problem of binary ... btw the backtrace buffer remains silent , although I do debug-on-error .
Post by w***@gmail.com
Hi,
1). Clang can not parse your source code, especially when you are using a lot of c++ templates, or under MS Windows.
2). Not all INCLUDE Folder PATH are passed to clang. By ac-clang-cflags
For 1b). I have encountered the same problems. I solve this by only spawn the child process when I actually modified that c/c++ source code.
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)
I modified it to
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(add-hook 'first-change-hook
(lambda ()
(if (not ac-clang-completion-process)
(ac-clang-launch-completion-process)))
nil
t)
(yas-minor-mode 1) ;; enable yas, otherwise, it will error with "Exit the snippet first!"
)
So, normally, I only view some C/C++ files, after this change, it will not spawn child process. It will only spawn child process once I modified the source code. Once you have finished modify that file, and want to close that child process, you can "M-x revert-buffer".
Not sure about what happens to problem 2).
Post by p***@gmail.com
Hi,
1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.
2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...
If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
p***@gmail.com
2013-10-11 07:30:53 UTC
Permalink
I; m on linux OpenSuse 12.4 and certainly clang-complete won't launch for Ogre3d headers either with orginal golevka script or with your modification. For the orginal it was triggered by opening header files, but it bloated the machine in the end . I do Ogre::Entity ent; ent-> ... end nothing pops up.
But with the old setup I managed to crunch and load that lib properly ...
There must be some way of telling Golevka to start processing those header files.
sincerly paul424.
Post by w***@gmail.com
Hi,
Yes, the 'first-change-hook' only runs when you actually change that file (for example, insert some characters, or save that file). So, it will not launch the child process, when you just read the Ogre3d's file.
And, you only need to do auto-complete for your local files, Right? If that is the case, you don't need to launch clang-complete.exe for those Ogre3d's header files. (Clang will parse those header files automatically, when you are editing your local cpp files which include those header files).
Post by p***@gmail.com
Hi, I am half the way of using your solution. After modifing your patch, I get
autocompletition for my local files -- that is -- if I do C-x C-s on buffer than the clang-complete would launch . But opposite is for the Ogre3d's include header files -- it does not start processing them ... never ! Either I try to open C-x C-f or do revert-buffer on opened the clang-complete does not start. I cannot do C-x C-s as I do not own permissions on that file.
I don;t know how the 'first-change-hook behaves ...
From previous exp I know the Ogre3d header files are all >>crunchable << for clang-complete, so it's not the problem of binary ... btw the backtrace buffer remains silent , although I do debug-on-error .
Post by w***@gmail.com
Hi,
1). Clang can not parse your source code, especially when you are using a lot of c++ templates, or under MS Windows.
2). Not all INCLUDE Folder PATH are passed to clang. By ac-clang-cflags
For 1b). I have encountered the same problems. I solve this by only spawn the child process when I actually modified that c/c++ source code.
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)
I modified it to
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(add-hook 'first-change-hook
(lambda ()
(if (not ac-clang-completion-process)
(ac-clang-launch-completion-process)))
nil
t)
(yas-minor-mode 1) ;; enable yas, otherwise, it will error with "Exit the snippet first!"
)
So, normally, I only view some C/C++ files, after this change, it will not spawn child process. It will only spawn child process once I modified the source code. Once you have finished modify that file, and want to close that child process, you can "M-x revert-buffer".
Not sure about what happens to problem 2).
Post by p***@gmail.com
Hi,
1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.
2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...
If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
p***@gmail.com
2013-10-12 11:10:30 UTC
Permalink
Here';s function from within the Golevka is launching the binary


(defun ac-clang-launch-completion-process-with-file (filename)
(setq ac-clang-completion-process
(let ((process-connection-type nil))
(apply 'start-process
"clang-complete" "*clang-complete*"
ac-clang-complete-executable
(append (ac-clang-build-complete-args)
(list filename)))))

Ok I got place where this mode launches binary ... can someone propose how I could modify that so it waits till the completition of other processes ?
AFAIK concurrency support is quite poor in elisp and emacs so :( ....
Post by p***@gmail.com
I; m on linux OpenSuse 12.4 and certainly clang-complete won't launch for Ogre3d headers either with orginal golevka script or with your modification. For the orginal it was triggered by opening header files, but it bloated the machine in the end . I do Ogre::Entity ent; ent-> ... end nothing pops up.
But with the old setup I managed to crunch and load that lib properly ...
There must be some way of telling Golevka to start processing those header files.
sincerly paul424.
Post by w***@gmail.com
Hi,
Yes, the 'first-change-hook' only runs when you actually change that file (for example, insert some characters, or save that file). So, it will not launch the child process, when you just read the Ogre3d's file.
And, you only need to do auto-complete for your local files, Right? If that is the case, you don't need to launch clang-complete.exe for those Ogre3d's header files. (Clang will parse those header files automatically, when you are editing your local cpp files which include those header files).
Post by p***@gmail.com
Hi, I am half the way of using your solution. After modifing your patch, I get
autocompletition for my local files -- that is -- if I do C-x C-s on buffer than the clang-complete would launch . But opposite is for the Ogre3d's include header files -- it does not start processing them ... never ! Either I try to open C-x C-f or do revert-buffer on opened the clang-complete does not start. I cannot do C-x C-s as I do not own permissions on that file.
I don;t know how the 'first-change-hook behaves ...
From previous exp I know the Ogre3d header files are all >>crunchable << for clang-complete, so it's not the problem of binary ... btw the backtrace buffer remains silent , although I do debug-on-error .
Post by w***@gmail.com
Hi,
1). Clang can not parse your source code, especially when you are using a lot of c++ templates, or under MS Windows.
2). Not all INCLUDE Folder PATH are passed to clang. By ac-clang-cflags
For 1b). I have encountered the same problems. I solve this by only spawn the child process when I actually modified that c/c++ source code.
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)
I modified it to
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(add-hook 'first-change-hook
(lambda ()
(if (not ac-clang-completion-process)
(ac-clang-launch-completion-process)))
nil
t)
(yas-minor-mode 1) ;; enable yas, otherwise, it will error with "Exit the snippet first!"
)
So, normally, I only view some C/C++ files, after this change, it will not spawn child process. It will only spawn child process once I modified the source code. Once you have finished modify that file, and want to close that child process, you can "M-x revert-buffer".
Not sure about what happens to problem 2).
Post by p***@gmail.com
Hi,
1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.
2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...
If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
p***@gmail.com
2013-10-14 16:45:20 UTC
Permalink
Finally I give up the Golevka and moved to brianjcj / auto-complete-clang which does use single clang-complete process. Golevka forked from brianjcj / auto-complete-clang in order to achieve async calls . It turns out that this does not block the emacs interface ( at least for Ogre3d , which is quite large). so sometimes multiprocesssing is not the best solution ...
Many thanks to anyone reading and helping in this thread.
Post by p***@gmail.com
Here';s function from within the Golevka is launching the binary
(defun ac-clang-launch-completion-process-with-file (filename)
(setq ac-clang-completion-process
(let ((process-connection-type nil))
(apply 'start-process
"clang-complete" "*clang-complete*"
ac-clang-complete-executable
(append (ac-clang-build-complete-args)
(list filename)))))
Ok I got place where this mode launches binary ... can someone propose how I could modify that so it waits till the completition of other processes ?
AFAIK concurrency support is quite poor in elisp and emacs so :( ....
Post by p***@gmail.com
I; m on linux OpenSuse 12.4 and certainly clang-complete won't launch for Ogre3d headers either with orginal golevka script or with your modification. For the orginal it was triggered by opening header files, but it bloated the machine in the end . I do Ogre::Entity ent; ent-> ... end nothing pops up.
But with the old setup I managed to crunch and load that lib properly ...
There must be some way of telling Golevka to start processing those header files.
sincerly paul424.
Post by w***@gmail.com
Hi,
Yes, the 'first-change-hook' only runs when you actually change that file (for example, insert some characters, or save that file). So, it will not launch the child process, when you just read the Ogre3d's file.
And, you only need to do auto-complete for your local files, Right? If that is the case, you don't need to launch clang-complete.exe for those Ogre3d's header files. (Clang will parse those header files automatically, when you are editing your local cpp files which include those header files).
Post by p***@gmail.com
Hi, I am half the way of using your solution. After modifing your patch, I get
autocompletition for my local files -- that is -- if I do C-x C-s on buffer than the clang-complete would launch . But opposite is for the Ogre3d's include header files -- it does not start processing them ... never ! Either I try to open C-x C-f or do revert-buffer on opened the clang-complete does not start. I cannot do C-x C-s as I do not own permissions on that file.
I don;t know how the 'first-change-hook behaves ...
From previous exp I know the Ogre3d header files are all >>crunchable << for clang-complete, so it's not the problem of binary ... btw the backtrace buffer remains silent , although I do debug-on-error .
Post by w***@gmail.com
Hi,
1). Clang can not parse your source code, especially when you are using a lot of c++ templates, or under MS Windows.
2). Not all INCLUDE Folder PATH are passed to clang. By ac-clang-cflags
For 1b). I have encountered the same problems. I solve this by only spawn the child process when I actually modified that c/c++ source code.
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process)
)
I modified it to
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(add-hook 'first-change-hook
(lambda ()
(if (not ac-clang-completion-process)
(ac-clang-launch-completion-process)))
nil
t)
(yas-minor-mode 1) ;; enable yas, otherwise, it will error with "Exit the snippet first!"
)
So, normally, I only view some C/C++ files, after this change, it will not spawn child process. It will only spawn child process once I modified the source code. Once you have finished modify that file, and want to close that child process, you can "M-x revert-buffer".
Not sure about what happens to problem 2).
Post by p***@gmail.com
Hi,
1a) Inability to parse Ogre3d header files
1b) Inability to parse any large library in general, because >>Golevka<< starts a separate process of "clang-complete " parser for each opened file, so the machine just gets bloated and hangs being out of memory,
The ideal would be to have the maximal number of process customzed, set by variable or whatever what is the nicest way of doing it in emacs.
2) Inability to cache the results: once I managed to parse the whole lib and have the tag-complete feature for every method or variable in Ogre3d. What for, if after session I lost the whole dictionary ! The autocomplete has some settings for caching the obtained results, but I am too dumb...
If someone would give some tips how do I approach that , I would be greatful ( and many people as well to get finally working autocompletion for C++ , which wouldn't be fooled by trickery the c++ library uses as for example CEDET/semantic) ...
Loading...