欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

emacs autocomplete

程序员文章站 2024-03-18 13:01:04
...
安装emacs24,23以前比较麻烦,
emacs24
http://kanpe777.github.io/blog/2014/01/12/yum-install-emacs24-on-centos-6-dot-5/

因为24自带了list-packages
$ cd /etc/yum.repos.d  
$ wget http://pj.freefaculty.org/EL/pjku.repo
$ rpm --import http://pj.freefaculty.org/EL/PaulJohnson-BinaryPackageSigningKey
$ yum install emacs
$ emacs -version

m-x list-packages

http://ergoemacs.org/emacs/emacs_package_system.html

安装插件

Install Packages

This list is shown in package-menu-mode. In this mode, here's the most useful keys:

【Enter ↵】 Describe the package under cursor. (describe-package)
【i】 mark for installation. (package-menu-mark-install)
【u】 unmark. (package-menu-mark-unmark)
【d】 mark for deletion (removal of a installed package). (package-menu-mark-delete)
【x】 for “execute” (start install/uninstall of marked items). (package-menu-execute)
【r】 refresh the list from server. (package-menu-refresh)

~/.emacs


(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
)

搜auto-complete

i x安装完之后发现 ~/.emacs.d/里面多了一些内容
~./.emacs
的内容为添加autocomplete的内容


(setq current-language-environment "UTF-8")
(setq default-input-method "chinese-py")
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)


(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
)

(require 'auto-complete)
(require 'auto-complete-config)
(global-auto-complete-mode t)
(setq-default ac-sources '(ac-source-words-in-same-mode-buffers))
(add-hook 'emacs-lisp-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-symbols)))
(add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename)))
(set-face-background 'ac-candidate-face "lightgray")
(set-face-underline 'ac-candidate-face "darkgray")
(set-face-background 'ac-selection-face "steelblue") ;;; 设置比上面截图中更好看的背景颜色
(define-key ac-completing-map "\M-n" 'ac-next) ;;; 列表中通过按M-n来向下移动
(define-key ac-completing-map "\M-p" 'ac-previous)
(setq ac-auto-start 2)
(setq ac-dwim t)
(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
相关标签: emacs