- 浏览: 896749 次
- 性别:
- 来自: 太原
文章分类
- 全部博客 (198)
- Linux/Unix (38)
- TinyOS / NS-2 for『WSN』 (44)
- 思想的拼图 (5)
- 开源 OpenSource (2)
- Framework 开发框架 (0)
- Software Engineering 软件工程 (2)
- IT项目管理 (6)
- Networking 网络技术 (2)
- Java (6)
- C语言 ANSI C (22)
- .NET / C# (9)
- C++ (12)
- Web 语言 Html/Xml (5)
- Groovy on Grails (1)
- Algorithm 算法 (1)
- Database 数据库技术 (5)
- Tools (21)
- VM 虚拟机 (3)
- WSN (wireless sensor network) (2)
- Linux 命令专辑 (3)
- PHP (0)
- 办公软件 (3)
最新评论
-
cfczdws:
感谢楼主,查了半天终于发现居然是htmlentities()做 ...
htmlentities()函数把中文转成了乱码 -
decoxiaohan:
这本书的名字 有谁知道????~~~
OMNeT++中文用户手册(完全版) -
huonie:
怎么下载啊
OMNeT++中文用户手册(完全版) -
huonie:
没有内容啊
OMNeT++中文用户手册(完全版) -
kyx0413:
谢谢先 先看看
OMNeT++中文用户手册(完全版)
emacs很强大,但是强大是以复杂的配置为前提的!没有配置好的时候,可能它比notepad还要难用。
前一段时间我就被缩进弄得晕头转向,tab经常是缩进5个空格,源码会乱,等等,我都几乎要放弃emacs了。
今天偶然看了看emacs自带的manual中的cc-mode一节,哇,发现新大陆了!不光讲得很细,还有个例子,拷过来就可以用了,那缩进,怎一个酷字了得!
offset参数详情
c-hanging-braces-alist 控制大括号后自动加新行,class-open after 表示在新建class的大括号后自动另起一行, 比如
这里可以根据自己的喜好修改,通过在想要设置自动新行的大括号前按RET(回车), 然后按C-c,C-s 找出大括号的语义(Syntactic context of brace), 然后在c-hanging-braces-alist中加入对它的设置。比如得到的语义为substatement-open, 就把c-hanging-braces-alist加入(substatement-open after)
如果想要在除了缩进的地方(每行开头)的其他地方使用TAB来插入多个空格, 而不是错定格式。
把(c-tab-always-indent . t)
改为
(c-tab-always-indent . nil)
后来又参考了王垠、ann77的主页,将tab和缩进基本搞定,下面是配置内容:
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
(setq tab-stop-list (cons (* x 4) tab-stop-list)))
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(cpp-macro . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"My C Programming Style")
;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))
;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;; other customizations
(setq tab-width 4
;; this will make sure spaces are used instead of tabs
indent-tabs-mode nil)
;; we like auto-newline and hungry-delete
(c-toggle-auto-hungry-state 1)
;; key bindings for all supported languages. We can put these in
;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
(define-key c-mode-base-map "\C-m" 'c-context-line-break)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Hanging Semicolons and Commas
— User Option: c-hanging-semi&comma-criteria
This style variable takes a list of functions; these get called when you type a semicolon or comma. The functions are called in order without arguments. When these functions are entered, point is just after the newly inserted `;' or `,' and they must preserve point (e.g., by using save-excursion). During the call, the variable c-syntactic-context is bound to the syntactic context of the current line1 see Custom Braces. These functions don't insert newlines themselves, rather they direct CC Mode whether or not to do so. They should return one of the following values:
t
A newline is to be inserted after the `;' or `,', and no more functions from the list are to be called.
stop
No more functions from the list are to be called, and no newline is to be inserted.
nil
No determination has been made, and the next function in the list is to be called.
Note that auto-newlines are never inserted before a semicolon or comma. If every function in the list is called without a determination being made, then no newline is added.
In AWK mode, this variable is set by default to nil. In the other modes, the default value is a list containing a single function, c-semi&comma-inside-parenlist. This inserts newlines after all semicolons, apart from those separating for-clause statements.
— Function: c-semi&comma-no-newlines-before-nonblanks
This is an example of a criteria function, provided by CC Mode. It prevents newlines from being inserted after semicolons when there is a non-blank following line. Otherwise, it makes no determination. To use, add this function to the front of the c-hanging-semi&comma-criteria list.
(defun c-semi&comma-no-newlines-before-nonblanks ()
(save-excursion
(if (and (eq last-command-char ?\;)
(zerop (forward-line 1))
(not (looking-at "^[ \t]*$")))
'stop
nil)))
— Function: c-semi&comma-inside-parenlist
— Function: c-semi&comma-no-newlines-for-oneline-inliners
The function c-semi&comma-inside-parenlist is what prevents newlines from being inserted inside the parenthesis list of for statements. In addition to c-semi&comma-no-newlines-before-nonblanks described above, CC Mode also comes with the criteria function c-semi&comma-no-newlines-for-oneline-inliners, which suppresses newlines after semicolons inside one-line inline method definitions (e.g. in C++ or Java).
用法: 在c-hanging-colons-alist后
前一段时间我就被缩进弄得晕头转向,tab经常是缩进5个空格,源码会乱,等等,我都几乎要放弃emacs了。
今天偶然看了看emacs自带的manual中的cc-mode一节,哇,发现新大陆了!不光讲得很细,还有个例子,拷过来就可以用了,那缩进,怎一个酷字了得!
offset参数详情
c-hanging-braces-alist 控制大括号后自动加新行,class-open after 表示在新建class的大括号后自动另起一行, 比如
class newClass { ... }
这里可以根据自己的喜好修改,通过在想要设置自动新行的大括号前按RET(回车), 然后按C-c,C-s 找出大括号的语义(Syntactic context of brace), 然后在c-hanging-braces-alist中加入对它的设置。比如得到的语义为substatement-open, 就把c-hanging-braces-alist加入(substatement-open after)
如果想要在除了缩进的地方(每行开头)的其他地方使用TAB来插入多个空格, 而不是错定格式。
把(c-tab-always-indent . t)
改为
(c-tab-always-indent . nil)
后来又参考了王垠、ann77的主页,将tab和缩进基本搞定,下面是配置内容:
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
(setq tab-stop-list (cons (* x 4) tab-stop-list)))
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(cpp-macro . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"My C Programming Style")
;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))
;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;; other customizations
(setq tab-width 4
;; this will make sure spaces are used instead of tabs
indent-tabs-mode nil)
;; we like auto-newline and hungry-delete
(c-toggle-auto-hungry-state 1)
;; key bindings for all supported languages. We can put these in
;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
(define-key c-mode-base-map "\C-m" 'c-context-line-break)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Hanging Semicolons and Commas
— User Option: c-hanging-semi&comma-criteria
This style variable takes a list of functions; these get called when you type a semicolon or comma. The functions are called in order without arguments. When these functions are entered, point is just after the newly inserted `;' or `,' and they must preserve point (e.g., by using save-excursion). During the call, the variable c-syntactic-context is bound to the syntactic context of the current line1 see Custom Braces. These functions don't insert newlines themselves, rather they direct CC Mode whether or not to do so. They should return one of the following values:
t
A newline is to be inserted after the `;' or `,', and no more functions from the list are to be called.
stop
No more functions from the list are to be called, and no newline is to be inserted.
nil
No determination has been made, and the next function in the list is to be called.
Note that auto-newlines are never inserted before a semicolon or comma. If every function in the list is called without a determination being made, then no newline is added.
In AWK mode, this variable is set by default to nil. In the other modes, the default value is a list containing a single function, c-semi&comma-inside-parenlist. This inserts newlines after all semicolons, apart from those separating for-clause statements.
— Function: c-semi&comma-no-newlines-before-nonblanks
This is an example of a criteria function, provided by CC Mode. It prevents newlines from being inserted after semicolons when there is a non-blank following line. Otherwise, it makes no determination. To use, add this function to the front of the c-hanging-semi&comma-criteria list.
(defun c-semi&comma-no-newlines-before-nonblanks ()
(save-excursion
(if (and (eq last-command-char ?\;)
(zerop (forward-line 1))
(not (looking-at "^[ \t]*$")))
'stop
nil)))
— Function: c-semi&comma-inside-parenlist
— Function: c-semi&comma-no-newlines-for-oneline-inliners
The function c-semi&comma-inside-parenlist is what prevents newlines from being inserted inside the parenthesis list of for statements. In addition to c-semi&comma-no-newlines-before-nonblanks described above, CC Mode also comes with the criteria function c-semi&comma-no-newlines-for-oneline-inliners, which suppresses newlines after semicolons inside one-line inline method definitions (e.g. in C++ or Java).
用法: 在c-hanging-colons-alist后
(c-hanging-colons-alist . ((case-label) (label after) (access-label after) (member-init-intro before) (inher-intro))) (c-hanging-semi&comma-criteria . (c-semi&comma-no-newlines-before-nonblanks c-semi&comma-inside-parenlist c-semi&comma-no-newlines-for-oneline-inliners))
发表评论
-
ksh 使用手记
2009-12-03 20:52 18931. 实现像bash那样上下方向键显示^[[A,^[[B,不能 ... -
Linux建立本地cvs服务器
2009-08-14 22:25 1590在RH Linux上快速建立本地CVS服务器的小指南 前提, ... -
如何在 Linux 中执行命令?
2009-08-12 21:01 24191、怎样在后台执行命令 ... -
linux查看命令/文件所在路径的命令及修改
2009-08-12 21:01 36173whereis 用来查看一个命令或者文件所在的绝对路径,而 w ... -
我的 emacs 配置文件
2009-08-11 18:29 3584; Set up nesC syntax highligh ... -
linux share文件
2009-07-27 20:57 2208安装好samba并在share folder中设置好想要共享的 ... -
Emacs学习笔记
2009-07-24 23:09 18081. 如何安装el文件 A:单个文件直接放入 ... -
Ubuntu中emacs23 的字体设置和emacs初始窗口位置的小经验
2009-07-24 19:09 7802Debian users, if your emacs sta ... -
scim 智能拼音消失的恢复办法
2009-07-06 19:48 1520完全删掉~/.scim后重启scim -
Linux 字符操作指令
2009-07-03 01:19 1286awk awk 用来从文本文件中提取字段。缺省地,字段分割符 ... -
Shell编程学习摘录十三--shell函数
2009-07-02 01:16 4148shell允许将一组命令集 ... -
Linux Shell脚本编写详解
2009-07-01 23:56 58601. Linux 脚本编写基础 1.1 语法基本介绍 1 ... -
Grep用法
2009-06-25 23:40 24761. grep简介 grep (global search ... -
ubuntu不能识别U盘的问题
2009-06-19 01:57 21184ubuntu插入u盘后,系统没 ... -
linux编程环境配置
2009-06-16 21:29 1078Gedit 1. 在Edit->Perferen ... -
Ubuntu英文版中显中文
2009-06-16 00:13 2546添加中文语言包 方法1. 在system->找到 ... -
linux之less/more命令
2009-06-11 19:46 4027名称:less 使用权限:所有使用者 使用方式:les ... -
Ubuntu 修改默认启动项
2009-06-05 16:22 1876sudo cp /boot/grub/menu.lst /bo ... -
Emacs 显示行号
2009-04-11 21:52 4567显示行号 把linum.el放到加载路径~/.emacs.d ... -
Emacs Mode for GDB
2009-04-11 01:41 1723Emacs Mode for GDB A graphical ...
相关推荐
"emacs缩进问题"主要集中在如何设置和调整Emacs以适应特定的缩进规范,比如K&R(Kernel Normal Routine)、Allman或GNU等不同的缩进风格。 首先,我们需要理解Emacs中的缩进控制。在Emacs中,`electric-indent-mode...
Emacs是一款强大的文本编辑器,深受程序员和高级用户喜爱,其可扩展性是它的一大亮点。Projectile是一款专为Emacs设计的插件,旨在优化开发者在多项目环境中的工作流程,提升开发效率。通过集成Projectile,用户可以...
Verilog Mode是Emacs为Verilog语言设计的专用模式,提供了许多针对Verilog编程的便利功能,如语法高亮、自动缩进、宏定义和自动补全等。 在Emacs中安装和配置Evil插件,可以极大地提高开发效率,尤其是对于那些喜欢...
- **基本描述**: 支持XML和NXML (Namespace XML) 文档的自动缩进和格式化。 - **有用链接**: [Emacs Wiki关于XML模式的信息](https://www.emacswiki.org/emacs/XMLMode) ##### 1.10 Boxquote - **基本**: 用于创建...
4. **交互式Python shell**:使用`C-c C-z`可以在Emacs内部启动一个新的Python Shell(通过`python-shell`命令),实现代码测试和调试。 5. **文档查看**:`C-h f`查看函数文档,`C-h v`查看变量文档,`M-.`跳转到...
`python-mode.el`是Emacs中的Python编程模式,它提供了语法高亮、自动缩进、代码补全等功能,极大地提升了Python编程体验。`pycomplete.el`是Python代码补全工具,它能够与`python-mode.el`协同工作,提供智能提示,...
它可以通过内置的编程语言模式如Java Mode,提供语法高亮、自动缩进、代码补全等功能。此外,通过集成像JDEE(Java Development Environment for Emacs)这样的扩展,Emacs可以进一步增强对Java项目的调试和管理能力...
Emacs是一款强大的文本编辑器,深受程序员和程序员爱好者们的喜爱,因为它的高度可配置性和丰富的扩展功能。在Emacs的世界里,"配置"是至关重要的,因为它可以根据个人的工作需求进行定制,实现高效的工作流。本篇...
3. **加载库和扩展**:`(require '库名)`用于加载Emacs库,`(add-to-list 'load-path "路径")`可以添加额外的搜索路径,以便找到自定义的库或插件。 4. **界面定制**:通过设置`frame`和`window`的属性,可以调整...
除了基本的语法高亮和补全,C#-mode可能还包括代码折叠、自动缩进、宏录制与播放、多文件项目管理等功能。Emacs的威力在于其强大的交互性,用户可以利用Elisp(Emacs Lisp)编写自定义函数,进一步扩展C#-mode的功能...
- **自动插入匹配的括号**:当输入左括号时自动添加相应的右括号。 - **缩进**:根据代码结构自动调整缩进。 - **选择矩形区域**:允许在非连续的多行之间选择文本。 - **语法检查**:实时检查代码语法错误。 - **...
2. **自动缩进**:根据 Haskell 的语法规则,`haskell-mode` 可以自动调整代码的缩进,保持代码整洁且遵循语言的规范。 3. **自动补全**:提供了基于当前项目和已安装库的代码补全功能,帮助开发者快速输入函数和...
- **自动缩进**:Emacs能够自动调整代码或文本的缩进,保持良好的格式。 - **文本属性**:可以为文本添加额外属性,例如字体加粗、斜体等。 #### 十九、程序编辑与调试 - **语法检查**:Emacs支持语法检查插件,...
这是一款为Emacs设计的Scala语言模式,它提供了语法高亮、自动缩进、代码补全、括号匹配等特性,极大地提升了Scala开发的便利性。在Emacs中,你可以通过MELPA(Marmalade Repository)或ELPA(Emacs Lisp Package ...
- **日记记录**:支持日记条目的添加和查询。 #### 三十二、自定义设置 - **个性化配置**:支持用户自定义配置文件,实现高度个性化。 - **定制界面**:提供定制界面的功能,如菜单、工具栏等。 #### 三十三、...
这段配置意味着Emacs将使用4个空格作为缩进单位,并且在新的缩进中使用空格而不是制表符。这对于保持代码整洁,特别是在多人协作的项目中,有着非常大的帮助。 除此之外,Emacs还允许用户定制各种快捷键,以提高...
- **基本描述**:Emacs 支持对 NXML 和 XML 代码的自动缩进和格式化。 - **特点**: - 根据 XML 元素的嵌套结构自动调整缩进。 - 支持对标签进行自动闭合。 - **有用链接**:[Emacs XML 缩进文档]...
用户可以在家目录下的`.emacs`文件中添加永久性的自定义设置,该文件在每次启动时会被加载。 ##### 4.3 Customize Package Emacs自带了一个名为Customize的包,它提供了一个友好的图形界面,用于管理各种设置。 ##...
此外,`emacs-sql-indent`还提供了快捷键和命令来手动调整缩进,例如,`C-M-\`可以重排当前行的缩进,而`C-c C-i`则可以为当前光标所在语句进行正确的缩进。这些功能使得在Emacs中编写SQL代码更加高效。 为了更好地...
用户可以在配置文件中定义各种模式的行为,如自动缩进、语法高亮、自动补全等。 4. **快捷键绑定**:Emacs使用键盘快捷键进行操作,用户可以根据个人习惯重新绑定快捷键,提高工作效率。 5. **自定义设置**:Emacs...