走进Emacs殿堂

[size=large]安装[/size]

[size=medium]使用cygwin在windows上安装[/size]

在安装emacs之前需要先安装cygwin。[url=http://www.cygwin.cn/site/install/]这里是安装方法[/url]。需要特别说明的是,在选择安装包的时候,请选上python。


[img]/upload/attachment/52643/a95d2500-dc15-3f59-96d3-fed251d58b8b.png[/img]


安装完cygwin以后我们就可以使用脚本进行以下的安装。把下面的一段代码存到名为myapt的文件中,把myapt文件存放到
C:\cygwin\home\[您的用户名]\bin目录下。

[code]
#!/bin/bash

function do_apt(){
mkdir -p ~/bin
cd ~/bin
wget http://download.linuxaudio.org/lilypond/binaries/cygwin/cyg-apt
chmod a+rx cyg-apt
cyg-apt -m http://www.cygwin.cn/pub setup
cyg-apt -m http://www.cygwin.cn/pub update
cd -
}

function do_editor(){
do_cyg_install install xinit xorg-server font-adobe-dpi100 font-adobe-dpi75
do_cyg_install install twm xclock font-isas-misc
do_cyg_install install emacs emacs-X11 emacs-el
}

function do_cyg_install(){
cyg-apt -m http://www.cygwin.cn/pub $@
}

cmd=$1

case $cmd in
init)
do_apt
;;
emacs)
do_editor
;;

esac

[/code]

点击桌面的 cygwin 快捷方式启动 cygwin 控制台。
在控制台中输入:

[code]

chmod +x bin/myapt #---赋予 myapt 执行权限。
myapt init #---初始化
myapt emacs #---安装emacs

[/code]

现在,emacs在windows下的基本安装就完成了。 我们可以在 cygwin 控制台中输入命令 starx 启动 xterm, 然后在 xterm 中输入命令 emacs-X11
来启动 emacs 程序。


[size=medium]在 ubuntu 上安装[/size]

我们同时使用脚本方式安装。把下面的代码拷贝到myapt文件中,把myapt存到${HOME}/bin目录下。

[code]

#!/bin/bash

function do_emacs(){
sudo aptitude install emacs emacs-extra emacs-goodies-el emacs-intl-fonts
sudo aptitude install w3m-el muse-el aspell remember-el
}

cmd=$1

case $cmd in

emacs)
do_editor
;;

esac

[/code]

打开Terminal 输入:

[code]

chmod +x bin/myapt #---赋予myapt执行权限。
myapt emacs #---安装emacs

[/code]

现在,emacs 在 ubuntu 下的基本安装就完成了。


[size=large]Emacs 简介[/size]

打开的 emacs 如下图所示。在 emacs 中编辑的不是文本本身,emacs 会把文件的内容拷贝到 buffer 中。

[img]/upload/attachment/53274/deaa2c39-5c01-3368-ac0f-e0db670f1731.png[/img]


从图中我们可以看到,emacs 由“菜单”、“工具条”、“主 buffer”、“状态显示条”和“次 buffer” 组成。

在 emacs 中很多操作都有快捷键,使用快捷键是一种
高效的编辑 buffer 的方式。但是如果我们忘记了某个操作的快捷键,我们可以通过选择“菜单”或者点击“工具条”上的按钮来执行相应的操作。

“主 buffer” 是我们编辑文件的主要区域,看起来和记事本没有太多区别,不过当您熟悉了它的功能以后,您就知道它远非那么简单了。

在 emacs 中还有一个模式(mode)的概念,例如我们编辑一个 SQL 文件,那么它就会使用 sql-mod。所有 SQL 相关的语法显亮,连接数据库,执行
SQL 查询等功能都会与 sql-mod 关联。在一个 buffer 中可以使用多个模式。这些信息会显示在“状态显示条”上。

“次 buffer” 是我们和 emacs 交互的一个窗口。通过“次 buffer”,我们可以向 emacs 发送命令。emacs 中的所有操作都可以通过命令来执行。


[size=large]基本的文本编辑[/size]


[code]
C-x C-c : Exit and close Emacs
C-x C-z : Exit and hang on Emacs
C-x C-f : Open file or folder
C-x i : Insert file
C-x C-r : Open a file with read only mode
C-x u Or C-/ : Undo
C-x C-s : Save
C-x s : Save all unsaved files
C-x C-w : Save as...
C-l : Refresh the buffer
C-g : Stop current command
C-a : Go to head
C-e : Go to tail
C-n : Next line
C-p : Pre line
C-f : forward one character
C-b : backward one character
[/code]


[size=large]如何获得帮助信息[/size]

Ctrl + h

[list][*]a command-apropos. Type a list of words or a regexp; it shows a list of commands whose names match. See also the apropos command.

[*]b describe-bindings. Display a table of all key bindings.

[*]c describe-key-briefly. Type a key sequence;it displays the command name run by that key sequence.

[*]d apropos-documentation. Type a pattern (a list of words or a regexp),
and shows a list of functions, variables, and other items whose documentation matches that pattern. See also the apropos command.

[*]p finder-by-keyword. Find packages matching a given topic keyword.

[*]r info-emacs-manual. Display the Emacs manual in Info mode.[/list]


[size=large]Lisp 语言介绍[/size]

[list][*]Function[/list]


01 (defun my-switch-buffer ()
02 "Like switch-buffer but in the opposite direction"
03 (interactive "")
04 (other-window -1)
05 )


[list][*]Customize Emacs[/list]


(require 'color-theme)
(color-theme-initialize)
(color-theme-billw)


[size=large]安装插件[/size]

Emacs的插件一般是由 Lisp 编写的,你只需要把插件的 Lisp 文件放到 Emacs 的查询路径下就可以了。这里我介绍另一个安装插件的工具 ELAP
[url=http://tromey.com/elpa/install.html。]http://tromey.com/elpa/install.html。[/url]


[code]

(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))

[/code]


[size=large]在Emacs中编程[/size]

[list][*]Tabbar
[*]Spell Check
[*]SQL
[*]Template
[*]Auto-completion
[*]Version Control[/list]


[size=large]执行更多的文本编写[/size]

[list][*]PlanningOrg[/list]

Org-mode is a mode for keeping notes, maintaining TODO lists, and doing project planning with a fast and effective plain-text system.

[list][*]Taking notesmuse[/list]

Emacs Muse is an authoring and publishing environment for Emacs. It simplifies the process of writings documents and publishing them to various output formats. Muse uses a very simple Wiki-like format as input.

Muse consists of two main parts: an enhanced text-mode for authoring documents and navigating within Muse projects, and a set of
publishing styles for generating different kinds of output.


[size=large]扩展Emacs[/size]

[list][*]Get the last version automatically[/list]

[code]

(add-hook 'find-file-hooks 'my-vc-update)

(defun my-vc-update()
(condition-case nil
(if (vc-registered (buffer-file-name))
(vc-update))
(error nil))
)

[/code]

[list][*]Run SQLunit Test[/list]

[code]
(defun sqlunit-run-file ()
"Run sqlunit on current buffer"
(interactive )
(shell-command
(format "ant -f %s../build.xml -Dscript.name=%s &" (buffer-dir) (buffer-name))))
[/code]

[list][*]Developerworks article publishing[/list]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值