• emacs 插件的维护


    2008年的时候,在vmware中开始学习ubuntu。
    什么都不会,安装软件基本上是google以后apt-get。
    后来ubuntu有了software center,就直接装。

    于是乎问题来了。
    ubuntu维护的软件版本有时候会赶不上开发者的进度。
    emacs就是一个例子。
    cedet1.0pre4和emacs2.32就出现无法jump的问题。
    但cedet1.0正式版就可以正常jump。
    去年学习emacs,每次换环境,都要在synaptic package manager中勾选cedet等,然后ubuntu自动安装到相关目录。
    因为插件多,感觉比较麻烦。

    后来发现用户目录下也有.emacs.d的文件夹,里面也可以存放插件的文件。
    因此emacs的迁移就简单了。

    首先从sourceforge下载需要的插件,自然都是最新的。
    cedet:http://cedet.sourceforge.net/
    ecb:http://ecb.sourceforge.net
    doxymacs:http://doxymacs.sourceforge.net
    xcscope: http://cscope.sourceforge.net
    或者还有自己收集的插件等。
    解压到用户目录的.emacs.d目录中。
    然后在用户目录的.emacs文件中指向.emacs.d目录即可。
    以后只要ubunut下安装emacs即可。复制.emacs文件,.emacs.d目录到用户目录下即可。

    善意的提示:在ubuntu下启动桌面特效的话,启动过程可能无法正确设置最大化窗口。

    顺便贴一份我的配置:
    ;load-path
    (add-to-list 'load-path "~/.emacs.d/lisp")
    (setq load-path (cons "~/emacs" load-path))

    (require 'xcscope) ;;加载xcscope


    ;;记录所有操作
    (require 'session)
    (add-hook 'after-init-hook 'session-initialize)
    (add-hook 'c-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode
    (add-hook 'c++-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode


    (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.

     '(ecb-options-version "2.32")
     '(session-use-package t nil (session))
     '(column-number-mode t);默认显示行号的同时,也显示列号
     '(display-time-mode t);显示当前时间
     '(inhibit-startup-screen t);关闭启动画面
     '(show-paren-mode t);显示与当前光标所在位置的括号匹配的另一个括号

    )


    (column-number-mode t)
    (transient-mark-mode t)
    (setq line-number-mode t)
    (setq default-tab-width 8)
    (setq x-select-enable-clipboard t)
    (setq mouse-yank-at-point t)
    (customize-set-variable 'scroll-bar-mode' right)
    (setq visible-bell t);关闭出错时的蜂鸣提示声
    (mouse-avoidance-mode'animate);当鼠标箭头与光标相近时,使鼠标箭头自动移开
    (blink-cursor-mode nil);光标不闪烁
    (setq-default cursor-type 'bar);光标显示为一竖线
    ;;(tool-bar-mode -1);; 不显示emcas的工具栏
    ;;(menu-bar-mode -1);; 不显示emcas的菜单栏,按ctrl+鼠标右键仍能调出该菜单
    (setq x-select-enable-clipboard t);; 支持emacs和外部程序之间进行粘贴
    (fset 'yes-or-no-p 'y-or-n-p);以 'y/n'字样代替原默认的'yes/no'字样
    (setq frame-title-format "%b@emacs");在最上方的标题栏显示当前buffer的名字
    (setq make-backup-files nil);关闭自动备份功能
    (setq auto-save-mode nil);关闭自动保存模式
    (setq auto-save-default nil);不生成名为#filename# 的临时文件
    (setq require-final-newline t);; 自动的在当前的buffer文件的最后加一个空行
    (global-set-key "\r" 'align-newline-and-indent);;自动缩进<C-j>变为<Enter>
    (setq echo-keystrokes 0.1);; 尽快显示按键序列提示
    (global-font-lock-mode t);; 语法高亮

    ;;;;;;;;
    (setq default-input-method 'chinese-py-punct)

    ;; 用来显示当前光标在哪个函数
    (require 'which-func)
    (which-func-mode 1)
    (setq which-func-unknown "unknown")
    ;; 用M-x执行某个命令的时候,在输入的同时给出可选的命令名提示
    (icomplete-mode 1)
    (define-key minibuffer-local-completion-map (kbd "SPC") 'minibuffer-complete-word)

    (global-hl-line-mode 1);;高亮当前行


    (set-face-background 'default "#334455");背景设定FDFCC1
    (set-face-foreground 'default "wheat")

    (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.
     )


    (global-set-key [(f3)] 'shell) ;;执行shell

    ;; move window (Shift + cursor)
    (windmove-default-keybindings)
    (setq windmove-wrap-around t)

    (global-set-key [C-\;] 'ecb-goto-window-edit-last) ;;切换到编辑窗口
    (global-set-key [C-\'] 'ecb-goto-window-methods) ;;切换到函数窗口
    (global-set-key [C-.] 'cscope-find-global-definition) ;;搜索定义
    (global-set-key [C-,] 'cscope-pop-mark) ;; 跳出转向

     
    (global-set-key [(meta return)] 'semantic-ia-complete-symbol-menu) ;;设置Alt+Enter为自动补全菜单
    (add-hook 'c-mode-common-hook (
      lambda()
      ( c-set-style "k&r" )
     (setq c-macro-shrink-window-flag t)
       (setq c-macro-preprocessor "cpp")
     (setq c-macro-cppflags " ")
     (setq c-macro-prompt-flag t)
     (setq hs-minor-mode t)
     (setq abbrev-mode t)
     ) ) ;;设置C语言默认格式

    (add-hook 'c++-mode-common-hook ( lambda() ( c-set-style "k&r" ) ) ) ;;设置C++语言默认格式

    ;;;;;;;;;;;;;;;;;启动时最大化;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun toggle-fullscreen (&optional f)
       (interactive)
       (let ((current-value (frame-parameter nil 'fullscreen)))
            (set-frame-parameter nil 'fullscreen
                    (if (equal 'fullboth current-value)
                            (if (boundp 'old-fullscreen) old-fullscreen nil)
                                   (progn (setq old-fullscreen current-value)
                                               'fullboth)))))

    (global-set-key [C-f11] 'toggle-fullscreen)

    ; Make new frames fullscreen by default. Note: this hook doesn't do
    ; anything to the initial frame if it's in your .emacs, since that file is
    ; read _after_ the initial frame is created.
    (add-hook 'after-make-frame-functions 'toggle-fullscreen)


    (setq initial-frame-alist '((top . 0) (left . 0) (width . 1366) (height . 768)))
    ;;(require 'display-line-number)
    ;;(global-display-line-number-mode 1)


    ;;;;;;;;;;;;;;;;web方式显示行号;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (set-scroll-bar-mode 'right);滚动条在右侧
    ;(set-scroll-bar-mode nil)   ; 不显示滚动条, even in x-window system (recommended)
    ;;(require 'wb-line-number)
    ;;(wb-line-number-toggle)

    (require 'cc-mode)
    (c-set-offset 'inline-open 0)
    (c-set-offset 'friend '-)
    (c-set-offset 'substatement-open 0)

    (autoload 'gtags-mode "gtags" "" t);gtags-mode is true

    ;##cedet(Collection of Emacs Development Environment Tools);;;;;;
    (load-file "/home/用户目录/.emacs.d/cedet-1.0/common/cedet.el")
    (require 'cedet) ;;加载cedet
    ;读取子目录中的特别的 .el 文件
    (global-ede-mode 1); Enable the Project management system
    (semantic-load-enable-code-helpers); Enable prototype help and smart completion
    (semantic-load-enable-minimum-features)
    (semantic-load-enable-guady-code-helpers)
    (semantic-load-enable-excessive-code-helpers)
    (semantic-load-enable-semantic-debugging-helpers)
    (global-srecode-minor-mode 1); Enable template insertion menu
    (global-set-key [(f4)] 'speedbar-get-focus);speedbar快捷键[F4]
    (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
    (define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)

    (setq semantic-default-submodes '(global-semantic-idle-scheduler-mode
                                      global-semanticdb-minor-mode
                                      global-semantic-idle-summary-mode
                                      global-semantic-mru-bookmark-mode))

    (defconst cedet-user-include-dirs 
     (list ".." "../include" "../inc" "../common" "../public"
             "../.." "http://www.cnblogs.com/include" "http://www.cnblogs.com/inc" "http://www.cnblogs.com/common" "http://www.cnblogs.com/public"))
     (require 'semantic-c nil 'noerror)
     (let ((include-dirs cedet-user-include-dirs)) 
      (mapc (lambda (dir)         
       (semantic-add-system-include dir 'c++-mode)
             (semantic-add-system-include dir 'c-mode)) 
            include-dirs))
    (enable-visual-studio-bookmarks) ;; 启动VS书签子程序

    (require 'semantic-util-modes)
    ;;(semantic-stickyfunc-mode  0)

    ;; 代码跳转
    (require 'semantic-ia)
    (global-set-key [f12] 'semantic-ia-fast-jump)
    (global-set-key [C-f12]
    (
     lambda ()
     (interactive)
     (if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
      (error "Semantic Bookmark ring is currently empty"))
     (let* ((ring (oref semantic-mru-bookmark-ring ring))
      (alist (semantic-mrub-ring-to-assoc-list ring))
      (first (cdr (car alist))))
     (if (semantic-equivalent-tag-p (oref first tag)
      (semantic-current-tag))
     (setq first (cdr (car (cdr alist)))))
     (semantic-mrub-switch-tags first))))

    (autoload 'senator-try-expand-semantic "senator")

    (setq hippie-expand-try-functions-list
          '(
            senator-try-expand-semantic
            try-expand-dabbrev
            try-expand-dabbrev-visible
            try-expand-dabbrev-all-buffers
            try-expand-dabbrev-from-kill
            try-expand-list
            try-expand-list-all-buffers
            try-expand-line
            try-expand-line-all-buffers
            try-complete-file-name-partially
            try-complete-file-name
            try-expand-whole-kill
            )
    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (add-to-list 'load-path "/home/用户目录/.emacs.d/ecb");读取安装el的路径
    (require 'ecb)
    (require 'ecb-autoloads)
    (setq ecb-auto-activate t);自动启动ecb
    (setq ecb-auto-activate t;自动启动ecb
     ecb-tip-of-the-day nil;不显示每日提醒
     inhibit-startup-message t;去掉Emacs和gnus启动时的引导界面
     ecb-auto-compatibility-check nil;
     ecb-version-check nil;
     ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)
    )
    (custom-set-variables
     '(ecb-source-path (quote ("~/workplay")))
    )

    ;;(semantic-mode 1)

    (global-set-key [C-f1] 'ecb-deactivate) ;;定义Ctrl+F1为停止ecb
    (global-set-key [f1] 'ecb-activate) ;;定义F1键为激活ecb

    ;;;; 各窗口间切换
    (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)

    ;;;; 使某一ecb窗口最大化
    (define-key global-map "\C-c1" 'ecb-maximize-window-directories)
    (define-key global-map "\C-c2" 'ecb-maximize-window-sources)
    (define-key global-map "\C-c3" 'ecb-maximize-window-methods)
    (define-key global-map "\C-c4" 'ecb-maximize-window-history)
    ;;;; 恢复原始窗口布局
    (define-key global-map "\C-c`" 'ecb-restore-default-window-sizes)


    ;##doxymacs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (add-to-list 'load-path "/home/用户目录/.emacs.d/doxymacs");读取安装el的路径
    (require 'doxymacs) ;; 启动doxymacs
    ;;注释高亮,针对C和C++程序
    (defun my-doxymacs-font-lock-hook ()
      (if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
          (doxymacs-font-lock)))
    (add-hook 'font-lock-mode-hook 'my-doxymacs-font-lock-hook)
    (doxymacs-mode);doxymacs-mode常true
    (global-set-key [(f2)] 'doxymacs-mode);doxymacs-mode快捷键[F2]
    (add-hook 'c-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode
    (add-hook 'c++-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode

    ;##GDB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (global-set-key [(f8)] 'gdb-restore-windows);gdb-restore-windows快捷键[F8]
    (setq gdb-use-separate-io-buffer nil) ; 不需要"IO buffer"时,则设为nil
    (gud-tooltip-mode) ; 调试期支持鼠标查看变量
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    ;##compile;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (define-key c-mode-base-map [(f7)] 'compile);emacs的compile命令快捷键F7
    (setq compile-command "make");默认的make -k命令,变为make命令
    (setq compile-command-clean "make clean");默认的make -k命令,变为make命令
    (global-set-key [C-f7] '(lambda () (interactive) (compile compile-command-clean)))
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;; set tabbar
    (add-to-list 'load-path "/home/用户目录/.emacs.d/emacs-goodies-el");读取安装el的路径
    (require 'tabbar)  
    (tabbar-mode 1) 
    (global-set-key [(meta l)] 'tabbar-backward)  
    (global-set-key [(meta k)] 'tabbar-forward) 


    ;; debug
    (require 'gdb-ui)
    (defun gdb-or-gud-go () 
     "If gdb isn't running; run gdb, else call gud-go." 
     (interactive) 
     (if (and gud-comint-buffer
        (buffer-name gud-comint-buffer)
              (get-buffer-process gud-comint-buffer)
              (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)))
          (gud-call (if gdb-active-process "continue" "run") "")   
          (ecb-deactivate)
          (gdb (gud-query-cmdline 'gdb))))

    (defun gud-break-remove () 
     "Set/clear breakpoin." 
     (interactive) 
     (save-excursion   
      (if (eq (car (fringe-bitmaps-at-pos (point))) 'breakpoint)
              (gud-remove nil)
            (gud-break nil))))


    (defun gud-kill ()
       "Kill gdb process."
       (interactive)
      (with-current-buffer gud-comint-buffer (comint-skip-input))
       (set-process-query-on-exit-flag (get-buffer-process gud-comint-buffer) nil)
     (kill-buffer gud-comint-buffer)
     (ecb-activate) )

    (defun gdb-tooltip-hook ()
      (gud-tooltip-mode 1)
      (let ((process (ignore-errors (get-buffer-process (current-buffer)))))
        (when process
          (set-process-sentinel process
                                (lambda (proc change)
                                  (let ((status (process-status proc)))
                                    (when (or (eq status 'exit)
                                              (eq status 'signal))
                                      (gud-tooltip-mode -1))))))))

    (setq gdb-many-windows t)
    (global-set-key [f5] 'gdb-or-gud-go)
    (global-set-key [C-f5] 'gud-kill)

    ;;(load-library "multi-gud.el")
    ;;(load-library "multi-gdb-ui.el")

    (global-set-key [f9] 'gud-break)
    (global-set-key [C-f9] 'gud-break-remove)

    (defun kill-buffer-when-shell-command-exit ()
        "Close current buffer when `shell-command' exit."
        (let ((process (ignore-errors (get-buffer-process (current-buffer)))))
        (when process
            (set-process-sentinel process
                (lambda (proc change)
                    (when (string-match "\\(finished\\|exited\\Debugger\\)" change)   ;;(when (string-match "\\(finished\\|exited\\)" change)
                        (kill-buffer (process-buffer proc))))
                )
            )
        )
    )


    (setq semanticdb-project-roots
          (list
            (expand-file-name "/")))

    (defun my-indent-or-complete ()
       (interactive)
       (if (looking-at "\\>")
          (hippie-expand nil)
          (indent-for-tab-command))
     )

    (global-set-key [(control tab)] 'my-indent-or-complete)

    (delete-selection-mode 1)

    ;; 退出gdb的时候关闭gdb对应的buffer
    (add-hook 'gdb-mode-hook 'kill-buffer-when-shell-command-exit)
    ;; 退出term的时候关闭term对应的buffer
    (add-hook 'term-mode-hook 'kill-buffer-when-shell-command-exit)

    (add-hook 'gdb-mode-hook '(lambda ()
        (define-key c-mode-base-map [(f10)] 'gud-next)
                  (define-key c-mode-base-map [(f11)] 'gud-step)    
        (define-key c-mode-base-map [(C-f11)] 'gud-finish)))


     

  • 相关阅读:
    转:【More Effective C#】Lambda表达式优化
    转:Highcharts图表控件的使用
    C# subString的理解
    转:TimeSpan的用法
    Android学习笔记一:Android基本组件和Activity生命周期
    IIS 反向代理设置
    WebApi 身份认证解决方案:Basic基础认证
    Calling async method synchronously
    C# 公共类
    aspnet-api-versioning
  • 原文地址:https://www.cnblogs.com/febwave/p/2343269.html
Copyright © 2020-2023  润新知