您的位置:首页 > 其它

[Editor][002][Emacs] 从零到高级的进阶 - 实践开发 - 帮助菜单主页

2016-09-06 14:55 337 查看

前言:The best way to learn Emacs is incrementally

-  从source insight走到Vim之后,用过VIM的Ctag,cscope时候也是一种选择。然后,对比source insight 对类定义和函数调用的各种引用,感觉vim还是有一定差距。也许,尝试Emacs是最终的选择,这也是笔者尝试重新开始的重要原因,一直觉得emacs很神奇,所以,期待这次努力,能够达到一定境界,能够逐步彻底淘汰掉VIM和Source insight.希望完成这个系列的时候,也是和大家一起能够基本掌握emacs的时候。【】请实践黑色括号扩起来的部分

- 本文主要讨论emacs 的非windows版本、终端模式

1 vim 的一些局限性:

比如Ctag的使用,首先要手动生成,然后,如果遇到有重复的定义,往往只能给你其中一个定义。各个结构,类的定义之间的切换比较困难。

比如Scope的使用,往往查找一个函数的调用,会首先给出一个很长很长的list列表,在里面逐个去查询调用的地方,比起source insight还是差太多了。

2 emacs 的第一步如何使用帮助

2.1 emacs 的进入和帮助菜单主页最基本操作:

如下命令会帮助你进入命令行模式

emacs -nw


版本24的emacs 会进入如下菜单

Welcome to GNU Emacs, one component of the GNU/Linux operating system.

Get help           <f1>
Emacs manual       <f1> r       Browse manuals     <f1> i
Emacs tutorial     <f1> t       Undo changes       C-x u
Buy manuals        <f1> RET     Exit Emacs         C-x C-c
Activate menubar   M-`
(`C-' means use the CTRL key.  `M-' means use the Meta (or Alt) key.
If you have no Meta key, you may instead type ESC followed by the character.)
Useful tasks:
Visit New File                  Open Home Directory
Customize Startup               Open *scratch* buffer

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
of 2014-03-08 on lamiak, modified by Debian
Copyright (C) 2013 Free Software Foundation, Inc.

GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
Emacs is Free Software--Free as in Freedom--so you can redistribute copies
of Emacs and modify it; type C-h C-c to see the conditions.
Type C-h C-o for information on getting the latest version.

2.1.1  两个最最基本快键定义

这里强调了两个主要的快键键值:`C-' means use the CTRL key.  `M-' means use the Meta (orAlt) key.

2.1.2  如何使用帮助菜单主页

type C-h C-w for full details

 【C-h】会进入帮助主菜单

2.1.3 如何退出emacs

Exit Emacs         【C-x C-c】

上面这个“C-x C-c” 是什么意思?

表示: 

1 先按住【Ctrl】 再 加【x】  

2 先按住【Ctrl】 再 加【c】 

做完步骤1,2 之后,会退出emacs

【案】emacs 的命令经常是这种组合按键类型,你看看一个退出都要按键4个才能退出,应该大致能够明白emacs的基本风格了。

2.2 emacs 帮助菜单主页的选项

2.2.1 菜单栏

File Edit Options Buffers Tools Help

2.2.2 编辑区和对应的使用说明

2.2.2.1 Get help

首页菜单对每一个项目都有连接描述
Get help           <f1>
Emacs manual       <f1> r       Browse manuals     <f1> i
Emacs tutorial     <f1> t       Undo changes       C-x u
Buy manuals        <f1> RET     Exit Emacs         C-x C-c
Activate menubar   M-`


【f1> r]】 表示先按F1 再按r

【M-`】表示先按【ALT】在按【`】,会进入菜单条选择菜单,这时候emacs会在右边新开一个窗口,并把菜单里面所有用的一些可能的键值都列表出来。

下面这个是菜单条

File Edit Options Buffers Tools Minibuf Help


读者可以逐个实验,这些命令其实和直接用鼠标在菜单上操作是一致。

Press PageUp key to reach this buffer from the minibuffer.
|Alternatively, you can use Up/Down keys (or your History keys) to change
Get help           <f1>                                                          |the item in the minibuffer, and press RET when you are done, or press the
Emacs manual       <f1> r       Browse manuals     <f1> i                        |marked letters to pick up your choice.  Type C-g or ESC ESC ESC to cancel.
Emacs tutorial     <f1> t       Undo changes       C-x u                         |In this buffer, type RET to select the completion near point.
Buy manuals        <f1> RET     Exit Emacs         C-x C-c                       |
Activate menubar   M-`                                                           |Possible completions are:
(`C-' means use the CTRL key.  `M-' means use the Meta (or Alt) key.             |b==>Buffers               e==>Edit                  f==>File
If you have no Meta key, you may instead type ESC followed by the character.)    |h==>Help                  o==>Options               t==>Tools


上图,比如“f==>File”

这个项目就是开始我们看到的主菜单上面的菜单条上显示的【file】项目

【案】右侧的pop windows 的退出可以用 【C-g】【ESC ESC】的方式,这两种退出方式也是结束pop out menu的主要快键方式。

正如 emacs手册所说,你只要去实践,你就会习惯输入的方式,这就像游泳,你只要会,你就不会忘记,所以,其实没有必要去记忆,只需要去实践就好了。 

2.2.3 底部的mode line的解释

-UUU:%%--F1  *GNU Emacs*    All L7     (Fundamental) ------------------------

2.2.3.1 在mode line中第1个字符

[-UUU]表示字符集,

2.2.3.1 在mode line中第2个字符

[%%]表示打开的文件(buffer)是否可写(先称为文件便于理解,实际上是buffer)
%表示只读,
- 和 * 表示可写。
再一个字符表示文件是否已写,
% 或 - 表示还没动,
*表示已经更改。

这两个字符组合起来有四个状态。
符号
表示
%%  只读,未更改
-- 可写,未更改
** 可写,已更改
%* 只读,已更改

[-] 表示路径

2.2.3.1 在mode line中第3个字符

[GNU Emacs] 后面黑体的 *GNU Emacs* 表示buffer的名称

2.2.3.1 在mode line中第4个字符

[ALL] 后面的All表示光标的位置,当文件在一页就能显示完的时,这里是All,此外还有Top, Bot,以及当前位置百分比。
L7表示第七行。

2.2.3.1 在mode line中第5个字符

【Fundamental】 是模式名

 【小结】本节主要讨论了emacs首次进入时候的界面讯息,并强调了界面首页的基本操作命令。
本节后面给出的参考文献,都具有非常重要的参考价值,后面的章节将逐步展开。敬请期待!

参考:

1 从零开始——Emacs 安装配置使用教程 2015

http://www.jianshu.com/p/b4cf683c25f3

2 学习Emacs系列教程

http://www.cnblogs.com/robertzml/archive/2009/09/10/1564108.html

3 O'Relly Learning GNU Emacs, 3rd Edition

4 emacswiki

https://www.emacswiki.org/

本文原创:

QQ; 28044280

微信公众号:NewTechLife

Email: huang.makin@gmail.com
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: