以下是我整理的 emacs 配置文件,供刚开始玩 emacs 的同学参考。网上有人说:emacs 是神的编辑器,如果能够用到这样的编辑器,那这个人就是神了。从我个人的经验来看,emacs 是一把利器,用好它,将会事半功倍。我们大多数的编程是受制于语言(程序员是语言的奴隶),而如果能够掌握好 emacs 这一利器,则对于自己是一个质的飞跃——编程是让语言成为程序员的奴隶。这一点,以后详细谈。

;; 常规设置
(menu-bar-mode -1) ;; 不显示菜单
(tool-bar-mode -1) ;; 不显示工具栏
(scroll-bar-mode -1) ;; 不显示滚动条
(column-number-mode 1) ;; 显示行数和列数
(setq default-directory "d:/home/") ;; 设置默认目录
(appt-activate 1) ;; 启动日历提醒
(setq require-final-newline t) ;; 编辑文件的最后一个字符是回车
(setq bookmark-default-file "~/.emacs.d/.emacs.bmk") ;; 书签文件位置
(fset 'yes-or-no-p 'y-or-n-p) ;; 简化确认时的输入
(global-set-key "\r" 'newline-and-indent) ;; 回车默认缩进
(setq inhibit-startup-message t) ;; 不显示启动时的界面
(show-paren-mode 1) ;; 显示括号的对应反括号
(setq show-paren-style 'mixed) ;; 设置显示括号的样式
(mouse-avoidance-mode 'animate) ;; 光标与鼠标重合时,移开鼠标
(setq frame-title-format "%b -- Do It Yourself") ;; 设置标题
(setq default-tab-width 4) ;; Tab 的宽度为 4
(setq-default make-backup-files nil) ;; 不产生备份文件
(set-frame-position (selected-frame) 400 140) ;; 设置初始的窗口宽高 ;; 增强 find file 及 switch buffer 功能
(require 'ido)
(ido-mode t) ;; 启动 Emacs 服务,下次打开文件时使用同一个 Emacs
(server-start) ;; 设置环境变量
(setenv "LC_CTYPE" "zh_CN.UTF-8") ;; 设置全局快捷键
(global-set-key "\C-c\C-v" 'view-mode) ;; 只读模式
(global-set-key "\C-z" 'set-mark-command) ;; Mark
(global-set-key "\C-xz" 'suspend-frame) ;; 将 Emacs 放到后台运行
(global-set-key [f8] 'occur) ;; 在当前 Buffer 中查找
(global-set-key "\C-x\C-b" 'electric-buffer-list) ;; 列出当前所有 Buffer
(global-set-key (kbd "C--") 'undo) ;; 向前恢复
(global-set-key "\C-c\C-z" 'pop-global-mark) ;; 到之前的 Marker
(global-set-key "\M-/" 'hippie-expand) ;; 智能完成
(global-set-key (kbd "C-SPC") 'nil) ;; 将 C+空格 快捷键置空
(global-set-key "\C-ca" 'org-agenda) ;; 启用 Agenda 模式
(global-set-key "\C-\\" 'toggle-truncate-lines) ;; 切换换行模式 ;; 设置 Windows 下字体
(setq w32-charset-info-alist
(cons '("gbk" w32-charset-gb2312 . 936) w32-charset-info-alist))
(setq default-frame-alist
(append
'((font . "fontset-gbk")) default-frame-alist))
(create-fontset-from-fontset-spec
"-outline-Courier New-normal-r-normal-normal-13-97-96-96-c-*-fontset-gbk")
(set-fontset-font
"fontset-default" nil
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'kana
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'han
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'cjk-misc
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'symbol
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-default-font "fontset-gbk") ;; 增加 Eshell 命令
;; linux 中 clear
(defun eshell/clear ()
"to clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer))) ;; 用 Windows 文件浏览器打开
(defun eshell/o (&rest args)
"open the doc"
(interactive)
(if (eq nil args)
(setq args '("explorer" ".")))
(apply 'start-process-shell-command "Sub process of Eshell" "*Messages*"
(car args) (cdr args))) ;; 恢复默认宽高设置
(defun retrive-position ()
(interactive)
(set-frame-position (selected-frame) 400 140)
(set-frame-size (selected-frame) 80 40)) ;; 还原最大化窗口
(defun frame-restore ()
"Restore a minimized frame"
(interactive)
(w32-send-sys-command 61728)) ;; 最大化窗口
(defun frame-maximize ()
"Maximize the current frame"
(interactive)
(w32-send-sys-command 61488)) ;; 关闭 Buffer,支持 Server/Client 模式的关闭
(defun my-kill ()
"Kill buffer for server-client and not server-client."
(interactive)
(cond (server-buffer-clients (server-edit))
(t (ido-kill-buffer)))) ;; 设置关闭 Buffer 的快捷键
(global-set-key "\C-xk" 'my-kill) ;; 加入 package 模块,可以通过 list-package 添加扩展
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) ;; 设置假期,在日历中可以看到
(setq calendar-holidays '((holiday-chinese 1 1 "春节")
(holiday-chinese 1 15 "元宵节")
(holiday-fixed 3 8 "妇女节")
(holiday-fixed 5 1 "劳动节")
(holiday-fixed 6 1 "儿童节")
(holiday-chinese 5 5 "端午节")
(holiday-chinese 7 7 "七夕节")
(holiday-chinese 7 15 "鬼节")
(holiday-fixed 8 20 "纪念")
(holiday-chinese 8 15 "中秋节")
(holiday-chinese 9 9 "重阳节")
(holiday-fixed 10 1 "国庆节") (holiday-chinese 1 1 "张三生日")
(holiday-chinese 3 1 "李四生日"))) ;; 设置多窗口时的快捷键,Shift+方向可以切换窗口,C-c ← 可以回到前一次窗口设置
(when (fboundp 'winner-mode)
(winner-mode)
(windmove-default-keybindings))

在 windows 环境中,添加 emacs 的右键编辑菜单,新建一个 emacs.reg 文件,内容如下:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\emacs]
@="Emacs (&W)"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\emacs\command]
@="D:\\emacs\\bin\\emacsclientw.exe -a \"d:\\emacs\\bin\\emacsclientw.exe\" \"%1\""

编辑完后,双击 emacs.reg 即可将该配置写入到注册表,这样,右键菜单就会有一个 Emacs(W) 的东东。可以通过这个选项使用 emacs 打开任何文件。

Emacs 配置文件的更多相关文章

  1. 转来的emacs配置文件,自动安装插件

    网上转来的emacs配置文件,便于自动安装插件,收藏起来 http://www.gogae.org/post-7/ EMACS是一个伪装成代码编辑器的操作系统. EMACS是一个非常强大的代码编辑器, ...

  2. emacs配置文件的基础知识 (转载)

    转自:http://blog.csdn.net/schumyxp/article/details/2278268 emacs的配置文件,叫作.emacs,是个隐藏文件,存在于当前用户的根目录下面,也就 ...

  3. linux下emacs配置文件

    1:安装.在ubuntu下使用命令 sudo apt-get install emacs,即可,我使用的是ubuntu的10.04的版本,在里面使用了据说是163的2个源. 1.1:如何更新快速的源, ...

  4. Emacs配置文件

    ;;tab and space;;when true,emacs use mixture of tab and space to archieve(setq-default indent-tabs-m ...

  5. update:我的Emacs配置文件

    ;;设置字体用的  防止中文变成无法识别的框框 (set-default-font "Consolas-11") (set-fontset-font "fontset-d ...

  6. 我的Emacs配置文件

    (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you co ...

  7. ~/.emacs emacs 配置文件

    windows ~/.emacs (when (>= emacs-major-version 24) (require 'package) (add-to-list 'package-archi ...

  8. [备份]Emacs配置文件

    (set-background-color "gray20")(set-foreground-color "wheat") (tool-bar-mode -1) ...

  9. emacs配置详解及C/C++IDE全功能配置演示(附配置文件)

    我的emacs插件下载地址: http://pan.baidu.com/share/link?shareid=4196458904&uk=3708780105 说明: 1.为什么使用emacs ...

随机推荐

  1. 【学习篇:他山之石,把玉攻】jquery实现调用webservice

    1.webservice端 using System; using System.Collections.Generic; using System.Web; using System.Web.Ser ...

  2. MySQL深度巡检

    1. IO层面检查   (1)IO检查   查看%util是否接近100%定位是哪个磁盘IO压力大 #iostat -x 1 10 (2)iotop定位负载来源进程 查看哪个PID占用IO最高 #io ...

  3. CMD安装/删除服务

    服务安装 sc create "ddd" binpath= "D:\winservice\XXX\XXX.exe" 服务删除 sc delete "d ...

  4. [leetcode] 390 Elimination Game

    很开心,自己想出来的一道题 There is a list of sorted integers from 1 to n. Starting from left to right, remove th ...

  5. python爬虫实战

    http://www.jb51.net/article/57161.htm python在线编程:http://www.pythontip.com/coding/run c语言在线编程:http:// ...

  6. SQL 语句与性能之执行顺序

    select * , t3.Name from t1 left join t2 on t1.sysno = t2.Asysno left join t3 on t3.sysno = t2.Bsysno ...

  7. python学习4 常用内置模块

    logging os 路径处理 // 获取当前路径 os.path.abspath(__file__) //获取当前文件夹路径 os.path.dirname(os.path.abspath(__fi ...

  8. LeetCode 389. Find the Difference

    Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...

  9. centos下编译安装lnmp

    centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...

  10. Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数

    特殊变量列表 变量 含义 $0 当前脚本的文件名 $n 传递给脚本或函数的参数.n 是一个数字,表示第几个参数.例如,第一个参数是$1,第二个参数是$2. $# 传递给脚本或函数的参数个数. $* 传 ...