Emacs C++智能提示

來源:互聯網
上載者:User

Emacs中的C++程式智能提示是個不容易的活。我使用的是auto-completion外掛程式。該外掛程式依賴clang編譯器進行程式碼分析,當然還依賴其他的emacs外掛程式。下面是我的Emacs設定檔。

;;------------------------------------------------------------------------------;; auto complete;;------------------------------------------------------------------------------;;(load-file (expand-file-name "/opt/emacs_plugins/c++/auto-complete-1.3.1");;(add-to-list 'load-path "/opt");;(require 'auto-complete-config);;(add-to-list 'ac-dictionary-directories "/opt/ac-dict");;(ac-config-default)(add-to-list 'load-path "/opt/emacs_plugins/c++/auto-complete-1.3.1")(require 'auto-complete-config)(add-to-list 'ac-dictionary-directories "/opt/ac-dict");;------------------------------------------------------------------------------;; yasnippet;;------------------------------------------------------------------------------;;sudo apt-get install yasnippet(add-to-list 'load-path "/opt/emacs_plugins/c++")(add-to-list 'ac-dictionary-directories "/opt/emacs_plugins/c++")(require 'yasnippet-bundle);;------------------------------------------------------------------------------;; clang for c++;;------------------------------------------------------------------------------(load-file "/opt/emacs_plugins/c++/brianjcj-auto-complete-clang-9db79f4/auto-complete-clang.el")(require 'auto-complete-clang)(setq ac-auto-start nil)(setq ac-quick-help-delay 0.5)(define-key ac-mode-map  [(control tab)] 'auto-complete)(defun my-ac-config ()  (setq ac-clang-flags (split-string "-I/usr/local/gcc-4.6.1/include/c++/4.6.1 -I/usr/src/boost_1_47_0"))  (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))  (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)  ;;(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)  (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)  (add-hook 'css-mode-hook 'ac-css-mode-setup)  (add-hook 'auto-complete-mode-hook 'ac-common-setup)  (global-auto-complete-mode t))(defun my-ac-cc-mode-setup ()  (setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup);; ac-source-gtags(my-ac-config)

需要提示的時候,就按下Ctrl+Tab鍵。

http://felipetonello.com/blog/2011/06/07/awesome-c-cpp-auto-completion-in-emacs/

https://github.com/brianjcj/auto-complete-clang

以及我發的文章

https://github.com/brianjcj/auto-complete-clang/issues/2

歡迎提問和建議,讓我們一起把Emacs下的C++開發環境做好。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.