Emacs初学者必知必会
自己学习Emacs已3年由余, 对Emacs也算有点经验. 随着对Emacs的了解的不断深入, 越来越觉得Emacs是一款非常值得学习的软件. 所以我经常向自己的朋友推荐Emacs. 自己也认识一些Emacs初学者. 从他们经常问的一些问题中感觉, 好多初学者都没有好好的学过Emacs, 也有可能是Emacs的资料不是很多, 好资料更少, 他们没有找到好的学习方法吧. 所以, 我想就我所了解的, 写一些初学者应该知道的东西, 或者说, 初学者掌握了这些知识和方法后, 学习Emacs起来更加容易吧. 另外, 初学者如果有兴趣的话, 可以看看本人另外一篇拙作《致Emacs初学者》, 希望能对你们有所帮助.
知道Emacs的基本概念
- buffer
缓冲区. Emacs并不直接对文件进行操作, 它是把文件加载进buffer, 用户直接操作buffer, 只有当用户确定把buffer中所做的修改写人文件时, Emacs才把buffer中的内容写入文件. buffer实际上就是一个内存缓冲区, 这和一般编辑器中都一样, 应该很好理解. - window
窗口. 由于Emacs很早就诞生了, 它的窗口概念和现在基于窗口的操作系统中的窗口概念不是一样的. Emacs中的窗口是用来显示buffer的一个区域. 它并不像操作系统中的窗口拥有自己的标题栏,系统菜单栏. - frame
Emacs中的frame就是操作系统中的窗口.
buffer是文件的内存表示, windows则是显示buffer的区域, 一个frame中可以有多个window, Emacs则可以有多个frame.
- Emacs Lisp
Emacs最基础的部分是用c写的,其他部分都是用Emacs Lisp语言写的,Emacs Lisp语言是基于lisp语言的. lisp是LISt Processor的缩写, 即链表处理语言, 所以lisp语言的操作都是基于链表的, 它的语法也是链表结构, 链表第一个元素表示函数名, 其他元素是参数, 比如通常语言中的a+b, 在lisp就是(+ a b) - mode
mode有major mode和minor mode之分, 每个缓冲区对应一个major mode, 也只有一个major mode, 但是可以有多个minor mode. Emacs对每一种文件都有一个mode. - 命令
你对Emacs所有的操作都是对Emacs的命令的调用。比如,你在text-mode里,当你按下任何字母键进行编辑的时候,实际上是调用的emacs的命令self-insert-command. - 快捷键
Emacs中Control键用C表示,Alt键用M表示, 即: C-c表示Control C, M-x表示Alt x.
除掉以Alt键开头的,比如Alt a,Emacs中的快捷键基本上都有一个前缀,Emacs中最多的快捷键前缀就是C-x,C-c,前缀表示,你不必要一起按下前缀和后缀,可以先按下前缀,Emacs会等待你按下剩余的快捷键,这样Emacs中的快捷键按起来非常的方便。 - keymap
键盘映射. Emacs的快捷键是通过keymap来控制的. 有全局和局部的keymap. 每个mode都会有一个自己的局部的keymap, 局部的keymap会覆盖全局的keymap, 另外如果对应的major mode有开启的minor mode, 而且这个minor mode有keymap的话, 这个minor mode的keymap会覆盖major mode的keymap.
学会看文档
Emacs的文档非常丰富, 有Elisp自己的自文档, 还有更详细的info. Elisp中的变量, 函数都有文档. 对于大多数情况都够用了.
- 查看变量的值和文档
C-h v (describe-variable) - 查看函数的文档
C-h f (describe-function) - 查看face的文档
M-x describe-face - 查看某个mode的文档
C-h m (describe-mode)
刚开始学习某个mode的时候, 可以用C-h m看看当前buffer对应的主mode和副mode的文档, 这个文档一般都会包括mode中的命令和快捷键列表. - 查看某个快捷键对应的命令
C-h k (describe-key) - 查看某个命令对应的快捷键
C-h w (where-is) - 查看当前buffer所有的快捷键列表
C-h b (describe-bindings) - 查看当前buffer中以某个快捷键序列开头的快捷键列表
<待查看的快捷键序列> C-h,比如你想查看当前buffer中所有以C-c开头的快捷键列表,按C-c C-h就可以了。 - 查看函数的代码
find-function - 查看变量的代码
find-variable - 查看face的代码
find-face-definition - M-x apropos
查看包含某个关键词的函数,变量,face
会些简单的配置
- 执行Elisp代码
- 在某条语句后面按C-x C-e (eval-last-sexp)可以执行那条语句
- M-x eval-buffer 可以执行当前buffer内的Elisp代码
- 选中一个region后, M-x eval-region可以执行这个region内的代码
- 安装插件
Emacs的插件一般都是一个以el为后缀名的文件, 把这个文件下载下来后放到一个目录, 比如~/emacs/lisps, 然后执行下面这两条语句:1 2
(add-to-list 'load-path "~/emacs/lisps") (require 'pluginname)
- 快捷键定制
全局绑定global-set-key, 绑定某个mode的快捷键用define-key. global-set-key的定义为:(global-set-key key command)
比如想把C-j绑定到”到达指定行上”(goto-line), 这样就可以了:
(global-set-key (kbd "C-j") 'goto-line)
kbd是Emacs的宏, 把快捷键转换为Emacs的内部按键表示. 然后执行上面那条语句, 就会使你的配置生效. 然后你可以用C-h k检查一下你的定制是否成功了.
如果对于比较复杂的快捷键, 比如Control x F3, 改怎么写呢? 按C-h k(describe-key), 然后再按下Control x F3, Emacs会出现一个”C-x“, 这个就是你要写到kbd宏里面的内容.
如果你想对某个特定模式比如c++-mode进行快捷键定制, 用define-key即可, 对于上面的例子这样写:(define-key c++-mode-map (kbd "C-j") 'goto-line)
define-key第一个参数map一般为mode后面直接加”-map”
- 简单的颜色定制
1 2 3 4 5
(set-background-color "black") ;; 使用黑色背景 (set-foreground-color "white") ;; 使用白色前景 (set-face-foreground 'region "red") ;; 区域前景颜色设为红色 (set-face-background 'region "blue") ;; 区域背景色设为蓝色

a WordPress rating system
Johann Strauss II’s delectable operetta is given an exuberant and bubbly production at the Mahalia Jackson Theater for the Performing Arts this weekend (the closing performance is Sunday, Nov. 15), showing why the tuneful confection is the most performed operetta in the standard repertoire. coach factory outlet measures are not consistent with Washington’s previous commitments to accept services from other countries. l coach outlet store online
A similar rationale applies to cold weather clothing, such as ski parkas http://www.raybansunglassesbuy.co.uk But many producers have fought the concept, arguing that actors already undergo health screening and audiences are turned off by condoms.
Montreal defenseman Nathan Beaulieu got a match penalty and game misconduct with 17 seconds left for a cross-check on Boston’s Zac Rinaldo. Rinaldo was skating in for a bodycheck when Beaulieu lifted his stick and appeared to get him in the neck or the head. ray ban glasses Initially, in 1991, he received a sentence of 66 years to life in prison, with two convictions for murder and another for rape. k ray ban sunglasses outlet
What that also leads to is a shortage of qualified teachers. cheap jordan shoes Fishing was a significant part of my life and is intertwined with so many of my childhood memories.
q The 813-acre park’s population booms to more than 15,000 people during summer holiday weekends, says Gene Van Koevering, the park’s president for the past three years. Most members live within an hour of the park, he says. coach outlet online “Lawmakers can expect a robust effort by the grassroots to steer them away from expanding Medicaid and placing Arkansas on a path to fiscal ruin. coach factory outlet
“I was nervous coming here thinking this is going to be my one job for a very long time even though it’s like the coolest job I could possibly imagine. coach outlet online We did not make these decisions lightly and these changes are difficult for us all, but these staffing reductions will allow us to operate more efficiently and position the network for the future. http://www.michaelkorshandbagsoutletup.us.com
Larkin scored in his fourth straight game – the first time a Red Wings teenager has done so since Steve Yzerman in 1984-85 – giving Detroit a 3-2 lead in the second period and helping force overtime to set the stage for Pulkkinen’s heroics. michael kors outlet online Two teams from southern Minnesota left it all on the court Thursday night. m michael kors outlet store
He was among four Phoenix Symphony musicians to recently earntenure, according to a news release from the orchestra. louis vuitton handbags Arizona State pays coach Charli Turner Thorne $464,000 a year.
After 30 years of Republican control, we spend less than all other states on students and we remain at the bottom of national rankings. http://www.cheapjordanshoes.us.org Established in 2005 in memory of Graves’ firstborn son, the Jackson L.
Nice pop for the position. michael kors handbags I can think back to a year a half ago when I came here and how I got my head kicked in, and I’m pretty glad I came.
Though far from amazing, they’re still louder and crisper than most single-speaker setups. cheap ray bans Still, the season included a 7AWest conference title, .
s And nearly nine out of ten see the health of the Gulf as important to their states’ economies. ray ban sunglasses The darkness can never overcome the light.
Forest Service reported more than twice the number of incidents than the other five agencies combined, but they have been lobbying for arms for years and one way to lobby is to document a lot of incidents, even small ones. coach factory outlet Doug Martin remained in Tampa. n michael kors outlet online
The Panthers were unable to get closer than seven the remainder of the contest http://www.louisvuitton-outlet.us.org Everything went as planned the old-fashioned way in a hospital bed – no bath tub, no home birth or anything like that, which seems to be popular in Denmark these days.
b Mariota provided a glimpse of what could happen during his against Jacksonville Nov. 19. Mariota took off on a read option play and sprinted to the end zone. coach online store It’s a bareknuckles business in which rivals try to beat each other to the doorsteps of residents who may have no idea of the wealth beneath their land. s
Islanders CFOEric Pettis reestablished his commitment to staying in central Pennsylvania after considering a move to Nashvilleor the Lehigh Valley. cheap nfl jerseys What the experience did, he said, is provide a strong connection between the players, coaches and parents. michael kors online
So one of my pleasures has been taken from me. If I divorce him it will still be single cooking, but I won’t have to pretend I am part of a household. Do you think vegetarianism should be grounds for divorce? michael kors outlet Daw, who is also a software engineer, said he’s never been a fan of the state’s computer voting machines they require a lot of equipment and their operating systems are easy to hack, he said. t michael kors bags
With Taron Egerton, Hugh Jackman and Christopher Walken oakley sunglasses I am lucky to have known them.
Dr. Louis Picker The Oregonian/OregonLive coach outlet online I’d pull into a spot, and there’d be a boat fishing it. y oakley glasses
Did McConnell feel that way when GOP icon former President Ronald Reagan nominated Supreme Court Justice Anthony Kennedy late in his term? No, and he actually he voted for Kennedy. coach outlet store online The result is a simple drop cookie that is simultaneously delicate and fudgy with a heady punch of mint.
[回复]
钟祥论坛
[回复]
using cialis viagra together
viagra cheap
buy legitimate viagra
[url=http://gjviagratjw.com/#]online viagra[/url]
viagra 50 mg effetti
cialis liquid for sale
cheap cialis online
buy cialis in canada online
[url=http://fycialisgke.com/#]cheap cialis[/url]
cheap cialis overnight
[回复]
عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/عقارات الرحاب/عقارات مدينتى/
عقارات مدينتى والرحاب/كونتكت/عقارات مدينتي/فيلات مدينتى/فلل للبيع/
شقق مدينتى/شقق للبيع بمدينتى/عقارات مدينتى/عقارات مدينتى للبيع/عقارات مدينتى/عقارات مدينتى/عقارات للبيع بمدينتى/عقارات الرحاب/اعلانات مبوبة/
اعلانات عقارات/
اعلانات مدينتى/اعلانات/عقارات/عقارات للايجار/عقارات للبيع
/موتوسيكلات/اعلانات عربيات/اجهزة منزلية/تلفزيون/كمبيوتر/ملابس حريمى/ملابس رجالى
/فساتين افراح/اعلانات سعات
/موبيلات/ارقام تلفون مميزة/معدات رياضية/مستلزمات اطفال/العاب اطفال/اعلانات وظائف/افراد امن
/اعلانات توظيف/مطلوب سكرترية/حيوانات اليفة
/كلاب للبيع/قطط للبيع/اعلانات خدمات/اعلانات عروض شركات/اعلانات اعمال صيانة/حفلات/اعلانات مبوبة/اعلانات مجانا
/منتجات تخسيس/اضافة اعلان/اعلان/كونتكت
شقق للايجار بمدينتي/شقق للبيع فى مدينتى/شقق للايجار في الرحاب/شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للبيع في مدينتي بالتقسيط/فلل للبيع في مدينتي/شقق مفروشة للايجار في مدينتي/شقق للايجار بمدينتي/
شقق للبيع فى مدينتى/شقق للايجار في الرحاب/
شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للبيع في مدينتي بالتقسيط/فلل للبيع في مدينتي/شقق مفروشة للايجار في مدينتي/شقق للايجار بمدينتي/شقق للبيع فى مدينتى/شقق للايجار في الرحاب/شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للبيع في مدينتي بالتقسيط/فلل للبيع في مدينتي/شقق مفروشة للايجار في مدينتي/
شقق للايجار بمدينتي/شقق للبيع فى مدينتى/شقق للايجار في الرحاب/شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للبيع في مدينتي بالتقسيط/فلل للبيع في مدينتي/
شقق مفروشة للايجار في مدينتي/شقق للايجار بمدينتي/شقق للبيع فى مدينتى/شقق للايجار في الرحاب/شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للبيع في مدينتي بالتقسيط/فلل للبيع في مدينتي/شقق مفروشة للايجار في مدينتي/
شقق للايجار بمدينتي/شقق للبيع فى مدينتى/شقق للايجار في الرحاب/شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للايجار بمدينتي/شقق للبيع فى مدينتى/شقق للايجار في الرحاب/شقق للبيع فى الرحاب/شقق للبيع في الرحاب بالتقسيط/شقق للبيع في مدينتي بالتقسيط/فلل للبيع في مدينتي/شقق مفروشة للايجار في مدينتي/
اعلانات بغداد/اعلانات الدوحة/اعلانات بيروت/اعلانات الرياض/اعلانات مكة/اعلانات الجزائر/اعلانات ابوظبى/اعلانات دبى/اعلانات عمان/اعلانات بورسعيد/اعلانات طنطا/اعلانات البصرة/
[回复]