Emacs auto-complet and yasnippet plug-ins for installation, configuration, and extension

Source: Internet
Author: User

During this period of time, I suddenly became idle, and I was tossing and tossing Emacs.

I always wanted to solve the auto-completion function because of the essential features of the modern development environment. Google, many of them use auto-complete and yasnippet, so they installed them on their own. First, check the installation documentation, and refer to other people's methods, various twists and turns, and finally complete the configuration, and learned how to expand these two plug-ins, you can define the complete content by yourself-cool!
First, we will introduce the relationship between the two. Auto-complete is a complementary framework and provides a simple source. yasnippet can be used as a complementary source for auto-complete, it can also be used independently, but it is better to use it with auto-complete. Of course, auto-complete and other sources can be used. Try again later.

Table of contents
    • 1. installation and configuration

      • 1.1 auto-complete
      • 1.2 yasnippet
    • 2 extension
      • 2.1 auto-complete
      • 2.2 yasnippet
1 Installation and configuration 1.1 Auto-complete

Download auto-complete-1.3.1. For more information, see the installation method in this document.
Version 1.3 can not use the latest version of yasnippet, solution: to auto-complete GitHub clone down the auto-complete-config.el, replace the file in the installation directory, remember to repeat byte-compile.
The configuration file is as follows:

(Add-to-list 'Load-Path "~ /. Emacs. d/plugins/auto-complete" )( Require ' Auto-complete-config ) (Add-to-list 'ac-dictionary-Directories "~ /. Emacs. d/plugins/auto-complete/ac-dict" ) (Ac-config-default) (setq ac-use-quick-help nil) (setq ac-auto-start 4) ;;  Enter 4 characters to complete (Global-set-Key "\ M -/" 'Auto-complete) ;;  Complete the shortcut key to be completed in advance ;;  Show menu 0.8 second later (Setq ACs-auto-show-menu 0.8) ;;  Select shortcut keys for menu items (Setq ac-use-menu-map t) (define-key ac-menu-Map "\ C-n" 'Ac-Next) (define-key ac-menu-Map "\ C-P" 'Ac-previous) ;;  Set menu to 12 lines (Setq ac-menu-Height 12)

Auto-complete supports completion in common languages by default, specific configuration in the auto-complete-config.el, see the last few lines of the file.
Additional configurations are required for Modes not supported by auto-complete, such as latex.

;;Latex-Mode(Add-to-list 'ac-modes 'latex-mode )(Defun Ac-latex-mode-Setup() (Setq ac-sources (append' (Ac-source-yasnippet) Ac-sources ))) (add-hook 'latex-mode-hook 'ac-latex-mode-Setup)
1.2 Yasnippet

Installing yasnippet can be cloned directly from GitHub. For more information about the installation process, see. My configuration file for yasnippet is as follows. Note that this section should be placed before the configuration for auto-complete, because AC needs to use Yas.

(Add-to-list 'Load-Path"~ /. Emacs. d/plugins/yasnippet")(Require'Yasnippet) (Setq Yas/prompt-Functions '(YAS/dropdown-Prompt Yas/X-Prompt Yas/completing-Prompt Yas/Ido-Prompt Yas/no-Prompt )) (YAS/Global-mode 1) (YAS/minor-mode-on);Use minor mode to enable it in combination with the main mode.
2 Extension

For more information about the extension method, see the user manual.

2.1 Auto-complete

The method to expand the AC is relatively simple. In the installation directory of the AC, there is a text file named "ac-dict" and "*-mode". You can directly modify this file.

2.2 Yasnippet

The simple extension method of AC determines that it can only be used as a framework, and more powerful functions can only be provided by other tools.
The Extension Method of yasnippet starts with a built-in snippet example.

Date: 2013-04-26t09: 44 + 0800

Author: liyongmou

Org version 7.9.2 with Emacs Version 24

Validate XHTML 1.0

 

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.