Emacs configuration details and C/C ++ ide full-featured configuration demonstration (with configuration file)

Source: Internet
Author: User

My Emacs Plugin:

Http://pan.baidu.com/share/link? Consumer id = 4196458904 & UK = 3708780105

Note:

1. Why not use ide instead of Emacs and Vim?

Daniel only uses these two tools, and I wait for the weak slag to be purely installed.

2. Why use Emacs instead of Vim?

I heard that the vim user JJ is short, and the Emacs user JJ is long, so I use Emacs.

(Emacs and VIM do not have good people. They are all personal preferences. Only hanging silk will argue about good or bad. Just like those who argue about win and Linux, you say win is good, XI daniu and professionals do not need to use it. He said that Linux is good and he can sell it. The programmer's life is in a hurry. unfamiliar people, who encounter conflicts between Emacs and Vim, who compete for the advantages and disadvantages of language, who compete for technology and sales, and those who both know and compete with Wu Mao cannot seek advice from them, correction is endless with sub-sections, thinking about arguing and making mistakes. People who are well-known in the city, not those who want to do big things)

3. The description of Emacs in this article is as follows:

-How to load the configuration file of Emacs.

-How to Write and organize the Emacs configuration file

-Basic general settings of Emacs

-Emacs plug-in extension configuration instructions

-Emacs Development Environment Configuration

4. This article will not explain how Emacs uses operations and lisp programming.

Let's talk less about things.

I. How to load the configuration file of Emacs

The core part of Emacs is an Emacs lisp interpreter, which is a dialect version of lisp. Configuring Emacs is actually an interpretation of the Emacs lisp configuration file by the lisp interpreter. The configuration of Emacs is actually to write the Emacs lisp configuration file. All Emacs configuration files use. el is a suffix (abbreviated as Emacs lisp ). emacs has a unified configuration file under "/home/your username. emacs is generally used to place some basic configuration content and reference the path of other configuration files.

Emacs initialization file (init file)
When starting Emacs, it usually tries to load a series of LISP programs from the initialization file. Emacs will find ~ /. Emacs ,~ /. Emacs. El or ~ /. Emacs. d/init. El (El is short for Emacs lisp ). Emacs can also have a default initialization file default. El, which can be located in any standard library search directory of Emacs. The library search directory of Emacs is defined by the load-PATH variable. In addition, emacs can also have a general configuration file (site-wide Startup File) that is effective to all users, known as the site-start.el, it can also be located in any standard library search directory of Emacs. If you want to know the content of the load-path, you can enter(print
load-path)
Then, move the cursor to the right parenthesis and run the statement using the shortcut key C-J (m-x eval-print-last-sexp, you can print the content of the load-path in the current buffer.

Emacs loads these configuration files in the order of site-start.el, initialization file, and finally the default initialization file default. El. When starting Emacs, you can use-Q or-no-init-file to prevent Emacs from loading the initialization file. If inhibit-default-init is set to T in the initialization file, emacs will not load default. el; finally, you can use-no-site-file to prevent Emacs from loading common configuration files.

Ii. Writing and organizing the Emacs configuration file

Compiling the Emacs configuration file is to compile the Emacs lisp file. The syntax follows the lisp language, and most of the configuration options are (Emacs variable Emacs style)

Such as this form (Emacs variable Emacs face)

Common Emacs variable options include set-Background-color, set-foreground-color, and column-number-mode... They all represent specific Emacs attribute styles, followed by set values.

For example:

                   (global-linum-mode 'linum-mode)                   ;;auto show row-num                   (partial-completion-mode 1)                   ;;use partial-completion                   (icomplete-mode 1)                    ;;use complete-completion                                    (display-time-mode 1);;

Where; is the annotation symbol, you can also use 'to annotate.

Among all Emacs configuration files, only. emacs does not use. El as the suffix, but it is also interpreted in the Emacs lisp file. You can write the configuration of various functions into an independent El file, and then include the El files in other files, and finally include the El files in the. emacs configuration file. If A. El contains B. El, you only need to include a. El in. emacs, which is the same as include in C.

According to the general habits, the. emacs file usually does not contain too much configuration information, and usually contains some information about the search path of Emacs.

Take my configuration as an example. emacs is placed under/home/Fenice/, and other El files are placed in/home/Fenice/. emacs. d/lisps/_ Emacs.

Therefore, you must first add an Emacs search path.

; Add plugin to Emacs
; Set the plug-in loading path
; Plugin directory ~ /. Emacs. d/lisp/_ Emacs/
(Add-to-list 'Load-path "~ /. Emacs. d/lisp/_ Emacs /")

You can also add plug-ins written by others to the path, for example

; Add the Emacs search path (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/install/ecb-2.40 ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/codepilot ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/emacs-eclim ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/icicles ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/gnuserv ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/install/cedet-1.0/common ")

After adding a search path, you must include a file before loading it at Emacs startup.

For example, to include the XXX. El file, you can (require 'xxx) or (load "XXX. El ")

III. Basic general settings of Emacs

You can download my configuration file and put the basic settings in/home/Fenice /. emacs. d/lisps/_ Emacs/base. in El, that is, the base under the folder _ Emacs. el

;; ========================================================== =================================== ;; Author: kevin_samuel (Sun Junyan); date:; update date ;; ========================================================== =================================== ;; set the font. The default value is monospace; Set-defalut-font; (set-default-font "monospace ") (set-default-font "-unknown-dejavu sans mono-normal-*-13-*-m-0-iso10646-1 ");; I personally feel that mono family fonts are suitable for general youth)

;;custom-set-variables;;set-color(set-background-color "black")  ;;use black-ground(set-foreground-color "white")  ;;use white-fore(set-face-foreground 'region "green") ;;(set-face-background 'region "blue") ;;

;; ========================================================== =================================== ;; Appearance settings ;; ========================================================== =================================== ;; remove the scroll bar (set-scroll-bar-mode nil); disable the enable screen (setq inhibit-startup-message T); disable the tool-bar-mode nil );; disable menu bar; (menu-bar-mode nil); remove alert-Bell (mouse-wheel-mode t) (Global-linum-mode 'linum-mode );; auto Show row-num; automatically load the row number (partial-completion-mode 1); use partial- Completion (icomplete-mode 1); Use complete-completion; highlight the current row; (require 'hl-line-settings );; you can change the cursor from square to a small bar; (require 'bar-cursor );; ========================================================== =================================== ;; ========================================================== =================================== ;; status Bar ;; ========================================================== =================================== ;; display time; (display-time) (display-time-mode 1 ); Display Settings, on the bar above minibuffer (setq display-time-24hr-format T); time in 24-hour format (setq display-time-day-and-date t );; time Display includes date and specific time; (setq display-time-use-mail-Icon T); Enable mail setting next to the time bar ;; (setq display-time-interval 10); how often is the time changed ?;; Display the column number (setq column-number-mode t); if no column shows the row number on the left, press F3 to display/hide the row number (require 'setnu) (setnu-mode t );; (Global-set-Key [F3] (Quote setnu-mode ));; display title bar % F buffer full path % P page percentage % L line number (setq frame-title-format "% F ");; ========================================================== =================================== ;; buffer ;; ========================================================== =================================== ;; setq default-line-Spaceing 4; Page width (setq default-fill-Column 60); default mode text-mode; (setq default-Major-mode 'text-mode); set delete record (setq kill-ring-max 200 );; end with a blank line; (setq require-Final-newline T); Enable syntax highlighting. (Global-font-lock-mode 1); select the highlighted area (transient-mark-mode t); smooth Page scrolling, scroll-margin 3 is close to the screen edge. The context is displayed. (setq scroll-margin 3 scroll-consrvatively 10000 );; show-Paren-mode t (setq show-Paren-style 'parentheses); mouse pointer to avoid cursor (mouse-avoidance-mode 'animate );; paste it at the cursor instead of the mouse pointer (setq mouse-yank-at-point t );; ========================================================== =================================== ;; echo area; ========================== ========================================================== ======================= ;; Setq visible-bell t; use y or n to ask (fset 'Yes-or-no-p' y-or-n-P );; setq resize-mini-Windows nil; recursive minibuffer (setq enable-recursive-minibuffers T); when M-x command is used, the key bound to the command will be displayed in 1 second (setq suggest-key-bindings-1); default ?;; ========================================================== =================================== ;; Editor settings ;; ========================================================== =================================== ;; do not generate backup files (setq make-backup-files nil); do not generate temporary files (setq-default make-backup-files nil); only render current screen syntax highlighting, speed Up Display (setq lazy-lock-defer-on-scrolling T); (setq font-lock-support-mode 'Lazy-lock-mode) (setq font-lock-maximum-decoration T); display the error information in the echo area (condition-case err (progn (require 'xxx )) (error (message "can't load XXX-mode % s" (cdr err); use X clipboard (setq X-select-enable-clipboard t );; set the content format of the clipboard to Firefox (set-clipboard-coding-system 'ctext); set the tab width to 4 (setq default-tab-width 4 );; set indent as follows; Use tab indent (setq indent-Tabs-mode t) (setq C-indent-Level 4) (setq C-continued-statement-offset 4) (setq C-brace-offset-4) (setq C-argdecl-indent 4) (setq C-label-offset-4) (setq C-Basic-offset 4) (Global-set-key "\ c-M" 'reindent-then-newline-and-indent)

This is part of my base. El file, so it won't be all pasted. However, remember that all the configuration files of Emacs are loaded into the lisp interpreter at startup. If there are too many configuration files or INS, the editor will become very slow, I have read an article that configures Emacs to the IDE development environment, which includes countless plug-ins. I configured the Emacs according to that article to start for 5 seconds (i5-3230 8g ), under normal circumstances, Emacs is enabled instantly. If it is necessary to be redundant, it would be better to use the IDE. emacs looks like it's just a waste of time, isn't it.

Iv. emacs plug-in extension configuration instructions

(1)

My Emacs configuration file

/Home/Fenice/. emacs

My Emacs configuration package

/Home/Fenice/. emacs. d/lisps/_ Emacs

The main function is called as follows (. emacs) to load the configuration file package.

; Read the script ;; ========================================================== = ;; bind the key (load "cykbd. el "); Basic Setting (load" base. el "); Expand setting (load" cyexpand. el "); ide frame setting; (load" addon. el "); Code setting for programming configuration (load" cycode. el ");; ==========================================================

My configuration file contains cycode. El. Why is it Cy code. El? This file is written by Chen Yang. All with the Cy prefix are.

For debugging, add the following content to cycode. El:

;; ========================================================== =================================== ;; GDB-UI configuration ;; ========================================================== ====================================( setq GDB-starter-Windows T) (load-library "multi-gud.el") (Load-library "multi-gdb-ui.el ")

The above contains two debugging plug-ins downloaded from the Internet to facilitate GDB debugging in Emacs.

(2) install the cedet plug-in. Download from the Internet. Cedet can perform syntax analysis in multiple languages, auto-completion, object-oriented design, UML drawing, and other functions, as well as engineering management functions, but it has never been used.

Reference: http://www.cnblogs.com/logicbaby/archive/2011/10/19/2217253.html

If you use my configuration file, you 'd better set/home/Fenice /. emacs. d/lisps/_ Emacs/install content is cleared, and cedet (My shared file contains a compressed package) is decompressed to the install directory, then install it according to the instructions in the install file in cedet. Add the path and configuration information in. emacs or cycode. El. The directory in my configuration file is ~ /. Emacs. d/lisps/_ Emacs/install/cedet-1.0/

To use this function, you must add

;; ========================================================== =========== ;; Cedet plug-in settings ;; ========================================================== ========== (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/install/cedet-1.0/speedbar ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/install/cedet-1.0/eieio ") (add-to-list 'Load-path "~ /. Emacs. d/lisps/_ Emacs/install/cedet-1.0/semantic "); load cedet ., copied from cedet install; see cedet/common/cedet.info for configuration details.

Finally, add it to the configuration file (in. emacs or another custom file, my cycode. El)

(Load-file "~ /. Emacs. d/lisps/_ Emacs/installation/cedet-1.0/common/cedet. el "); Enable Ede (project management) features (Global-Ede-mode 1); Enable Ede for a pre-existing C ++ project ;; (EDE-CPP-root-project "name": file "~ /Myproject/makefile "); enabling semantic (Code-parsing, smart completion) features; select one of the following:; * This enables the database and idle reparse engines ;; (semantic-load-enable-minimum-features); * This enables some tools useful for coding, such as summary mode; imenu support, and the semantic navigator ;; (semantic-load-enable-code-helpers); * This enables even more coding tools such as intelliisense mode; decoration mode, and stickyfunc mode (plus regular code helpers );; (semantic-load-enable-gaudy-code-helpers); * This enables the use of exuberent ctags if you have it installed .;; if you use C ++ templates or boost, you should not enable it .;; (semantic-load-enable-all-exuberent-ctags-support); or, use one of these two types of support .;; add support for new languges only via ctags .;; (semantic-load-enable-primary-exuberent-ctags-support); add support for using ctags as a backup parser .;; (semantic-load-enable-secondary-exuberent-ctags-support); Enable srecode (template Management) Minor-mode .;; (Global-srecode-minor-mode 1); values (semantic-load-enable-minimum-features) (semantic-load-enable-code-helpers );; (semantic-load-enable-guady-code-helpers); (semantic-load-enable-excessive-code-helpers) (semantic-load-enable-semantic-debugging-helpers) (Global-Ede-mode t); Code folding; (require 'semantic-tag-folding nil 'noerror) (Global-semantic-tag-folding-mode 1 );; define-key Semantic-tag-folding-mode-map (KBD "c --") 'semantic-tag-folding-fold-All) (define-key Semantic-tag-folding-mode-map (KBD "C-=") 'semantic-tag-folding-show-all );; define-key Semantic-tag-folding-mode-map (KBD "C-_") 'semantic-tag-folding-fold-block) (define-key Semantic-tag-folding-mode-map (KBD "C-+") 'semantic-tag-folding-show-block)

(3) For ease of use, the ECB plug-in can be used with cedet. The disadvantage is that these two plug-ins have slowed Emacs startup by 2 seconds.

Directly download ECB ~ /. Decompress the Emacs. d/lisps/Emacs/install directory. This is my directory. You can also customize the directory, but be sure to modify the path.

Add

;; ========================================================== =================================== ;; ECB configuration ;; ========================================================== =================================== ;; (require 'ecb); Enable ECB, M-X: ECB-activate (require 'ecb-autoloads); automatically starts ECB and does not display daily prompts ;; (require 'ecb); (setq ECB-auto-activate T) (setq ECB-tip-of-the-day nil) (require 'CC-mode) (C-set-offset 'inline-open 0) (C-set-offset 'friend'-) (C-set-offset 'substatement-open 0)

(4) The real auto-completion function is like the completion after visual assist is installed in Visual Studio in WINDOS.

Here we need two plug-ins-auto-complete and yasnippet. Install auto-complete first, download it, and place it in ~ /. Emacs. d/lisps/Emacs/install to decompress the package (you can also use your own directory to change the path), enter the decompressed directory, and enter the make command. Install yasnippet below, download and put it in ~ /. Emacs. d/lisps/Emacs/install directory, and decompress it. The following are the configurations of the two plug-ins:

;; ========================================================== =========================== ;; Load csflood ;; ========================================================== =========================( require 'xcs= );; ========================================================== =========================== ;; yasnippet configuration ;; ========================================================== =========================== ;; powerful, powerful template feature (require 'yasnippet); not yasnippet-bundle (YAS/initialize) (YAS/load-directory "~ /. Emacs. d/lisps/_ Emacs/install/yasnippet-0.6.1c/snippets "); Auto completion; (require 'auto-complete-config); (Ac-config-default)

(5) Key Binding

That is, set the Emacs shortcut key

All of my Key Binding settings are in the cykbd. El file. The following content includes compilation and debugging.

(Global-set-Key [F1] 'Manual-entry) (Global-set-Key [C-f1] 'info); F3 is the search string, alt + F3 close the current buffer (Global-set-Key [F3] 'grep-find) (Global-set-Key [M-f3] 'Kill-this-buffer );;. set a speedbar shortcut in Emacs (Global-set-Key [(F4)] 'speedbar-get-Focus); ctrl-f4, activation, ECB (Global-set-Key [C-f4] 'ecb-activate );; f5 display/hide toolbar for easy debugging (Global-set-Key [F5] 'tool-bar-mode); ctrl-F5 display/hide menu bar ;; m-x menu-bar-open (Global-set-Key [C-f5] 'menu-bar-mode) (Global-set-Key [F6] 'gdb); C-f7, set the compilation command; F7: save all the files and compile the current window file (defun Du-onekey-compile () "Save buffers and start compile" (interactive) (save-some-Buffers t) (switch-to-buffer-other-window "* Compilation *") (compile-command ))

(6) Many other elasticsearch extension files are included in cyexpand. El. However, many of them were not noticed by me. Note (load "cyexpand. El") in. emacs if not required.

(7) My configuration file contains an addon. el, this configuration plug-in can make Emacs look more like IDE, but because it is too ugly, so I am in. emacs injected it.

If using my profile http://pan.baidu.com/share/link? Consumer id = 4196458904 & UK = 3708780105

Download emacs_setting.tar.gz and follow the instructions in readme.txt. It is a little troublesome and can be explored carefully. Rename samuel_emacs to. emacs and put it under/home/yourusername /.

Decompress _emacs.d.tar.gz, rename it as. emacs. D, and put it under/home/yourusername /.

Note that you need to note out all unused configuration files. Otherwise, emacs will be as bloated as some ides. Relatively speaking, it is easier to configure Vim to ide. the great god Wu wrote an article about how to configure Vim to multiply IDE, but that is more complicated.

Related Article

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.