ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

(二) 简单认识Emacs

2021-11-15 11:01:39  阅读:187  来源: 互联网

标签:name 认识 -- color emacs mode 简单 Emacs


一、启动emacs

1.1 命令行启动emacs,并附加相关参数

  1. 启动emacs,同时打开文件
emacs filename 
emacs +15 filename 		//定位到第15行。 
emacs +3:12 filename 	//第3行第12个字符处 
  1. 打开文件,并插入另一个文件
emacs filename1 --insert filename2 
emacs +3:12 file1 --insert  filename2
  1. 改变显示属性
    主要是针对xwindow。
emacs -nw   		//在当前终端打开emacs,不使用xWindow 
emacs --display :0   // 指定应该在什么位置显示 Emacs X 客户端窗口 
emacs --display rs6000:0  //在名为 rs6000 的远程主机的缺省服务器上打开 Emacs 窗口
emacs --geometry WIDTHxHEIGHT\[{<s>-}XOFFSET{</s>-}YOFFSET\]    // 指定客户端窗口的宽度、高度以及可选的 X 和 Y 偏移量
  1. 启动时,添加参数以改变emacs字体和颜色
    下列选项可以控制emacs程序的字体和颜色
    –foreground-color color 或 -fg color 设置前景颜色为 color
    –background-color color 或 -bg color 设置背景颜色为 color
    –border-color color  或 -bd color 设置边框颜色为 color
    –cursor-color color  或 -cr color 设置光标颜色为 color
    –mouse-style color  或 -ms color 设置鼠标指针颜色为 color

  2. 控制所使用的配置文件

emacs -q           		//不运行任何配置文件 
emacs -u joe            //使用joe的配置文件 
emacs --no-site-file 	//不运行全局 site-start.el 文件

Emacs 还有一个全局启动文件 site-start.el,它通常保存在 etc/emacs 目录树中。–no-site-file选项将启动 Emacs,而不执行该文件中的 Emacs Lisp代码。

  1. 启动时,指定执行动作选项
emacs -l load-file-name      //从当前目录,或者EMACS LOADPATH 环境变量指定的目录加载 
emacs -f function-name  	 //执行函数,需要时应提供参数。 
emacs --eval  "(expression)"  //执行表达式
##ex: 
emacs +999 myfile --eval "(insert (current-time-string))"
emacs --batch +35 practice.b --insert myfile -f save-buffer --kill  //批处理方式执行。
  1. 调试模式启动
emacs --debug-init 	

1.2 emacs 参数列表

--visit=filespec   
  --file=filespec  打开 filespec到各自的缓冲区,以进行编辑。 
+row\[:column\]   将光标移动到该文件中的 row行和(可选的)水平位置 column 列(缺省值是 +1:1)。 
--insert file  将文件file 插入到缓冲区的开头。 
--debug-init   对.emacs 启动文件使用 Lisp调试器。 
--no-init-file   
  -q           不运行任何 .emacs 启动文件。 
–no-site-file  不运行全局 site-start.el 文件。 
-u user   
  –user user   使用用户 user 的.emacs 启动文件。 
–funcall function   
  -f function  执行 Emacs Lisp函数。 
--eval expression   
  --execute expression 执行 Emacs Lisp 表达式expression。 
--load file   
  -l file      执行文件 file 中的 Emacs Lisp 指令。
-batch   
  --batch      使用批处理(非交互)模式。 
-kill   
  --kill       当处于批处理模式时,退出 Emacs。 
–name name     使用 name 作为 Emacs X客户端窗口的名称(缺省值是“emacs”)。 
-T title   
  --title title 使用title 作为 Emacs X 客户端窗口的标题(缺省值是 name@FQDN,其中 FQDN是该主机的完全限定域名)。 
--reverse-video   
  -r           使用反向显示方式,交换前景和背景的颜色。 
--iconic   
  -iconic      启动Emacs,并将其作为一个图标,而不是一个活动窗口。 
--icon-type   
  -i           当图标化 Emacs 窗口时,使用 Emacs 图标(通常是/usr/share/emacs/version/etc/gnu.xpm),而不是窗口管理器的任何缺省值。
-fn name   
  -font name   使用 name 作为 Emacs 窗口字体。 
--border-width width   
  -bw width    将窗口边框设置为 width 像素。 
--internal-border width
  -ib width    将窗口内部边框设置为 width 像素。 
--g dimensions
  –geometry dimensions 根据给定的 X 窗口尺寸dimensions(生成窗口的缺省值是 80x40个字符)设置窗口的宽度、高度和位置。 
--foreground-color color   
  -fg color    将前景色设置为 color。 
--background-color color   
  -bg color    将背景色设置为 color。 
--border-color color   
  -bd color    将边框颜色设置为 color。 
--cursor-color color   
  -cr color    将光标颜色设置为 color。 
--mouse-color color   
  -ms color    将鼠标指针颜色设置为 color。 
-d name   
  --display name 在与 name相对应的 X 显示器上打开 Emacs 窗口。 
-nw    
  --no-windows  在X中,不使用X 客户端窗口,而是在当前终端窗口中打开。这一选项不影响控制台会话。 
-t file   
  --terminal file 将标准 I/O 重定向到文件 file,而不是终端。

二、Emacs 中的模式

2.1 major mode(主模式):

经常见到或使用的主模式:

fundmetal mode 
text mode 
mail mode 
RMAIL mode 
view mode 
shell mode
ange-ftp mode 
telnet mode 
outline mode 
indented text mode 
paragraph indet text mode 
picture mode 
nroff mode 
tex mode 
latex mode 
HTML mode
SGML mode

Complilation mode 
cc mode 
java mode 
perl mode and Cperl mode 
SQL mode
FORTRAN mode 
Emacs LISP mode 
LISP mode 
LISP interaction mode

dird mode

2.2 minor mode:

(多个)从模式可以和主模式联合使用,经常用到的从模式有:

auto-fill mode 
overwrite mode 
auto-save mode 
line number mode 
Isearch mode 
flyspell mode 
flyspell prog mode 
transient mark mode  (临时标记模式) 
abbrev mode 
paragraph indent text mode 
Refill mode
Artist mode 
outline mode 
VC mode 
info mode
ido-mode          (interactively do things)

当然,还有一些其他的模式,这里并没有全部列出。
进入/添加某种模式: M-x modename

三、按键缩写

在 Emacs 有大量的快捷键,常用的快捷键缩写如下:

C Ctrl 
M meta, ALT 
S shift 
RET Return 
SPC Spacse 
ESC escape 
TAB TAB 
DEL backspace 
<next> PageDown
<prior> PageUp

四、帮助命令

C-h c (describe-key-briefly) ;;查看键绑定的命令
C-h k (describe-key) ;;查看键对应的命令和简要说明

C-h w (where-is) ;;查看某个命令对应的键绑定

C-h f (describe-function) ;;

C-h v (describe-variable) ;;
C-h m (describe-mode) 查看当前mode中的相关文档,包括帮助、快捷键等。

C-h b (describe-binding) 查看当前mode的所有键绑定列表。
C-h s (describe-syntax)
C-h l (view-lossage) ;;最近输入的100个字符是什么。
C-h e (view-echo-area-message)

C-h t (help-with-tutorial)
C-h r (info-emacs-manual)
C-h i (info)

C-h P (describe package) ;;描述一个包

C-h a (apropos-command) ;;这个概念涉及到哪些命令
M-x apropos ;;这个概念涉及到哪些函数和变量
M-x super-apropos ;;哪些函数和变量的文档里提到了这个概念

M-x apropos-variable
M-x apropos-value
M-x apropos-document

查看某一快捷键开始部分的相关内容
C-x r C-h
C-x 4 C-h

五、emacs server模式

emacs可以作为 Server运行在另一台机器上,而在另一台机器上可以启动 emacsclient链接 Emacs Server后端。

5.1 emacs 作为 server

方法一: 启动emacs后,运行 M-x server-start

因为一个机器上可以启动多个emacs server,为了区分,可以指定服务器名字:
M-x set-variable RET server-name RET “foo” RET

方法二:添加命令行参数。
采用这种方法,emacs启动后将直接返回到控制台。

emacs –daemon
emacs –eval “(setq server-name \\"foo\\")" –daemon  //服务模式启动,并指定服务器名字。

指定服务器名字后,可以使用emacsclient -s参数明确所访问的emacs server

5.2 启动emacsclient

emacsclient filename

可以指定调用的服务器名字:

emacsclient -s server-name

5.2.1 emacsclient 命令行选项:

-c GUI界面 
-t text terminal

5.3 kill emacs daemon

M-x kill-emacs

标签:name,认识,--,color,emacs,mode,简单,Emacs
来源: https://blog.csdn.net/roaman/article/details/121284193

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有