- 浏览: 885629 次
- 性别:
- 来自: 太原
文章分类
- 全部博客 (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 18331. 实现像bash那样上下方向键显示^[[A,^[[B,不能 ... -
Linux建立本地cvs服务器
2009-08-14 22:25 1535在RH Linux上快速建立本地CVS服务器的小指南 前提, ... -
如何在 Linux 中执行命令?
2009-08-12 21:01 23671、怎样在后台执行命令 ... -
linux查看命令/文件所在路径的命令及修改
2009-08-12 21:01 36113whereis 用来查看一个命令或者文件所在的绝对路径,而 w ... -
我的 emacs 配置文件
2009-08-11 18:29 3513; Set up nesC syntax highligh ... -
linux share文件
2009-07-27 20:57 2169安装好samba并在share folder中设置好想要共享的 ... -
Emacs学习笔记
2009-07-24 23:09 17491. 如何安装el文件 A:单个文件直接放入 ... -
Ubuntu中emacs23 的字体设置和emacs初始窗口位置的小经验
2009-07-24 19:09 7753Debian users, if your emacs sta ... -
scim 智能拼音消失的恢复办法
2009-07-06 19:48 1460完全删掉~/.scim后重启scim -
Linux 字符操作指令
2009-07-03 01:19 1252awk awk 用来从文本文件中提取字段。缺省地,字段分割符 ... -
Shell编程学习摘录十三--shell函数
2009-07-02 01:16 4112shell允许将一组命令集 ... -
Linux Shell脚本编写详解
2009-07-01 23:56 58121. Linux 脚本编写基础 1.1 语法基本介绍 1 ... -
Grep用法
2009-06-25 23:40 24401. grep简介 grep (global search ... -
ubuntu不能识别U盘的问题
2009-06-19 01:57 21090ubuntu插入u盘后,系统没 ... -
linux编程环境配置
2009-06-16 21:29 1040Gedit 1. 在Edit->Perferen ... -
Ubuntu英文版中显中文
2009-06-16 00:13 2488添加中文语言包 方法1. 在system->找到 ... -
linux之less/more命令
2009-06-11 19:46 3970名称:less 使用权限:所有使用者 使用方式:les ... -
Ubuntu 修改默认启动项
2009-06-05 16:22 1827sudo cp /boot/grub/menu.lst /bo ... -
Emacs 显示行号
2009-04-11 21:52 4501显示行号 把linum.el放到加载路径~/.emacs.d ... -
Emacs Mode for GDB
2009-04-11 01:41 1676Emacs Mode for GDB A graphical ...
相关推荐
emacs的缩进风格问题,c/c++模式下。
一个Emacs插件,支持快速定位到项目文件,支持项目全文查找。
emacs-batch-indent是一个命令行程序,在批处理模式下使用Emacs可以缩进标准输入上给出的Common Lisp , Emacs Lisp和Scheme代码。 缩进的代码将写入标准输出。 该脚本最初被编写为用作Vim缩进Lisp的equalprg 。 ...
通过强制执行固定和自动平衡布局来管理窗口大小
Emacs-28.1添加右键快捷菜单.reg
Emacs详细安装配置,yasnippet和代码自动提示,强烈推荐 将文件解压到你的home目录下就可以,windows系统下放到 C:\Users\你的名字\AppData\Roaming下或者你自己设置的EMACS HOME目录
突出显示Emacs的缩进 提供两种次要模式: highlight-indentation-mode和highlight-indentation-current-column-mode highlight-indentation-mode显示准则缩进(仅空格缩进)。 highlight-indentation-current-...
在emacs中控制后台程序自动重启,当程序挂死或者被kill了之后,emacs会自动重启改程序
Jedi.el-Emacs的Python自动完成 链接: (已) (带有emacs-jedi标签) (在GitHub上) (在GitHub上) 它是什么? Jedi.el是Emacs的Python自动完成包。 它旨在以无损方式帮助您的Python编码。 它还可以帮助您...
- Emacs Lisp 添加了新的 "advice" 机制 - 文件提醒支持 - 基于像素的 frames 和 windows 缩放 - 文本终端支持菜单 - 添加新的 rectangular mark mode (C-x SPC) 更多内容请看 etc/NEWS 文件,使用 `C-h n...
emacs模版,定制linux下的emacs编辑环境,自动添加代码模版,快速高效。
emacs windows下emacs 编辑器 据说是神的编辑器
windows下安装emacs及添加配置文件代码
NULL 博文链接:https://tenanchris.iteye.com/blog/566790
emacs-jedi, python的自动完成 Jedi.el-- Emacs的python 自动完成链接:文档( 开发) ( 发布版本)屏幕截图配置文件命令常见问题解答故障排除完整概述变更日志文件中的A & ( 带有 emacs-jedi 标记)
GNU Emacs 是什麽 GNU EMACS 的特质 Emacs 的线上辅助说明 Emacs 的基本知识 Emacs 的自学教材 Ctrl-h 的用法 Emacs 的 info 使用说明 Emacs 的整合环境 如何在 Emacs 中执行 Shell 的指令 有关目录的编辑...
Emacs-28.2添加右键快捷菜单
本压缩包包括了:living in emacs, survive in emacs & gnu emacs pocket referrence. 希望大家喜欢
Emacs使用详解Emacs使用详解Emacs使用详解
emacs-elixir, Emacs主要Elixir模式 Elixir模式提供字体锁定,缩进和导航支持 Elixir程序语言。 安装工具通过 package.el通过 el手动使用情况交互式命令配置文件Keymapping注释工具集成工具。