Emacs Configuration details and c/c++ide full function configuration demo (with configuration file) __c++

Source: Internet
Author: User

My emacs plugin Download address: http://pan.baidu.com/share/link?shareid=4196458904&uk=3708780105

Description

1. Why use Emacs and Vim without using the IDE.

Daniel only uses these two kinds of tools, I wait for the weak slag is pure outfit ratio.

2. Why use Emacs when you abandon vim?

I heard that with Vim's person JJ short, the man with Emacs is long, so I use Emacs.

(Emacs and Vim no one good who bad, is entirely a person's preference, only hanging wire will argue good or bad, like the controversy between win and Linux people, you say win well, cherish Daniel and professionals do not, he said Linux good, have the ability to sell AH. Programmer's life time is hurried, strange person, inattention Emacs and Vim contend, language pros and cons, technology and sales competition, the public know and five cents, all can not be with their plans, correction and the bar and the endless, think in the mouth of the argument and not real, all the people who do not seek the big things Also

3. The description of Emacs in this article has

-emacs How to load a configuration file.

How-emacs configuration files are written and organized

Basic general settings for-emacs

-emacs Plug-in Extension configuration instructions

-EMACS Development Environment Configuration

4. This article will not explain Emacs usage and Lisp programming



Gossip less, to the point

One. Emacs How to load a configuration file

The core of Emacs is an Emacs Lisp interpreter, and Emacs Lisp is a dialect version of Lisp. Configuring Emacs, in fact, is the LISP interpreter that interprets the Emacs Lisp configuration file. And our configuration of Emacs is actually writing the Emacs Lisp configuration file. All emacs profiles are suffix. El (Emacs Lisp). Emacs has a unified configuration file under "/home/your username/". Emacs, which is typically used to place some basic configuration content and a path reference to other configuration files.

Emacs Initialization File (Init file)
Emacs typically attempts to load an explanation of a series of Lisp programs from an initialization file when it is started. Emacs looks for one of the ~/.emacs,~/.emacs.el or ~/.emacs.d/init.el (el is actually the abbreviation for Emacs Lisp). Emacs can also have a default initialization file Default.el, which can be located under any standard library search directory in Emacs, where Emacs's Library search directory is defined by the Load-path variable. In addition, Emacs can have a common configuration file (site-wide startup file) that works for all users, called Site-start.el, and can also be located in any standard library search directory in Emacs. If you want to know the contents of the Load-path, you can enter (print Load-path) in the *scratch* buffer of Emacs, and then use the shortcut key after you move the cursor to the closing parenthesis c-j (M-x eval-print-last-sexp) To execute this statement, you can print out the contents of the Load-path in the current buffer.

Emacs Loads these configuration files in the order of: Site-start.el, initializing the file, and finally the default initialization file Default.el. When Emacs starts, you can use the-Q or –no-init-file option to prevent Emacs from loading the initialization file, and if the initialization file sets Inhibit-default-init to T, Emacs does not load the Default.el, and finally, you can use the –no-site-file to prevent Emacs from loading the generic configuration file.


Two. The writing and organization of the Emacs configuration file

The Emacs configuration file is written as an Emacs Lisp file, the syntax follows the Lisp language, and usually most of the configuration options are (Emacs variable emacs style)

As in this form (Emacs variable emacs face)

The common emacs variable has set-background-color,set-foreground-color,column-number-mode ... And so on, they all represent a particular Emacs attribute style, followed by a set value.

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);;

of which;; As an annotation symbol, you can also use ' to annotate.

Of all Emacs profiles, only. Emacs is not a. El suffix, but it is also interpreted as an Emacs Lisp file. You can write the configuration of various functions as separate El files, then include them in other files, and finally include these El files in the. Emacs configuration file. where contains b.el in A.el, just include A.el in. Emacs, as included in the C language

According to the general custom,. emacs files generally do not put too much information on settings, generally put some Emacs search path information.


Take my configuration for example,. Emacs is placed under/home/fenice/, while other El files are placed in/home/fenice/.emacs.d/lisps/_emacs.

So first you add a search path for Emacs

;; Add Plugin to Emacs
;; To set the plug-in load path
;; Plugin directory ~/.emacs.d/lisp/_emacs/
(Add-to-list ' Load-path "~/.emacs.d/lisp/_emacs/")

Plug-ins that are written by others can also be added to the path, such as

;;;; Add 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")            


You need to include files after you add a search path to load when Emacs starts

For example, include Xxx.el files, either (Require ' xxx) or (load "Xxx.el")


Three. Emacs Basic General Settings

You can download my profile, the basic settings are placed in the/home/fenice/.emacs.d/lisps/_emacs/base.el, that is, _emacs under the folder Base.el

;; =======================================================================
;; Author:kevin_samuel (Sun Junyan)
;;D ate:2013-7-30;
; Update date:2013-7-30;
; =======================================================================

;; Set font, default is monospace
;; Set-defalut-font
;;( Set-default-font "Monospace")
(set-default-font "-unknown-dejavu Sans mono-normal-normal-normal-*-13-*-*-*- M-0-iso10646-1 ")  ;; Personal feeling Mono system font fit program (to ordinary 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 setting;; ===============================================================
;; Remove the scroll bar (set-scroll-bar-mode nil); Close the opening screen (setq inhibit-startup-message t);; Disable toolbar (tool-bar-mode nil);; Disable the menu bar;;( Menu-bar-mode nil);; Remove Alert-bell (Mouse-wheel-mode t) (Global-linum-mode ' Linum-mode);; Auto show Row-num;; Automatic load line number (Partial-completion-mode 1);; Use Partial-completion (Icomplete-mode 1);; Use complete-completion;; Highlight current line;;( Require ' hl-line-settings);; You can turn the cursor from a square into a small strip;;( Require ' bar-cursor);; ======================================================================



;; ======================================================================
;; status bar;; ======================================================================
;; Show time;;( Display-time) (Display-time-mode 1);; Enable time display setting, on the bar above the Minibuffer (setq display-time-24hr-format t);; Time using 24-hour system (setq display-time-day-and-date t);; Time display includes date and time;;( SETQ Display-time-use-mail-icon T);; Mail setting is enabled next to the time bar;;( SETQ display-time-interval 10);; Time change frequency, unit how many again.; Display column number (setq column-number-mode t);; No column left shows line number, press F3 to show/Hide line number (require ' Setnu) (Setnu-mode t);;( GLOBAL-SET-KEY[F3] (quote setnu-mode)); Display title bar%f buffer full path%p page percent%l line number (setq frame-title-format "%f");; =======================================================================
;; buffer zone;; =====================================================================
;; Set line spacing (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);; To end with a blank line;;( SETQ require-final-newline t);;
Open syntax highlighting. (Global-font-lock-mode 1);; Highlight Region selection (Transient-mark-mode t);; The page rolls smoothly, and the Scroll-margin 3 starts rolling near the edge of the screen and 3 lines, just to see the context;;( SETQ Scroll-margin 3 scroll-consrvatively 10000) Highlight the pair bracket (Show-paren-mode t) (setq show-paren-style ' parentheses);; mouse pointer to avoid the cursor (Mouse-avoidance-mode ' animate); Paste at the cursor, not at the mouse pointer (setq mouse-yank-at-point t);; =======================================================================
;; echo area;; =======================================================================
;; Flash screen Alarm (setq Visible-bell t); Ask questions with Y or n (fset ' yes-or-no-p ' y-or-n-p);; Lock row height (setq resize-mini-windows nil);; Recursive Minibuffer (setq enable-recursive-minibuffers t); When the M-x command is used, the command-bound key (Setq suggest-key-bindings-1) is displayed over 1 seconds;; Default.;; ======================================================================
;; The setting of the editor;; ======================================================================
;; Does not produce backup files (setq make-backup-files nil);; Do not generate temporary files (setq-default make-backup-files nil);; Renders only the current screen syntax highlighting, speeding up the display speed (setq lazy-lock-defer-on-scrolling t);;( Setq Font-lock-support-mode ' Lazy-lock-mode) (setq font-lock-maximum-decoration t) Displays the error message in the Echo area (Condition-case err (Progn (require ' xxx)) (Error (message "Can ' t load xxx-mode%s" (Cdr err)));; Use the x clipboard (setq x-select-enable-clipboard t);; Sets the content format of the Clipboard to fit into Firefox (Set-clipboard-coding-system ' Ctext);; Set tab width to 4 (setq default-tab-width 4);; The following settings indent
;; tab indent (setq indent-tabs-mode t) (setq c-indent-level 4) (setq c-continued-statement-offset 4) (setq c-brace-offset-4) (s ETQ c-argdecl-indent 4) (setq c-label-offset-4) (setq c-basic-offset 4) (global-set-key "\c-m" ' Reindent-then-newline-an D-indent)

This is part of my base.el file, and it's not all posted. Remember, however, that all of the configuration files in Emacs are loaded into the Lisp interpreter at startup, and if there are too many profiles or plug-ins, the editor becomes slow, and you've seen an article that configures Emacs as an IDE development environment with countless plug-ins, The Emacs I configured in accordance with that article starts 5 seconds (i5-3230 8g), and normally Emacs is instantaneous. If you want to be so redundant, you might as well go with the IDE, and Emacs looks at the turtle, isn't it?


Four. Emacs Plug-in Extension Configuration description

(1)

My Emacs configuration file

/home/fenice/.emacs

My Emacs configuration file Package

/home/fenice/.emacs.d/lisps/_emacs

The main feature calls are as follows (. emacs) Loading the configuration file package

;;;; Read script
;; =========================================
;; Bind the key
(load "Cykbd.el")

;; Basic setting
(Load "Base.el")
;; Expand Setting
(Load "Cyexpand.el")
; DE frame setting
;;( Load "Addon.el")

;; Code setting for programming configuration
(Load "Cycode.el")
;; ========================================


My profile has a cycode.el, why is called Cy Code.el, because this file is written by Chen Yang. The one with the CY prefix is.

debugging features, adding in Cycode.el:

;; ==============================================================
;; Gdb-ui configuration
;; ==============================================================
(setq gdb-many-windows t)
(load-library "Multi-gud.el")
(load-library "Multi-gdb-ui.el")

The above contains two debugging Plug-ins downloaded from the Internet, it is convenient to do gdb debugging in Emacs.

(2) Install Cedet plugin. Need to download from the Internet. Cedet can be a variety of language grammar analysis, automatic completion, object-oriented design, UML diagram rendering functions, as well as engineering management functions, but no use.

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

If you use my profile, it's best to empty the contents of the/home/fenice/.emacs.d/lisps/_emacs/install and then extract the Cedet (a compressed package from my shared file) into the install directory. It is then installed according to the instructions in the install file within the Cedet. Finally, add the path and configuration information to the. Emacs or Cycode.el. My configuration file has a directory of ~/.emacs.d/lisps/_emacs/install/cedet-1.0/

If used, you need to add

;; ==================================================
;; Cedet plugin 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 the install of Cedet
; Cedet/common/cedet.info for configuration details.

Finally, add in the configuration file (in. emacs or other custom files, mine is Cycode.el)

(load-file "~/.emacs.d/lisps/_emacs/install/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 IntelliSense 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 are should not enable it. ;;   (semantic-load-enable-all-exuberent-ctags-support);; Or, use one of the 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);; ----------------------------------------------------------------------(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);; Collapses and opens all the code for the entire buffer (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 ') Collapses and opens all code for a single buffer (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) The ECB plug-in can be used in conjunction with Cedet for easy use. The disadvantage is that the two plug-ins slow down the start of Emacs by 2 seconds.

Download the ECB directly to the ~/.emacs.d/lisps/emacs/install directory to extract it, this is my directory, you can also customize the directory, but to note that modify the path

And then add

;; ==============================================================
;; ECB configuration
;; ==============================================================
;;( Require ' ECB)
;; Open ECB use, m-x:ecb-activate
(Require ' ecb-autoloads)
;; Automatically starts the 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) True automatic complement function, just like WinDOS under Visual Studio installed visual assist after the completion.

Here you need two plugins-auto-complete and Yasnippet. First install Auto-complete, download and then put into the ~/.emacs.d/lisps/emacs/install directory decompression (also can use their own directory, pay attention to modify the path), and then into the extracted directory, and then enter make command The following installation Yasnippet, download and then put to the ~/.emacs.d/lisps/emacs/install directory, and then unzip it; Here are a few words about the configuration of these two plug-ins:

;; ==========================================================
;; Loading cscope
;; ==========================================================
(Require ' xcscope)

;; ==========================================================
;; The configuration of Yasnippet
;; ==========================================================
;; Too powerful, powerful template function
(require ' yasnippet)    ;; Not Yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/lisps/_emacs/install/ Yasnippet-0.6.1c/snippets ")

;; Automatic completion
;;( Require ' Auto-complete-config)
;;( Ac-config-default)

(5) Key binding function

is the shortcut key to set up Emacs

My key bindings are all set in the Cykbd.el file, and the following are some of the things that include compiling and debugging

(Global-set-key [F1] ' Manual-entry)
(Global-set-key [c-f1] ' info)

;; F3 is the lookup string, ALT+F3 closes the current buffer
(Global-set-key [F3] ' Grep-find)
(Global-set-key [m-f3] ' kill-this-buffer)

;;. Set up a Speedbar shortcut key in Emacs
(Global-set-key [(F4)] ' Speedbar-get-focus)
;; CTRL-F4, activation, ECB
(global-set-key [c-f4] ' ecb-activate)

;; F5 Show/Hide toolbars for easy debugging
(Global-set-key [F5] ' Tool-bar-mode)
;; Ctrl-f5 Show/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 Compile command; F7, save all 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 Compile-command))


(6) Many other collected point El Extension files are included with Cyexpand.el. But there are a lot of them that I've been missing. If you don't need to, you can drop (load "Cyexpand.el") in. Emacs.

(7) There is a addon.el in my profile that will make Emacs look more like the IDE, but because it's so ugly, I've got it in. Emacs.


If you are using my profile http://pan.baidu.com/share/link?shareid=4196458904&uk=3708780105

Download Emacs_setting.tar.gz, according to Readme.txt instructions can, a little trouble, you can explore carefully. Rename Samuel_emacs to. Emacs, put it under/home/yourusername/.

After you extract the _emacs.d.tar.gz, rename the. emacs.d into/home/yourusername/, and the other plugins are configured according to Readme.txt


Note that a configuration file that is not in use contains all the notes, otherwise Emacs will really be as bloated as some Ides. While Vim is relatively simple to configure as an IDE, the great God of Wu has written an article that configures Vim to the IDE, but that's 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.