EMACS-DOCUMENT

=============>随便,谢谢

Emacs as C++ IDE - First Step: rtags

目录

For years, I have been battling hard to find an optimal setup on my Emacs. Finally, after sufficient patience I think I have found a tags setup that is not too crufty to navigate. I have visited rtags home page for long enough, I even watched the famous cmake-ide evangelist's video but never really figured out how to get my Emacs to behave with rtags.

Now, what I am doing requires to navigate a large C++ codebase like nobody's business and things were getting serious. So, I decided to spend the weekend looking closely into this.

At first, I wanted everything to work out of the box then I realized this was a pipe dream so I started the rdm server from terminal and ran the indexer from command line too (Gross!)

However, after enough digging and sifting through the following links here I have a working out of the box rtags/cmake-ide setup. I'm sharing the final output here. I am running Emacs 26.1 compiled from source.

Demo

emacs-rtags-helm.gif

First clone the rtags repo inside your ~/.emacs.d directory and build the repo based on the instructions provided in the rtags home page

(require 'rtags)
(cmake-ide-setup)
(add-hook 'c-mode-hook 'rtags-start-process-unless-running)
(add-hook 'c++-mode-hook 'rtags-start-process-unless-running)

(use-package rtags
 :ensure t
 :hook (c++-mode . rtags-start-process-unless-running)
 :config (setq rtags-completions-enabled t
        rtags-path "/home/manoj/.emacs.d/rtags/src/rtags.el"
        rtags-rc-binary-name "/home/manoj/.emacs.d/rtags/bin/rc"
        rtags-use-helm t
        rtags-rdm-binary-name "/home/manoj/.emacs.d/rtags/bin/rdm")
 :bind (("C-c E" . rtags-find-symbol)
     ("C-c e" . rtags-find-symbol-at-point)
     ("C-c O" . rtags-find-references)
     ("C-c o" . rtags-find-references-at-point)
     ("C-c s" . rtags-find-file)
     ("C-c v" . rtags-find-virtuals-at-point)
     ("C-c F" . rtags-fixit)
     ("C-c f" . rtags-location-stack-forward)
     ("C-c b" . rtags-location-stack-back)
     ("C-c n" . rtags-next-match)
     ("C-c p" . rtags-previous-match)
     ("C-c P" . rtags-preprocess-file)
     ("C-c R" . rtags-rename-symbol)
     ("C-c x" . rtags-show-rtags-buffer)
     ("C-c T" . rtags-print-symbol-info)
     ("C-c t" . rtags-symbol-type)
     ("C-c I" . rtags-include-file)
     ("C-c i" . rtags-get-include-file-for-symbol)))

(setq rtags-display-result-backend 'helm)