Skip to main content
added 94 characters in body
Source Link
Tu Do
  • 6.9k
  • 23
  • 39

EDIT: Semantic Refactor requires at least Emacs 24.4 or latest CEDET to work properly.

EDIT: Semantic Refactor requires at least Emacs 24.4 or latest CEDET to work properly.

added 889 characters in body
Source Link
Tu Do
  • 6.9k
  • 23
  • 39
  1. You can use GNU Global with ggtags or helm-gtags. GNU Global can use cscope backend, but you should use its native backend for generating tag datdabase for C/C++ code. You can jump to definitions or references instantly, even for project as large as Linux kernel.

  2. You don't need to jump back to local definition to see the details. Simply using semantic-idle-summary-mode, it will show definition of any variable/function/class/struct at point like this:

    You can use GNU Global with ggtags or helm-gtags, which can be installed through MELPA. GNU Global can use cscope backend, but you should use its native backend for generating tag datdabase for C/C++ code. You can jump to definitions or references instantly, even for project as large as Linux kernel. Here is a demo of how you can select all available tags in your project:

semantic-idle-summary-modehelm-gtags-select

Following my ggtags or helm-gtags in my guide, you can jump to any definition with ggtags-find-tag-dwim or helm-gtags-dwim which is bound to M-. and jump back where you were with M-,.

  1. You don't need to jump back to local definition to see the details. Simply using semantic-idle-summary-mode, it will show definition of any variable/function/class/struct at point like this, automatically:

Demo 1:

semantic-idle-summary-mode1

Demo 2:

semantic-idle-summary-mode2

Demo 3:

semantic-idle-summary-mode3

As you can see in the screenshot, the function signature of find_if is shown in the minibuffer.

If you just want to try before going through all installation and configuration, use my demo Emacs kit made for the guide:

git clone https://github.com/tuhdo/emacs-c-ide-demo.git ~/.emacs.d
  1. You can use GNU Global with ggtags or helm-gtags. GNU Global can use cscope backend, but you should use its native backend for generating tag datdabase for C/C++ code. You can jump to definitions or references instantly, even for project as large as Linux kernel.

  2. You don't need to jump back to local definition to see the details. Simply using semantic-idle-summary-mode, it will show definition of any variable/function/class/struct at point like this:

semantic-idle-summary-mode

As you can see in the screenshot, the function signature of find_if is shown in the minibuffer.

  1. You can use GNU Global with ggtags or helm-gtags, which can be installed through MELPA. GNU Global can use cscope backend, but you should use its native backend for generating tag datdabase for C/C++ code. You can jump to definitions or references instantly, even for project as large as Linux kernel. Here is a demo of how you can select all available tags in your project:

helm-gtags-select

Following my ggtags or helm-gtags in my guide, you can jump to any definition with ggtags-find-tag-dwim or helm-gtags-dwim which is bound to M-. and jump back where you were with M-,.

  1. You don't need to jump back to local definition to see the details. Simply using semantic-idle-summary-mode, it will show definition of any variable/function/class/struct at point like this, automatically:

Demo 1:

semantic-idle-summary-mode1

Demo 2:

semantic-idle-summary-mode2

Demo 3:

semantic-idle-summary-mode3

As you can see in the screenshot, the function signature of find_if is shown in the minibuffer.

If you just want to try before going through all installation and configuration, use my demo Emacs kit made for the guide:

git clone https://github.com/tuhdo/emacs-c-ide-demo.git ~/.emacs.d
Source Link
Tu Do
  • 6.9k
  • 23
  • 39

You can check my C/C++ guide for all the needs above:

  1. You can use GNU Global with ggtags or helm-gtags. GNU Global can use cscope backend, but you should use its native backend for generating tag datdabase for C/C++ code. You can jump to definitions or references instantly, even for project as large as Linux kernel.

  2. You don't need to jump back to local definition to see the details. Simply using semantic-idle-summary-mode, it will show definition of any variable/function/class/struct at point like this:

semantic-idle-summary-mode

As you can see in the screenshot, the function signature of find_if is shown in the minibuffer.

You can also keep the definition of current function always visible at the top like this:

semantic-sticky-func-mode

To enable those features, add this configuration to your init file (either ~/.emacs or ~/.emacs.d/init.el:

(semantic-mode 1)
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode)

You can use highlight-symbol (you can install from MELPA to highlight and jump back and forth occurrences of the same symbol in buffer with the following configuration:

(require 'highlight-symbol)

(highlight-symbol-nav-mode)

(add-hook 'prog-mode-hook (lambda () (highlight-symbol-mode)))
(add-hook 'org-mode-hook (lambda () (highlight-symbol-mode)))

(setq highlight-symbol-idle-delay 0.2
      highlight-symbol-on-navigation-p t)

(global-set-key (kbd "M-n") 'highlight-symbol-next)
(global-set-key (kbd "M-p") 'highlight-symbol-prev)

After that, you can jump back and forth with M-p and M-n

  1. Use GNU Global to look thins up. It just works.

You may want to check Semantic Refactor, a package for common refactoring tasks (i.e. rename local variables easy and precisely, extract a piece of code into a separate function...). Here are the demos