xxdragen 发表于 2007-12-25 23:03:50

emacs 写C程序问题,几个实用的function

大家好,我用emacs写C程序,现在有几个问题:

1 如何高亮显示所有同名局部变量?
2 如果更改一个变量的名称(或者一个struct 里元素的名称),如何让所有的引用都同时更名?(这个好像对struct很困难)
3 怎么format一个C文件? (以前用Eclipse写Java程序的时候可以很简单的format一个Java文件,不知道对Emacs有没有类似的包)

我再贡献我自己配置里面的几个function,挺方便的,大家看看吧。有些我自己写的,但是因为我对Lisp并不是很熟,大家不要见笑。能用就好。

(defun insert-new-line-up ()
"Opens a new line before the current line. Equivalent to beginning-of-line, open-line"
(interactive) (beginning-of-line) (open-line 1) (indent-according-to-mode)
)

(global-set-key [(control shift return)] 'insert-new-line-up)


(defun insert-new-line-down()
"Opens a new line after the current line."

(interactive) (beginning-of-line 2) (open-line 1) (indent-according-to-mode)
)
(global-set-key [(control return)] 'insert-new-line-down)


;;++++++++++++++ scroll one line up and down ++++++++++++++
(defun scroll-up-one-line ()
(interactive)
(scroll-up 1))

(defun scroll-down-one-line ()
(interactive)
(scroll-down 1))

(global-set-key [(control down)] 'scroll-up-one-line)
(global-set-key [(control up)] 'scroll-down-one-line)

这个我忘了下载地址了,大家自己google一下吧。
;go to the last edit point.
(require 'goto-last-change)
(global-set-key [(meta left)] 'goto-last-change)
页: [1]
查看完整版本: emacs 写C程序问题,几个实用的function