Will Song

Will Song的博客

他的个人主页  他的博客

大家帮我改进下emacs配置

Will Song  2010年05月13日 星期四 10:21 | 2251次浏览 | 4条评论

多谢社区提供的一些支持,包括小包的博客,还有夏老师在org上的文章:http://www.zeuux.org/science/learning-emacs.cn.html

昨天看了小包的那篇文章:http://www.zeuux.com/blog/content/2858/

觉得实在太复杂了。

我只是想作个适合开发的简单配置,用到的语言也就C和C++,还有Python(刚开始接触)。

emacs配置的语法,我实在没搞清楚(一开头那两括号我就不明白什么意思~),所以大多照葫芦画瓢。。。

忙活了一大早晨,终于能凑合用了。。。

我知道社区有很多牛人,我想把配置贴上来,大家帮看一下有没有什么问题:比如重复没用的废话啦、缺少的基本设置啦,当然太复杂的东西不是我追求的,毕竟我只是要个开发环境就OK。

大家多关照啦~~~

先截个图:

 

 

最后就是还有几个小问题希望有高手帮解决下:

1、如何设置代码的自动提示和补全功能(没这个功能感觉很不爽啊~)

2、如何默认打开emacs就全屏或最大化(这个试了几次都没成功~)

3、自定义快捷键个部分,有经验的人欢迎来详细分享下

over...

------------------------------------------

.emac如下:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

(custom-set-variables; 一开始这里的设置和之后的设置有什么区别呢?

'(column-number-mode t);显示列号

;'(display-time-mode t)

'(size-indication-mode t)

'(transient-mark-mode nil)

'(global-linum-mode t)

'(cua-mode nil)

'(show-paren-mode t nil (paren))

)

(custom-set-faces

)

;我的Emacs配置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-to-list 'load-path "/usr/local/share/emacs/my_plus"); 自己的插件包

;(require 'color-theme);主题颜色

;(color-theme-dark-blue)

(require 'setnu);第行前显示行号

(setnu-mode t)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;设置颜色;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(set-cursor-color "Wheat")

(set-mouse-color "Wheat")

(set-foreground-color "Wheat")

(set-background-color "DarkSlateGray")

;;设置时间格式;;;;;;;;;;;;;;;;;;;;;;;;;;;

(display-time-mode t)

(setq display-time-12hr-format t)

(setq display-time-day-and-date t)

(setq visible-bell t);关闭出错提示声

(setq inhibit-startup-message t);关闭开启画面

(setq backup-inhibited t);;不产生备份

(setq auto-save-default nil);不生成名为#filename#的临时文件

(setq default-major-mode 'text-mode);;设置默认模式是text mode

(global-font-lock-mode t);语法高亮

(auto-image-file-mode t);打开图片显示功能

(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴

(setq frame-title-format '("" buffer-file-name "@emacs" ));标题栏显示buffer名

(setq default-directory "/home/blueboy/Program");设置缺省目录

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;鼠标滚轮,默认的滚动太快,这里改为3行;;;;;;

(defun up-slightly () (interactive) (scroll-up 3))

(defun down-slightly () (interactive) (scroll-down 3))

(global-set-key [mouse-4] 'down-slightly)

(global-set-key [mouse-5] 'up-slightly)

;;自定义按键;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 这部分内容实在搞不清楚啦

(global-set-key [f1] 'shell);F1进入Shell

(global-set-key [C-f5] 'previous-error)

(global-set-key [f5] 'next-error)

(global-set-key [C-f3] 'python-shell);F3进入Python-Shell

(global-set-key [C-f6] 'gdb);调试

(setq compile-command "make -f Makefile")

(global-set-key [f7] 'compile);F7编译文件

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;Python配置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 刚接触Python啊。。。。

;(require 'python-mode)

(setq auto-mode-alist

(cons '("\\.py$" . python-mode) auto-mode-alist)

);自动关联文件

(setq interpreter-mode-alist

(cons '("python" . python-mode)

interpreter-mode-alist)

)

(autoload 'python-mode "python-mode" "Python editing mode." t)

;;C语言配置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 感觉好罗嗦,能简化吗?

(defun linux-c-mode()

;;;将回车代替C-j的功能,换行的同时对齐;;;;;;

(define-key c-mode-map [return] 'newline-and-indent)

(interactive)

(c-set-style "k&r");设置C程序的对齐风格

(c-toggle-auto-state);自动模式,在此种模式下当你键入{时,会自动根据你设置的对齐风格对齐

(c-toggle-hungry-state);此模式下,当按Backspace时会删除最多的空格,使得if缩进正常

(setq c-basic-offset 4);缩进设置为4

(imenu-add-menubar-index);在菜单中加入当前Buffer的函数索引

(which-function-mode);在状态条上显示当前光标在哪个函数体内部

)

;;C++语言配置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 同上C语言的问题

(defun linux-cpp-mode ()

(define-key c++-mode-map [return] 'newline-and-indent)

(interactive)

(c-set-style "Stroustrup")

(setq c-basic-offset 4)

(c-toggle-auto-state)

(c-toggle-hungry-state)

(imenu-add-menubar-index)

(which-function-mode)

)

(add-hook 'c-mode-hook 'linux-c-mode)

(add-hook 'c++-mode-hook 'linux-cpp-mode)

(setq imenu-sort-function 'imenu--sort-by-name);设置imenu的排序方式为按名称排序

(setq auto-mode-alist

(append '(("\\.h$" . c++-mode)) auto-mode-alist))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !
小包

回复 小包  2010年05月13日 星期四 15:32

http://nschum.de/src/emacs/company-mode/ 呵呵 刚刚又发现一个自动补全,我的emacs整合进去3个自动补全,不过这个出来有点慢,我按三下tab 就会出现这个的补全。。默认是yasnippet 然后是auto-complete最后这个。。

0条回复

马理军

回复 马理军  2010年05月13日 星期四 14:45

针对python:
安装pcmacs,pycomplete就可以实现代码自动补全,我的经验是pcmacs以源代码的方式安装。
yasnippet主要是可以实现与mac 系统下面textmate那种编程效果,例如输入if+tab整个if结构就出来了。

0条回复

小包

回复 小包  2010年05月13日 星期四 14:30

;;自动补全 yasnippet
(add-to-list 'load-path
"~/.emacs.d/plugins")
(require 'yasnippet-bundle)

这个插件很不错。。 不能发视频,,这个插件作者做了个视频演示(http://code.google.com/p/yasnippet/downloads/detail?name=yas_demo.avi&;can=2&q=) 你看下就知道了

下载地址(http://code.google.com/p/yasnippet/downloads/list

昨天我那里面仔细看啊。。

(require 'auto-complete+) ;;这个是ahei按照auto-complete的补充!
(require 'auto-complete-config) ;;这个也是自动补全
;;这个安装参考作者的视频和文件自己找吧!我英语这么烂都能找到 http://www.cx4a.org/pub/ac-demo/ac-demo.html

;;;http://www.emacswiki.org/emacs/AutoComplete 参考资料

1条回复

暂时没有评论

Zeuux © 2024

京ICP备05028076号