我的emacs配置

学习ruby on rails 两年了,期间使用过Eclipse和Netbeans,半年以前开始使用emacs。
经过刚开始的不适,半年来不断到处拷代码,改配置。最近感觉逐渐使得顺手了。
把配置贴出来做一个记录,也希望能对其他人有启发或者帮助 :)

model:
[img]http://zzhang.iteye.com/upload/attachment/131957/3cab88d3-e14c-3135-b896-cd2b3cfd8e4b.png[/img]
view:
[img]http://zzhang.iteye.com/upload/attachment/131958/68d59241-e29a-30dd-a1d1-54a70c4f232a.png[/img]

[b]
自定义常用快捷键:[/b]
F5 compile
F12 kill buffer
C-F12 kill rinari files
C-w kill one line
s-m choose model
s-c choose controller
s-g go to line
s-o commit code
s-u uncommit code
s-h hide all methods
s-s show all methods
s-t toggle block
s-a find file in rails project



;;show file in title
(setq frame-title-format '("%f"))

;;'y' for 'yes', 'n' for 'no'
(fset 'yes-or-no-p 'y-or-n-p)

;;highlight current line
(require 'hl-line)
(global-hl-line-mode t)

;;screen set
(setq default-frame-alist '((top . 2) (left . 2) (height . 30) (width . 110)))

;;ido
(require 'ido)
(setq ido-confirm-unique-completion t)
(setq ido-default-buffer-method 'samewindow)
(setq ido-use-filename-at-point t)
(setq ido-enable-flex-matching t)
(ido-mode t)
(ido-everywhere t)
(set-face-background 'ido-first-match "green")
(set-face-foreground 'ido-subdir "blue3")

;;cursor
(setq-default cursor-type 'bar)

;;copy to other place
(setq x-select-enable-clipboard t)

;;no backup file
(setq make-backup-files nil)

;;twilight theme
(setq load-path (cons "~/.emacs.d/themes" load-path))
(require 'color-theme)
(color-theme-initialize)
(load-file "~/.emacs.d/themes/color-theme-twilight.el")
(color-theme-twilight)

;;ecb
(load-file "~/.emacs.d/cedet/common/cedet.el")
(global-ede-mode 1) ; Enable the Project management system
(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion
(global-srecode-minor-mode 1) ; Enable template insertion menu
(setq load-path (cons "~/.emacs.d/ecb" load-path))
(require 'ecb)
(setq ecb-auto-activate t)
(add-hook 'ecb-activate-hook
'(lambda()
(setq ecb-auto-activate t
ecb-tip-of-the-day nil
)))

;;better copy
(defadvice kill-ring-save (before slickcopy activate compile)
"When called interactively with no active region, copy a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
(defadvice kill-region (before slickcut activate compile)
"When called interactively with no active region, kill a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))

;;org mode
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-hide-leading-stars t)
(setq org-log-done t)

;;add one line
(global-set-key (kbd "s-l")
'(lambda ()
(interactive)
(end-of-line 1)
(newline-and-indent)))

;;ruby on rails
(setq load-path (cons "~/.emacs.d/ruby" load-path))
(setq load-path (cons "~/.emacs.d/rails" load-path))
(require 'rails)

;;flymake
(require 'flymake-ruby)
(add-hook 'ruby-mode-hook 'flymake-ruby-load)

;;smart-compile
(require 'smart-compile)
(setq smart-compile-alist
'( ("\\.rb$" . "ruby %f")))
(global-set-key [(f5)] 'smart-compile)
(add-to-list 'load-path "~/.emacs.d/rhtml-mode")
(require 'rhtml-mode)
(add-hook 'rhtml-mode-hook
'(lambda ()
(auto-fill-mode -1)))

;;yaml
(add-to-list 'load-path "~/.emacs.d/yaml-mode")
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))

;;kill-this-buffer
(global-set-key [(f12)] 'kill-this-buffer)

;; Rinari
(setq load-path (cons "~/.emacs.d/rinari" load-path))
(require 'rinari)
(global-set-key (kbd "s-c") 'rinari-find-controller)
(global-set-key (kbd "s-m") 'rinari-find-model)
(global-set-key (kbd "s-v") 'rinari-find-view)
(global-set-key (kbd "s-h") 'rinari-find-helper)
(global-set-key (kbd "s-f") 'rinari-find-file-in-project)

;; kill all rinari buffers
(defun kill-buffers-in-subdir (subdir buffer)
"Kills the given buffer if it is linked to a file in the current rinari project."
(if (buffer-in-subdir-p subdir buffer)
(kill-buffer buffer)))
(defun buffer-in-subdir-p (subdir buffer)
"Returns true if buffer belongs to the current rinari project"
(and (buffer-file-name buffer)
(string-match subdir (buffer-file-name buffer))))

(defun kill-all-rinari-buffers ()
"Kills all buffers linked to the current rinari project"
(interactive)
(let ((path (rinari-root)))
(if path
(dolist (buffer (buffer-list))
(kill-buffers-in-subdir path buffer)))))
(global-set-key [(C-f12)] 'kill-all-rinari-buffers)

;;goto line
(global-set-key (kbd "s-g") 'goto-line)

;;commit
(global-set-key (kbd "s-o") 'comment-region)
(global-set-key (kbd "s-u") 'uncomment-region)

;;code toggle
(global-set-key (kbd "s-h") 'hs-hide-all)
(global-set-key (kbd "s-s") 'hs-show-all)
(global-set-key (kbd "s-t") 'hs-toggle-hiding)


(global-set-key [(f8)] 'ecb-toggle-ecb-windows)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值