Emacs-23.2 usage

Source: Internet
Author: User

# + Options: Author: Nil timestamp: Nil Creator: Nil # IDE, auto-completion, cedet, intermediate use cedet to browse and edit C ++ code (continued) -use Emacs 23.2 built-in cedet # + begin_html Author: meteor Liu # + end_html ** preface today, the emacs-23.2 is released, the biggest change is integrated into the cedet, so with this continuation, we will introduce the differences between build in cedet and offical cedet, as well as alternative solutions for built-in cedet which lacks some functions. # + HTML: PS1: although the official release version is 1.0pre7, the built-in cedet uses the cedet-version command to check that the input is 1.0pre7, but I always feel that the built-in cedet is much slower than the official version. I guess the built-in cedet may not be upgraded to the release of 1.0pre7. PS2: the built-in cedet does not support the emacs-lisp language. ** Semantic configuration ** the official cedet is started through several functions such as semantic-load-enable-minimum-features. The built-in cedet adds a separate minor mode, that is, semantic-mode. You can use the (semantic-mode) command to enable or disable. (Semantic-mode) determines which minor modes are enabled using the semantic-default-submodes variable. The default semantic-default-submodes includes the following two minor modes: -Global-semantic-idle-scheduler-mode-global-semanticdb-minor-mode according to the (semantic-mode) documents, semantic-default-submodes can set the following minor modes: -Global-semanticdb-minor-mode-global-semantic-idle-scheduler-mode-global-semantic-idle-Summary-mode-global-semantic-idle-completions-mode-Global -semantic-Decoration-mode-global-semantic-Highlight-func-mode-global-semantic-stickyfunc-mode-global-semantic-MRU-bookmark-mode can be set as needed, for example, I have enabled the following four minor modes: # + begin_html
(Setq semantic-default-submodes '(Global-semantic-idle-scheduler-Mode
Global-semanticdb-minor-Mode
Global-semantic-idle-Summary-Mode
Global-semantic-MRU-bookmark-mode ))
(Semantic-mode 1)

# + End_html In addition, the "Source code parsers (semantic)" menu item is added under the Tools menu of the emacs-23.2, you can use this menu item to enable and disable semantic-mode, it has the same functions as the command (semantic-mode. In addition, there are other minor modes in the official cedet, which can be basically used now. For example, I also opened the following: # + begin_html
(Global-semantic-Highlight-edits-mode (if window-system 1-1 ))
(Global-semantic-show-unmatched-syntax-mode 1)
(Global-semantic-show-parser-state-mode 1)

# + End_html the settings of system-include-Dir are the same as before: # + begin_html
(Defconst user-include-dirs
(List ".." "../include" "../INC" "../common" "../Public"
".. /.. "".. /.. /Include "".. /.. /INC "".. /.. /common "".. /.. /Public "))
(Defconst win32-include-dirs
(List "C:/mingw/include"
"C:/mingw/include/C ++/3.4.5"
"C:/mingw/include/C ++/3.4.5/mingw32"
"C:/mingw/include/C ++/3.4.5/backward"
"C:/mingw/lib/GCC/mingw32/3.4.5/include"
"C:/program files/Microsoft Visual Studio/vc98/mfc/include "))
(Let (include-dirs user-include-dirs ))
(When (EQ system-type 'windows-NT)
(Setq include-dirs (append include-dirs win32-include-dirs )))
(Mapc (lambda (DIR)
(Semantic-add-system-include dir 'C ++-mode)
(Semantic-add-system-include dir 'C-mode ))
Include-dirs ))

# + End_html *** code jump and the official version of the same or with the semantic-Ia-fast-jump command, but directly using this command in the emacs-23.2 may report the following error: # + begin_html
Semantic-Ia -- fast-Jump-helper: Symbol's function definition is void: semantic-analyze-tag-References

# + End_html this may be an Emacs bug. The semantic-analyze-tag-references function is defined in semantic/analyze/refs. and semantic/IA. el writes (eval-when-compile (require 'semantic/analyze/refs), so this feature is not loaded at runtime. We need to load it ourselves: # + begin_html
(Require 'semantic/analyze/refs)

# + End_html In addition, after semantic-Ia-fast-Jump in the official cedet, you can run the semantic-mrub-switch-tags command to return to the previously redirected location, but in the emacs-23.2 will prompt: # + begin_example semantic bookmark ring is currently empty # + end_example this is because semantic-Ia-fast-jump will use the push-Mark Function to place the skipped place in the mark ring, cedet officially defines the advice of push-mark to put it in semantic-MRU-bookmark-ring, semantic-mrub-switch-tags is used to locate the position from semantic-MRU-bookmark-ring, but the advice of push-mark is removed from the cedet of build in, therefore, semantic-MRU-bookmark-ring is always empty. My solution is to copy the device of push-mark from the official cedet to my device. in Emacs: # + begin_html
(Defadvice push-mark (around semantic-MRU-bookmark activate)
"Push a mark at location with nomsg and activate passed to 'push-mark '.
If 'semantic-MRU-bookmark-mode' is active, also pushes a tag
The MRU bookmark stack ."
(Semantic-mrub-push semantic-MRU-bookmark-ring
(Point)
'Mark)
Ad-do-it)

# + End_html: the previously written semantic-Ia-fast-Jump-back function can also be used: # + begin_html
(Defun semantic-Ia-fast-Jump-back ()
(Interactive)
(If (Ring-empty-P (oref semantic-MRU-bookmark-ring ))
(Error "semantic bookmark ring is currently empty "))
(Let * (ring (oref semantic-MRU-bookmark-ring ))
(Alist (semantic-mrub-ring-to-assoc-list ring ))
(First (CDR (CAR alist ))))
(If (semantic-equivalent-tag-P (oref first tag) (semantic-current-tag ))
(Setq first (CDR (CAR (CDR alist )))))
(Semantic-mrub-switch-tags first )))

# + End_html: the user [[http://fangzhzh.blogs.mu/##fangzhzh#has mentioned that you can use c-u C-space to jump back to the original mark. [C-X to jump back, however, the two buttons seem to be a little messy and cannot match the position of semantic-Ia-fast-jump. I guess the two keys are the mark position of the push-mark function, and the push-mark function is not only used by cedet. My requirement is to only jump back to the place where semantic-Ia-fast-jump has been there, so I still keep this function. My habit is to bind to F12: # + begin_html
(Defun semantic-Ia-fast-Jump-or-back (& optional back)
(Interactive "p ")
(If back
(Semantic-Ia-fast-Jump-back)
(Semantic-Ia-fast-jump (point ))))
(Define-key Semantic-mode-map [F12] 'semantic-Ia-fast-Jump-or-back)
(Define-key Semantic-mode-map [C-f12] 'semantic-Ia-fast-Jump-or-back)
(Define-key Semantic-mode-map [S-f12] 'semantic-Ia-fast-Jump-back)

# + End_html here is an extra semantic-Ia-fast-Jump-or-back function, because I sometimes operate the remote Emacs in putty, Putty can not use the key of the S-f12, so I bound F12 to semantic-Ia-fast-Jump-or-back, so that I can use c-u F12 in Putty to jump back. The previous semantic-analyze-proto-impl-Toggle command can also be used: # + begin_html
(Define-key Semantic-mode-map [M-S-f12] 'semantic-analyze-proto-impl-Toggle)

# + End_html *** in the Code Completion official version, you can use the command semantic-Ia-complete-symbol-menu to pop up the semantic completion menu, however, this command does not exist in the built-in cedet (probably because the official version of Emacs thinks this command can only be used in the GUI, It is not general enough ). However, the built-in cedet can display possibly supplemented content in another buffer via the command complete-symbol (bound to the ESC-TAB by default), like this: # + begin_html

Semantic complete-Symbol

# + End_html if you want to use the completion menu, you can use other plug-ins, such as auto-complete or company-mode: Company-mode-0.5, to support the built-in cedet of Emacs; auto-complete-1.2 still has some questions about the built-in cedet support. I want to write an article about how to configure auto-complete-1.2 to support the built-in cedet. ** There is no difference between Ede configuration and the official version, and you can still enable it with (Global-Ede-mode t); however, "Project Support (EDE)" is added under the Tools menu of the emacs-23.3) "menu item to complete the same global-Ede-mode function. ** Other ** visual bookmarks visual-studio-bookmarks in cedet are missing in the built-in cedet. Therefore, I am using [[http://www.nongnu.org/bm/##bm. * ** The pulse function still exists in the built-in cedet, but the pulse-toggle-integration-advice function can be used in the official cedet to switch the pulse, this function disappears in the built-in cedet. The current method is to set the pulse-command-advice-flag variable to switch: # + begin_html
(Setq pulse-command-advice-flag (if window-system 1 nil ))

# + End_html In addition, the official version sets the pulse device for the following functions: -Goto-line-exchange-point-and-mark-find-tag-tags-search-tags-loop-continue-pop-tag-mark-imenu-default-Goto-Function none of these devices in the built-in versions, so I copied the advice in the official version directly: # + begin_html
(Defadvice goto-line (after pulse-advice activate)
"Cause the line that is 'Goto 'd to pulse when the cursor gets there ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice exchange-point-and-mark (after pulse-advice activate)
"Cause the line that is 'Goto 'd to pulse when the cursor gets there ."
(When (and pulse-command-advice-flag (Interactive-P)
(> (ABS (-(point) (Mark) 400 ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice find-tag (after pulse-advice activate)
"After going to a tag, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice tags-search (after pulse-advice activate)
"After going to a hit, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice tags-loop-continue (after pulse-advice activate)
"After going to a hit, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice pop-tag-mark (after pulse-advice activate)
"After going to a hit, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice imenu-default-Goto-function (after pulse-advice activate)
"After going to a tag, pulse the line the cursor lands on ."
(When pulse-command-advice-flag
(Pulse-momentary-Highlight-one-line (point ))))

# + End_html In addition, I also like to define pulse for the following functions: # + begin_html
(Defadvice Cua-exchange-point-and-mark (after pulse-advice activate)
"Cause the line that is 'Goto 'd to pulse when the cursor gets there ."
(When (and pulse-command-advice-flag (Interactive-P)
(> (ABS (-(point) (Mark) 400 ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice switch-to-buffer (after pulse-advice activate)
"After switch-to-buffer, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice previous-buffer (after pulse-advice activate)
"After previous-buffer, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice next-buffer (after pulse-advice activate)
"After next-buffer, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice Ido-switch-buffer (after pulse-advice activate)
"After Ido-switch-buffer, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))
(Defadvice beginning-of-buffer (after pulse-advice activate)
"After beginning-of-buffer, pulse the line the cursor lands on ."
(When (and pulse-command-advice-flag (Interactive-p ))
(Pulse-momentary-Highlight-one-line (point ))))

# + End_html *** H/CPP switch the eassist. El in the official cedet is gone, so eassist-switch-H-CPP is gone. Now I use [Export. * ** Code folding semantic-tag-folding.el no, but I did not find other better alternatives, so I copied the semantic-tag-folding.el in the official cedet, you only need to replace (require 'semantic-decorate-mode) with (require 'semantic/decorate/mode) in the file to use it as before. The previous Senator-fold-tag function can also be used. Finally insert an advertisement, my configuration for the built-in cedet (the last part): http://github.com/meteor1113/dotemacs/blob/master/init-basic.el

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.