`
jjchen_lian
  • 浏览: 84237 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

emacs配置

阅读更多

直接给出配置,发邮件的配置没有给出。

;; 显示括号匹配 
(show-paren-mode t)
(setq show-paren-style 'parentheses)


;; 指针颜色设置为白色
(set-cursor-color "orange")

;;代码提示
;;-----------------------------auto-complete--------------------------------------------
;;auto-complete  
(add-to-list 'load-path "~/.emacs.d/lisp/auto-complete-1.3.1")    
(require 'auto-complete)  
(require 'auto-complete-config)
(defun prefix-list-elements (list prefix)
  (let (value)
    (nreverse
     (dolist (element list value)
       (setq value (cons (format "%s%s" prefix element) value))))))

(defvar ac-source-rope
  '((candidates
     . (lambda ()
         (prefix-list-elements (rope-completions) ac-target))))
  "Source for Rope")

(defun ac-python-find ()
  "Python `ac-find-function'."
  (require 'thingatpt)
  (let ((symbol (car-safe (bounds-of-thing-at-point 'symbol))))
    (if (null symbol)
        (if (string= "." (buffer-substring (- (point) 1) (point)))
            (point)
          nil)
      symbol)))

(defun ac-python-candidate ()
  "Python `ac-candidates-function'"
  (let (candidates)
    (dolist (source ac-sources)
      (if (symbolp source)
          (setq source (symbol-value source)))
      (let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit))
             (requires (cdr-safe (assq 'requires source)))
             cand)
        (if (or (null requires)
                (>= (length ac-target) requires))
            (setq cand
                  (delq nil
                        (mapcar (lambda (candidate)
                                  (propertize candidate 'source source))
                                (funcall (cdr (assq 'candidates source)))))))
        (if (and (> ac-limit 1)
                 (> (length cand) ac-limit))
            (setcdr (nthcdr (1- ac-limit) cand) nil))
        (setq candidates (append candidates cand))))
    (delete-dups candidates)))

(add-hook 'python-mode-hook
          (lambda ()
            (set (make-local-variable 'ac-sources)
                 (append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
            (rope-open-project "~/.emacs.d/database/python/")
            ))  
  
(add-to-list 'ac-dictionary-directories "~/.emacs.d/lisp/auto-complete-1.3.1/dict")    
(ac-config-default)  
  
(global-auto-complete-mode t)  
  
;(setq-default ac-sources '(ac-source-words-in-same-mode-buffers))  
(setq-default ac-sources '(ac-source-yasnippet    
                 ac-source-semantic  
                 ac-source-ropemacs  
                 ac-source-imenu    
                 ac-source-words-in-buffer  
                 ac-source-dictionary  
                 ac-source-abbrev    
                 ac-source-words-in-buffer    
                 ac-source-files-in-current-dir    
                 ac-source-filename))   
  
(add-hook 'emacs-lisp-mode-hook    (lambda () (add-to-list 'ac-sources 'ac-source-symbols)))  
(add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename)))  
;;下面这句是从auto-complete-config.el中翻出来的  
;;加上这句,在python中输入类的 . 就可以提示里面的方法了  
(add-hook 'python-mode-hook        (lambda () (add-to-list 'ac-omni-completion-sources (cons "\\." '(ac-source-ropemacs)))  ))    
  
  
(set-face-background 'ac-candidate-face "lightgray")  
(set-face-underline 'ac-candidate-face "darkgray")  
(set-face-background 'ac-selection-face "steelblue")   
  
(setq ac-auto-start 2)  
(setq ac-dwim t) 
;;重构功能以及函数提示
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    ;;      Cedet 1.0  
    ;;  
    (load-file "~/.emacs.d/lisp/cedet-1.1/common/cedet.el")  
         ;;;; 具体说明可参考源码包下的INSTALL文件,或《A Gentle introduction to Cedet》

;; Enabling Semantic (code-parsing, smart completion) features

;; Select one of the following:

;;(semantic-load-enable-minimum-features)

;;(semantic-load-enable-code-helpers)

;;(semantic-load-enable-gaudy-code-helpers)

(semantic-load-enable-excessive-code-helpers)

;;(semantic-load-enable-semantic-debugging-helpers)

 

;;;; 使函数体能够折叠或展开

;; Enable source code folding

(global-semantic-tag-folding-mode 1)

 

;; Key bindings

(defun my-cedet-hook ()

  (local-set-key [(control return)] 'semantic-ia-complete-symbol)

  (local-set-key "/C-c?" 'semantic-ia-complete-symbol-menu)

  (local-set-key "/C-cd" 'semantic-ia-fast-jump)

  (local-set-key "/C-cr" 'semantic-symref-symbol)

  (local-set-key "/C-cR" 'semantic-symref))

(add-hook 'c-mode-common-hook 'my-cedet-hook)

 

;;;; 当输入"."或">"时,在另一个窗口中列出结构体或类的成员

(defun my-c-mode-cedet-hook ()

  (local-set-key "." 'semantic-complete-self-insert)

  (local-set-key ">" 'semantic-complete-self-insert))

(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
    ;;  
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
    
   ;;工程目录 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    ;;      ECB 2.40  
    ;;  
      
    (add-to-list 'load-path  
                        "~/.emacs.d/lisp/ecb-2.40")  
      
    (require 'ecb)  
    (require 'ecb-autoloads) 
    ;;;; 自动启动ecb,并且不显示每日提示

    (setq ecb-auto-activate t

      ecb-tip-of-the-day nil)
      
      (ecb-layout-define "my-cscope-layout" left nil
                   (ecb-set-methods-buffer)
                   (ecb-split-ver 0.5 t)
                   (other-window 1)
                   (ecb-set-history-buffer)
                   (ecb-split-ver 0.5 t) ;我改成了0.5 
                   (other-window 1)
                   (ecb-set-cscope-buffer))

(defecb-window-dedicator ecb-set-cscope-buffer " *ECB cscope-buf*"
                         (switch-to-buffer "*cscope*"))

(setq ecb-layout-name "my-cscope-layout")

;; Disable buckets so that history buffer can display more entries
(setq ecb-history-make-buckets 'never)
      
    ;; ;;;;窗口间切换  
    (global-set-key [M-left]  'windmove-left)  
    (global-set-key [M-right] 'windmove-right)  
    (global-set-key [M-up]    'windmove-up)  
    (global-set-key [M-down]  'windmove-down)  
      
     ;;;;show&hide window  
    (global-set-key [C-f1] 'ecb-hide-ecb-windows)  
    (global-set-key [C-f2] 'ecb-show-ecb-windows)  
      
      
    ;; ;;;; 使某一ecb窗口最大化  
    (global-set-key (kbd "C-c 1") 'ecb-maximize-window-directories)  
    (global-set-key (kbd "C-c 2") 'ecb-maximize-window-sources)  
    (global-set-key (kbd "C-c 3") 'ecb-maximize-window-methods)  
    (global-set-key (kbd "C-c 4") 'ecb-maximize-window-history)  
      
    ;; ;;;;恢复原始窗口布局  
    (global-set-key (kbd "C-c 0") 'ecb-restore-default-window-sizes)  
      
    ;;  
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "black" :foreground "green" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))
                          
;;------------------------pymacs-----------------------------------
(load "~/.emacs.d/pymacs.el")
;; Python mode hook
(defun my-python-hook-mode ()
  (interactive)
  ;(setq ropemacs-enable-shortcuts nil)
  ;(setq ropemacs-local-prefix "C-c C-p")
  (require 'pymacs)
  (autoload 'pymacs-apply "pymacs")
  (autoload 'pymacs-call "pymacs")
  (autoload 'pymacs-eval "pymacs" nil t)
  (autoload 'pymacs-exec "pymacs" nil t)
  (autoload 'pymacs-load "pymacs" nil t)
  (ac-ropemacs-setup)
  ;(pymacs-load "ropemacs" "rope-")
  ;; Automatically save project python buffers before refactorings
  (setq ropemacs-confirm-saving 'nil)
  (ropemacs-mode t)
  (define-key python-mode-map "\C-m" 'newline-and-indent)
  ;(setq ac-sources (append ac-sources '(ac-source-ropemacs)))
 )
 (add-hook 'python-mode-hook 'my-python-hook-mode)
 
;;------------------------查看词典----------------------------------
(defun yodao-dict-search-wordap (&optional word)

"Use python script dict to look up word under point"

(interactive)

(or word (setq word (current-word)))

(shell-command (format "python ~/.emacs.d/dict.py %s" word)))

(global-set-key [f7] 'yodao-dict-search-wordap)

;;---------------------------挂载文档----------------------------
(setq pylookup-dir "~/.emacs.d/plugins/pylookup")
(add-to-list 'load-path pylookup-dir)
(require 'pylookup)

;; load pylookup when compile time
(eval-when-compile (require 'pylookup))

;; set executable file and db file
(setq pylookup-program (concat pylookup-dir "/pylookup.py"))
(setq pylookup-db-file (concat pylookup-dir "/pylookup.db"))

;; set search option if you want
;; (setq pylookup-search-options '("--insensitive" "0" "--desc" "0"))

;; to speedup, just load it on demand
(autoload 'pylookup-lookup "pylookup"
  "Lookup SEARCH-TERM in the Python HTML indexes." t)

(autoload 'pylookup-update "pylookup" 
  "Run pylookup-update and create the database at `pylookup-db-file'." t)
(global-set-key (kbd "C-c h") 'pylookup-lookup)


 记录一下,防止以后再其他机子上需要配置,下面把所用的插件也上传上来.只需要下载并且解压到你的目录下,把emacs.d改成.emacs.d,覆盖你原来的.emacs.d,然后拷贝上面的的配置文件到你的.emacs下,就可以生效了。

好了,体验emcas来了,以后有新的功能会及时更新。

分享到:
评论

相关推荐

    linux emacs 配置文件

    本配置文件基于网上提供的其他配置文件进行修改。 支持: emacs 24 +cedet 1.1 +ecb 2.40 源配置文件下载地址: http://download.csdn.net/detail/karotte/3812760

    emacs配置IDE

    emacs配置IDE相关资料,包括代码补全等等。

    我的emacs配置文件 linux

    我的emacs配置文件 linux 下载后解压到用户家目录下面,即可使用。 可能有的会出错,自己相应地修改.emacs文件即可。

    王垠 王纯叶的emacs配置

    王垠 王纯叶的emacs配置,打包成chm了, 方便查找些emacs技巧

    系统Ubuntu下的Emacs配置

    带有各种功能的emacs配置。

    emacs配置好了的

    emacs配置好了的 配置的非常完整 很值得

    emacs 配置

    emacs 配置文件, 支持动态加载插件代码

    emacs配置文件

    emacs配置文件的修正版,网上现有的emacs.d很多都缺少部分文件。另外如何配置可参考本人的blog文章:emacs配置。

    Emacs配置文件

    这是我的emacs配置文件,和我的blog相对应的

    emacs 配置文件

    emacs 配置文件(已经测试适合Windows和Linux),已经包含了各个扩展,主要的功能: 基本功能: 1. 设置colortheme 2. 共享系统剪贴板 3. 显示括号匹配 4. 用y-n取代yes-no 5. 用法高亮 6. 显示时间 7. 自动保存session...

    emacs配置文件 (.emacs)

    emacs config file, emacs编辑器的一个配置文件

    Emacs配置(Linux+WIndows)

    Emacs配置 Emacs作为Oier和程序设计者们的编程神器,当然也少不了一款强大的配置 Emacs配置(Linux放到Home并替换,Windows放到C:\)

    Emacs配置与插件

    Emacs 配置 插件 包括最新插件 基本配置 没有那么冗余 新手必备

    emacs 配置,cedet

    emacs 配置(cedet, ecb, yasnipped),改键工具

    emacs配置文件,针对emacs23.1

    emacs配置文件,针对emacs23.1 emacs配置文件,针对emacs23.1 emacs配置文件,针对emacs23.1 emacs配置文件,针对emacs23.1

    emacs配置 c java python

    关于c c++ java python开发的emacs配置文件

Global site tag (gtag.js) - Google Analytics