function-args icon indicating copy to clipboard operation
function-args copied to clipboard

[feature request] Auto insert doxygen document snippets

Open zilongshanren opened this issue 10 years ago • 12 comments

Could you provide the feature in the following figure?

xx

zilongshanren avatar Mar 19 '15 08:03 zilongshanren

moo-doxygen already kind of does this. Could you give me a spec of what you want in a simple source code file, instead of the gif?

abo-abo avatar Mar 19 '15 08:03 abo-abo

@abo-abo Thanks for quick reply.

I have tried moo-doxygen, but it is very slow and relies on Semantic to parse my whole code base. And I never get it to work. I don't know why..

I'm using irony-mode and clang to provide auto completion for my c++ project. My code base is here: https://github.com/cocos2d/cocos2d-x It's a very large c++ code base. Irony-mode and company-irony seems promising and the completion speed is acceptable.

zilongshanren avatar Mar 19 '15 09:03 zilongshanren

Note that Semantic only parses once and subsequent invocations it won't block you again and does it precisely. However, if you don't want to depend on Semantic then you can try Doxymacs.

tuhdo avatar Mar 19 '15 09:03 tuhdo

@tuhdo Thanks for mentioning Doxymacs.

I don't notice Semantic will only parse the code base once. I will give Semantic another try in my spare time. Thanks.

zilongshanren avatar Mar 19 '15 09:03 zilongshanren

Hi @abo-abo I know you are also a c/c++ programmer, could you recommend me a auto completion framework for large c++ code base. Semantic or Irony? Could you give me some suggestions?

Thanks.

zilongshanren avatar Mar 19 '15 09:03 zilongshanren

@andyque, as can you see, I'm highly invested in CEDET. I'm not using irony since I'm a GCC supporter, so I can't endorse Clang until GCC goes under (hopefully, that will never happen:).

The advantage of CEDET is that it's highly hack-able. And once all the code is parsed (need to do this just once), CEDET speed is quite acceptable.

The main C++ library that I'm using is deal.II. It's got around 8000 files (more than cocos), and I'm satisfied with CEDET completion for it. You just need to get into the right mindset to make it work:

  • accept that you won't use ac-source-semantic, because it's too slow, and you don't really need it.
  • use CEDET completion (moo-complete) only when you need.

I still use auto-complete with the only source ac-source-words-in-same-mode-buffers. It's fast, although it's not aware of C++. So I call moo-complete in case when auto-complete doesn't pick up what I want.

abo-abo avatar Mar 19 '15 10:03 abo-abo

Thanks @abo-abo

In order to use moo-doxygen, I will definitely give CEDET a try. Last time I wasted my whole day configuring the CEDET for my cocos project and failed in the end.

zilongshanren avatar Mar 19 '15 10:03 zilongshanren

Here's my CEDET config:

(require 'semantic/bovine/c)
(add-to-list 'semantic-lex-c-preprocessor-symbol-file
             "/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h")
(add-to-list 'semantic-lex-c-preprocessor-symbol-file
             "/home/oleh/Software/deal.II/include/deal.II/base/config.h")
(add-to-list 'semantic-lex-c-preprocessor-symbol-file
             "/home/oleh/Software/DUNE/dune-crowd/config.h")
(mapc
 (lambda (x) (semantic-add-system-include x 'c++-mode))
 '("/home/oleh/Software/deal.II/include/"
   "/home/usr/local/trilinos/include/"
   "/usr/include/qt4"
   "/usr/local/boost_1_54_0/"
   "/home/oleh/Software/DUNE.2.3.1/dune-common-2.3.1"
   "/home/oleh/Software/DUNE.2.3.1/dune-geometry-2.3.1"
   "/home/oleh/Software/DUNE.2.3.1/dune-grid-2.3.1"
   "/home/oleh/Software/DUNE.2.3.1/dune-istl-2.3.1"
   "/home/oleh/Software/DUNE.2.3.1/dune-localfunctions-2.3.1"
   "/home/oleh/Software/DUNE.2.3.1/dune-pdelab-2.0.0"))
(set-default 'semantic-case-fold t)

It's basically nothing, I'm just making CEDET aware of where the include files are. I plan to publish my whole Emacs config sometime this month. Maybe I should clean up the above code a bit.

abo-abo avatar Mar 19 '15 10:03 abo-abo

Configuring CEDET is easy. At the minimum, just:

(semantic-mode 1)

If you want more features, enable it:

(add-to-list 'semantic-default-submodes 'global-semantic-mru-bookmark-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)

Now, if you have extra system include paths, add it:

(semantic-add-system-include "/usr/include/boot" 'c++-mode)

By default, Semantic sets the standard location such as /usr/include, /usr/local/include.. You probably don't want to add to many system include paths, that's when EDE is useful. EDE - Emacs Development Environment - is a generic interface for managing projects. In EDE, a project hierarchy matches a directory hierarchy. The project's topmost directory is called the project root, and its subdirectories are sub-projects. First, enable it:

(require 'ede)
(global-ede-mode)

Then,you can create a project and put in anywhere your Emacs loads when it starts:

(ede-cpp-root-project "project_root"
                      :file "/dir/to/project_root/Makefile"
                      ;; include paths related to the project root
                      :include-path '("/include1"
                                      "/include2")
                      ;; system include paths local to this project
                      :system-include-path '("~/linux"))

You may want to have a look at my C/C++ guide for different features other than code completion. Also have a look at my Semantic Stickyfunc Enhance.

tuhdo avatar Mar 19 '15 10:03 tuhdo

@tuhdo

You guide is really helpful, thanks very much.

BTW, does you configuration covers c++11?

zilongshanren avatar Mar 19 '15 12:03 zilongshanren

What kind of support for c++-11 do you want? You can write code in C++11 in Emacs as usual. I haven't spent time to learn all C++11 yet and I know Semantic can at least recognize a complete lambda function. If you write a lot of C++11 and want to have all completion candidates precisely, then maybe you need Irony for completion. But Semantic is sitll nice for other things too, as pointed out in my guide. For example, have a look at my package Semantic Refactor.

tuhdo avatar Mar 19 '15 14:03 tuhdo

@tuhdo I don use a lot c++11 feature in my daily work. Thanks, I will try your guide and Semantic Refactor.

zilongshanren avatar Mar 20 '15 16:03 zilongshanren