Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532792
  • 博文数量: 137
  • 博客积分: 3170
  • 博客等级: 中校
  • 技术积分: 1455
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-17 11:47
文章分类

全部博文(137)

文章存档

2015年(2)

2013年(1)

2012年(6)

2011年(5)

2010年(62)

2009年(61)

我的朋友

分类: LINUX

2009-11-12 15:24:06

;;load xcsope
(add-to-list 'load-path "~/.emacs.d/cscope-15.7a/contrib/xcscope")
(require 'xcscope)
;;load xcsope END
;;show line and column number
(setq column-number-mode t)
(setq line-number-mode t)
;;show line and column numberEND
;;配置颜色color-theme
(add-to-list  'load-path (expand-file-name  "~/.emacs.d/" ))
(require 'color-theme)
(color-theme-initialize)
(color-theme-calm-forest)
;;配置颜色color-themeEND
;;设置C-x C-f的默认路径,不管用,不知何故,但是关闭启动画面则可以实现,何故??
(setq default-directory "/home/jacky/uSrv/uworldserver/uWorld_UniG_src/unig2/uworldServer")
;;设置C-x C-f的默认路径END
;;关闭emacs启动画面
(setq inhibit-startup-message t)
;;关闭emacs启动画面END
;;ibuffer加载
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
;;ibuffer目录设置
(require 'ibuf-ext)
  (setq ibuffer-mode-hook
        (lambda ()
          (setq ibuffer-filter-groups
                '(
                  ("*buffer*" (name . "\\*.*\\*"))
                  ("dired" (mode . dired-mode))
                  ("perl" (or (mode . cperl-mode)
                              (mode . sepia-mode)
                              (mode . perl-mode)))
                  ("elisp" (or (mode . emacs-lisp-mode)
                               (mode . lisp-interaction-mode)))
                  ("prog" (or (mode . c++-mode)
                              (mode . c-mode)
                              (mode . java-mode)))
                  ("tags" (name . "^TAGS"))))))
;;ENDibuffer目录设置
;;ibuffer加载 END
;;cc-mode的加载*************
;;(setq-default c-electric-flag nil)  ;;使打入分号后换行
(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
      (setq tab-stop-list (cons (* x 4) tab-stop-list)))

(defconst my-c-style
  '((c-tab-always-indent        . t)
    (c-comment-only-line-offset . 4)
    (c-hanging-braces-alist     . ((substatement-open after)
                                   (brace-list-open)))
    (c-hanging-colons-alist     . ((member-init-intro before)
                                   (inher-intro)
                                   (case-label after)
                                   (label after)
                                   (access-label after)))
    (c-cleanup-list             . (scope-operator
                                   empty-defun-braces
                                   defun-close-semi))
    (c-offsets-alist            . ((arglist-close . c-lineup-arglist)
                                   (substatement-open . 0)
                                   (case-label        . 4)
                                   (block-open        . 0)
                                   (knr-argdecl-intro . -)))
    (c-echo-syntactic-information-p . t)
    )
  "My C Programming Style")

;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))

;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
  ;; add my personal style and set it for the current buffer
  (c-add-style "PERSONAL" my-c-style t)
  ;; other customizations
  (setq tab-width 4
        ;; this will make sure spaces are used instead of tabs
        indent-tabs-mode nil)
  ;; we like auto-newline and hungry-delete
  (c-toggle-auto-hungry-state 1)
  ;; key bindings for all supported languages.  We can put these in
  ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
  ;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
  (define-key c-mode-base-map "\C-m" 'c-context-line-break)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;;cc-mode的加载************* END
;;go-to-char转到下一个字符--王垠
(defun wy-go-to-char (n char)
  "Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
  (interactive "p\ncGo to char: ")
  (search-forward (string char) nil nil n)
  (while (char-equal (read-char)
             char)
    (search-forward (string char) nil nil n))
  (setq unread-command-events (list last-input-event)))
(define-key global-map (kbd "C-c a") 'wy-go-to-char)
;;go-to-char转到下一个字符--王垠 END
;;hippie-expand补齐
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
      '(try-expand-dabbrev
    try-expand-dabbrev-visible
    try-expand-dabbrev-all-buffers
    try-expand-dabbrev-from-kill
    try-complete-file-name-partially
    try-complete-file-name
    try-expand-all-abbrevs
    try-expand-list
    try-expand-line
    try-complete-lisp-symbol-partially
    try-complete-lisp-symbol))

(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.
 '(column-number-mode t))
(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.
 )

(put 'upcase-region 'disabled nil)
;;hippie-expand补齐 END

;;emacs矩形区域操作
;;; rect-mark.el
;;  ~/Emacs/Extensions/rect-mark.el
(require 'rect-mark)
;
;; Use this section in your "~/.emacs" when rect-mark isn't included
;; as an integral part of Emacs.  Don't forget to remove the first
;; three columns.
;; Support for marking a rectangle of text with highlighting.
(define-key ctl-x-map "r\C-@" 'rm-set-mark)
(define-key ctl-x-map [?r ?\C-\ ] 'rm-set-mark)
(define-key ctl-x-map "r\C-x" 'rm-exchange-point-and-mark)
(define-key ctl-x-map "r\C-w" 'rm-kill-region)
(define-key ctl-x-map "r\M-w" 'rm-kill-ring-save)
(define-key global-map [S-down-mouse-1] 'rm-mouse-drag-region)
(autoload 'rm-set-mark "rect-mark"
 "Set mark for rectangle." t)
(autoload 'rm-exchange-point-and-mark "rect-mark"
 "Exchange point and mark for rectangle." t)
(autoload 'rm-kill-region "rect-mark"
 "Kill a rectangular region and save it in the kill ring." t)
(autoload 'rm-kill-ring-save "rect-mark"
 "Copy a rectangular region to the kill ring." t)
(autoload 'rm-mouse-drag-region "rect-mark"
 "Drag out a rectangular region with the mouse." t)
;; Use this section in your "~/.emacs" to modify picture mode so that
;; it automatically uses the rect-mark equivalents of many commands.
;; One vision of a better picture mode.
(add-hook 'picture-mode-hook 'rm-example-picture-mode-bindings)
(autoload 'rm-example-picture-mode-bindings "rect-mark"
 "Example rect-mark key and mouse bindings for picture mode.")
;;END emacs矩形区域操作
;;匹配括号--王垠按%来对应匹配的括号
(global-set-key "%" 'match-paren)
          
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
    ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
    (t (self-insert-command (or arg 1)))))
;;匹配括号--王垠END
;;临时标记,来回跳转
;;C-.作标记  C-,跳回
(global-set-key [(control ?\.)] 'ska-point-to-register)
(global-set-key [(control ?\,)] 'ska-jump-to-register)
(defun ska-point-to-register()
  "Store cursorposition _fast_ in a register.
Use ska-jump-to-register to jump back to the stored
position."
  (interactive)
  (setq zmacs-region-stays t)
  (point-to-register 8))

(defun ska-jump-to-register()
  "Switches between current cursorposition and position
that was stored with ska-point-to-register."
  (interactive)
  (setq zmacs-region-stays t)
  (let ((tmp (point-marker)))
        (jump-to-register 8)
        (set-register 8 tmp)))
;;临时标记,来回跳转END
;;设置默认字体字号
(set-default-font "DejaVu Sans Mono-14")
(add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-14"))

;;(set-default-font "DejaVu LGC Sans Mono-14")
;;(add-to-list 'default-frame-alist '(font . "DejaVu LGC Sans Mono-14"))
;;设置默认字体字号END
;;设置时间
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
(display-time)
;;设置时间END
;;设置工具栏菜单栏滚动条隐藏
(tool-bar-mode nil)
(menu-bar-mode nil)
(scroll-bar-mode nil)
;;设置工具栏菜单栏滚动条隐藏END
;;设置ido
(ido-mode 1)
(setq ido-save-directory-list-file "~/.emacs.d/_ido_last")
;;;;设置idoEND
;;yes和no变化为y和n
(fset 'yes-or-no-p 'y-or-n-p)
;;yes和no变化为y和nEND
;;关闭括号的来回跳转匹配,很麻烦
(show-paren-mode nil)
;;关闭括号的来回跳转匹配,很麻烦END
;;标题栏显示文件路径  
 (setq frame-title-format  
       '("%S" (buffer-file-name "%f"  
                    (dired-directory dired-directory "%b"))))  
;;标题栏显示文件路径END
;;;;退出Emacs时保存所有正在编辑的文档desktop
(load "desktop")
(setq desktop-load-locked-desktop t)
   (desktop-save-mode 1)
;;;;退出Emacs时保存所有正在编辑的文档END
;;用C-c C-m代替M-x键
(global-set-key "\C-c\C-m" 'execute-extended-command)
(global-set-key "\C-x\C-m" 'execute-extended-command)
;;用C-c C-m代替M-x键END
;;定义删除区域快捷键
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
;;定义删除区域快捷键END
;;重名buffer的处理
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;;重名buffer的处理END
;;在buffer和shell之间快速切换需要加载shell-toggle.el
(autoload 'shell-toggle "shell-toggle"
  "Toggles between the *shell* buffer and whatever buffer you are editing."
  t)
(autoload 'shell-toggle-cd "shell-toggle"
  "Pops up a shell-buffer and insert a \"cd \" command." t)
(global-set-key [C-f9] 'shell-toggle-cd)
;;在buffer和shell之间快速切换END
;;不产生备份文件,临时文件
(setq make-backup-files nil)
(setq-default make-backup-files nil)
;;不产生备份文件,临时文件END
;;制止M-x shell产生乱码
(ansi-color-for-comint-mode-on)
;;制止M-x shell产生乱码END
;;使emacs和其他程序copy数据
(setq x-select-enable-clipboard t)
;;使emacs和其他程序copy数据END
;;开机全屏最大化
;;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
)
;最大化
(defun my-maximized ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
)
(my-maximized) ;; 启动emacs时窗口最大化
;;开机全屏最大化END
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线
(mouse-avoidance-mode 'animate)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线END
;;防止屏幕过快的滚动20091226
(setq scroll-margin 3
      scroll-conservatively 10000)
;;防止屏幕过快的滚动END
;;调到指定行
(define-key ctl-x-map "l" 'goto-line)
;;调到指定行END
;;load psvn
;;(require 'psvn)
;;load psvnEND
;;插入当前时间
(defun my-insert-date ()
  (interactive)
  (insert (format-time-string "%Y/%m/%d %H:%M:%S" (current-time))))
(global-set-key (kbd "C-c m d") 'my-insert-date)
;;插入当前时间END
;;IncreaseSearch:C-s区分大小写
(add-hook 'isearch-mode-hook
            (function
             (lambda ()
               (define-key isearch-mode-map "\C-h" 'isearch-mode-help)
               (define-key isearch-mode-map "\C-t" 'isearch-toggle-regexp)
               (define-key isearch-mode-map "\C-c" 'isearch-toggle-case-fold)
               (define-key isearch-mode-map "\C-j" 'isearch-edit-string))))
;;IncreaseSearch:C-s区分大小写END
;;use multi-term for open many term in emacs
;;also solve the problem: cmd 'top' can't run under emacs shell
(require 'multi-term)
(setq multi-term-program "/bin/bash")
;;key bind
(setq multi-term-program "/bin/bash")
(setq multi-term-buffer-name "term")
(global-set-key "\C-x." 'multi-term)
(global-set-key "\C-x," 'multi-term-dedicated-open)
;;use multi-term for open many term in emacsEND
;;chm-view w3m,we can also see url
(setq browse-url-browser-function 'w3m-browse-url)
 (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
 ;; optional keyboard short-cut
 (global-set-key "\C-x m" 'browse-url-at-point)
(require 'chm-view)
;;chm-view w3m,we can also see urlEND
阅读(1123) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~