Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12488
  • 博文数量: 14
  • 博客积分: 560
  • 博客等级: 中士
  • 技术积分: 150
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-17 16:40
文章分类
文章存档

2010年(14)

我的朋友
最近访客

分类: LINUX

2010-09-16 13:32:06

1.3. A Word About Modes

1.3. 关于模式

 

Emacs achieves some of its famed versatility by having various editing modes in which it behaves slightly differently. The word mode may sound technical, but what it really means is that Emacs becomes sensitive to the task at hand. When you're writing, you often want features like word wrap so that you don't have to press Enter at the end of every line. When you're programming, the code must be formatted correctly depending on the language. For writing, there's text mode; for programming, there are modes for different languages, including C, Java, and Perl. Modes, then, allow Emacs to be the kind of editor you want for different tasks.

    Emacs拥有很多编辑模式,各种模式都有些微的不同,这也是它以多功能著称的原因之一。模式这个词听起来很专业,但是它实际是含义是:Emacs对你手里的各种任务都很敏锐。当你写作时,你希望有自动换行功能,这样就不用在每行结束时按一下回车键。当你编程时,代码必须按照编程语言的要求格式化好。对于写作,有文本模式;对于编程,不同语言有不同的模式,包括C,JavaPerl等。模式使Emacs针对不同的任务都拥有友好的交互过程。

 

Text mode and Java mode are major modes. A buffer can be in only one major mode at a time; to exit a major mode, you have to enter another one. Table 1-1 lists some of the major modes, what they do, and where they're covered in this book.

    文本模式和Java模式都是主模式。一个缓冲区只有一个主模式,离不开一个主模式就会进入到另一个。表1-1列出了一些主模式,介绍他们的功能以及在本书中介绍的章节。

Table 1-1. Major modes

1-1. 主模式

Mode模式

Function功能

Fundamental mode

基本模式

The default mode ()

默认模式(6章)

Text mode

文本模式

For writing text ()

用于编辑文本(2)

View mode

只读模式

For viewing files but not editing ()

只能浏览文档不能修改(4章)

Shell mode

Shell模式

For running a shell within Emacs ()

Emacs里运行一个Shell5章)

Outline mode

大纲模式

For writing outlines ()

编辑大纲(7章)

Indented text mode

缩进文本模式

For indenting text automatically ()

自动缩进文本(7章)

Paragraph indent text mode

段落缩进文本模式

For indenting the first line of each paragraph ()

自动缩进每段的第一行(7章)

Picture mode

绘图模式

For creating ASCII drawings using the keyboard ()

ASCII码绘图(7章)

HTML mode

HTML模式

For writing HTML ()

编辑HTML8章)

SGML mode

SGML模式

For writing SGML and XML ()

编辑SGMLXML8章)

LaTeX mode

LaTeX模式

For formatting files for TEX and LATEX ()

格式化TEXLATEX文件(8章)

Compilation mode

编译模式

For compiling programs ()

编译程序(9章)

cc mode

CC模式

For writing C, C++, and Java programs ()

编辑CC++Java程序(9章)

Java mode

Java模式

For writing Java programs ()

编辑Java程序(9章)

Perl mode and Cperl mode

Perl模式和CPerl模式

For writing Perl programs ()

编辑Perl程序(9章)

SQL mode

SQL模式

For interacting with databases using SQL ()

SQL访问数据库(9章)

Emacs Lisp mode

EmacsLisp模式

For writing Emacs Lisp functions ( and )

编辑EmacsLisp函数(911章)

Lisp mode

Lisp模式

For writing Lisp programs ( and )

编辑Lisp程序(911章)

Lisp interaction mode

Lisp交互模式

For writing and evaluating Lisp expressions ( and)

编辑和计算Lisp表达式(911章)

Whenever you edit a file, Emacs attempts to put you into the correct major mode for what you're going to edit. If you edit a file that ends in .c, it puts you into cc mode. If you edit a file that ends in .el, it puts you in Lisp mode. Sometimes it looks at the contents of the file rather than just its name. If you edit a file formatted for TEX, Emacs puts you in LaTeX mode. If it cannot tell what mode you should be in, it puts you in fundamental mode, the most general of all. Because Emacs is extensible, add-in modes are also available; we talk about some in this book, though we do not list them in Table 1-1.

    当你编辑文件的时候,Emacs都会尝试根据文件的类型打开相应的主模式,如果你编辑一个以.c结尾的文件,那么Emacs会打开CC模式。如果你编辑一个以.el结尾的文件,那么Emacs会打开Lisp模式。有时Emacs是根据文件内容而不是文件名来确定主模式的。如果你编辑一个按TEX格式排版的文件,Emacs会打开LaTex模式。如果无法确定是哪种模式,则进入通用的基本模式。因为Emacs可扩展,所以附加模式也可以用,我们也会介绍一些1-1表中没有列出的模式。

 

In addition to major modes there are also minor modes. These define a particular aspect of Emacs's behavior and can be turned on and off within a major mode. For example, auto-fill mode means that Emacs should do word wrap; when you type a long line, it should automatically make an appropriate line break. Table 1-2 lists some minor modes, what they do, and where they're covered in this book.

    此外,除了主模式还有副模式。副模式定义了Emacs的一些特殊行为,它们可以在主模式中打开或关闭。自动换行模式表示Emacs可以让文本自动换行,当你输入很长一行的时候,它可以在适当位置自动换行。表格1-2列出了一些副模式,介绍他们的功能以及在本书中介绍的章节。

 

Table 1-2. Minor modes

1.2. 副模式

Mode

Function

Auto-fill mode

自动换行模式

Enables word wrap ().

允许自动换行(2)

Overwrite mode

替代模式

Replaces characters as you type instead of inserting them ().

用你想输入的内容替换你输入的代名词(2)

Auto-save mode

自动保存模式

Saves your file automatically every so often in a special auto-save file ().

定时自动保存文件到特定的自动保存文件中(2

Isearch mode

查找模式

For searching ().

用于查找(3

Flyspell mode

拼写检查模式

For flyspell spell-checker ().

Flyspell prog mode

程序检查模式

For spell-checking programs with flyspell ().

Flyspell检查程序拼写(3

Abbrev mode

简写模式

Allows you to use word abbreviations ().

允许使用单词简写(3

Paragraph indent text mode

段落缩进模式

For indenting the first line of each paragraph ().

自动缩进每段的第一行(7

Refill mode

重新换行模式

A mode in which Emacs attempts to fill paragraphs as you edit them (a bit experimental; mentioned in ).

Emacs对当前正在编辑的段落进行换行操作(一个试验性质的模式,在第2章提到)

Artist mode

艺术家模式

For creating ASCII drawings using the mouse ().

用鼠标绘制ASCII码图片(7)。

Outline mode

大纲模式

For writing outlines ().

编辑大纲(7)。

SGML name entity mode

SGML实体名称模式

For inserting special characters in HTML, SGML, and XML documents ().

用于向HTMLSGMLXML文档中插入指定的实体名称(8)。

ISO accents mode

重音字符模式

For inserting accented characters in text files.

用于输入有重音的字符(法文等cafĉ(load-library "iso-acc")(M-x iso-accents-mode)

Font lock mode

语法高亮模式

For highlighting text in colors and fonts to improve readability (separating, for example, comments from code visually) ().让文本在颜色和字体上变得明显来提高可读性(例如:将代码和注释分开)(9

Compilation mode

编译模式

For compiling programs ().

用于编译程序(9

Enriched mode

强化模式

For saving text attributes ().

用于保存文本的特性(10

VC mode

版本控制模式

For using various version control systems under Emacs ().

Emacs中使用不同的版本控制系统(12

Info mode

信息模式

A mode for reading Emacs's own documentation ().

一个阅读Emacs自身文档的模式(14

 

You may have noticed that several modes, including paragraph indent text mode, outline mode, and compilation mode, are both major and minor modes. Each can be used alone—as a major mode—or with another major mode as a minor mode.

    你或许注意到一些模式即是主模式也是副模式,比如:文本缩进模式,大纲模式,以及编译模式。它们即可以单独作为主模式使用也可以作为副模式与其他主模式一起使用。

 

There are many other modes that we won't discuss, including modes for some obscure but interesting programming languages (like Modula-2). There are also some other modes that Emacs uses itself, like Dired mode for the directory editing feature (described in Chapter 5).

    还有很多其他模式我们没有讨论,包括一些晦涩的但有趣的编程语言(如Modula-2)。还有一些Emacs自身使用的模式,比如用于文件夹管理功能的文件夹模式(第5章介绍)

In addition, if you're good at Lisp programming, you can add your own modes. Emacs is almost infinitely extensible.

    此外,如果擅长Lisp编程,你可以添加你自己的模式。Emacs几乎可以无限扩展。

 

阅读(392) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~