emacs打开多文字的时候C-n切不到另一页

Vim、Emacs配置和使用
回复
fnhwsk
帖子: 39
注册时间: 2010-07-13 15:17

emacs打开多文字的时候C-n切不到另一页

#1

帖子 fnhwsk » 2012-11-05 16:28

编辑长且多行的文件的时候长按C-n切到下行 光标有时候会跳回
要么等上几秒 要么用C-v才能切到下一个页面
图片
图片
我用的是GNU emacs 23.4.1 系统是Debian wheezy + Awesome
机器配置 i7 2630+ 4G内存
上次由 fnhwsk 在 2012-11-05 16:49,总共编辑 1 次。
fnhwsk
帖子: 39
注册时间: 2010-07-13 15:17

Re: emacs打开多文字的时候C-n切不到另一页

#2

帖子 fnhwsk » 2012-11-05 16:30

:em20 这个问题为什么会发生呢。。
fnhwsk
帖子: 39
注册时间: 2010-07-13 15:17

Re: emacs打开多文字的时候C-n切不到另一页

#3

帖子 fnhwsk » 2012-11-05 16:46

代码: 全选

;;#######################################################################
;;#######################################################################
(setq default-directory "~/")                           ;;设置默认工作目录
;;设置插件目录*********************************************************************
(add-to-list 'load-path "~/.emacs.d/config")
(add-to-list 'load-path "~/.emacs.d/plugins/ecb-2.40")
(add-to-list 'load-path "~/.emacs.d/config/codepilot")
(add-to-list 'load-path "~/.emacs.d/config/emacs-eclim")
(add-to-list 'load-path "~/.emacs.d/config/icicles")
(add-to-list 'load-path "~/.emacs.d/config/gnuserv")
;;-------------------------------------------------------------------------------
(require 'ahei-misc)                                    ;;一些基本的小函数
(require 'eval-after-load)                              ;;用eval-after-load避免不必要的elisp包的加载
(require 'util)                                         ;;http://emacser.com/eval-after-load.htm
;;-窗体外观主题等配置---------------------------------------------------------------
(require 'maxframe-settings)				;;启动Emacs的时候最大化Emacs
(set-scroll-bar-mode nil)			       	;;去掉滚动条
(setq inhibit-startup-message t)		       	;;关闭开启画面
(tool-bar-mode nil)				       	;;禁用工具栏
(menu-bar-mode nil)				       	;;禁用菜单栏
(tool-bar-mode -1)				       	;;选择小工具栏图标,工具栏的东西
(require 'color-theme-settings)		     		;;color theme Emacs主题,很多face文件
(require 'ahei-face)
(require 'color-theme-ahei)
(require 'face-settings)
;;(set-default-font "8x16")	    			;;设置字体大小,默认是Monospace
;;(set-default-font "10x20")
;;(set-default-font "9x15")
(require 'font-settings)                                ;;由于不适用于mac 所以注释掉
;;(set-default-font "文泉驿微米黑")
;;(set-default-font "monaco")
(set-default-font "Monaco for Powerline Bold")
;;(set-default-font "-unknown-Mono-normal-normal-*-15-*-*-*-m-0-iso10646-1")
;;(setq default-frame-alist
;; '((height . 35)(width . 100)
;;   (menubar-lines . 20)(tool-bar-lines . 0)))           ;;默认窗口大小
(setq default-tab-width 8)			       	;;设置TAB宽度为8
(setq indent-tabs-mode t)                               ;;用tab缩进
(setq c-indent-level 8)
(setq c-continued-statement-offset 8)
(setq c-brace-offset -8)
(setq c-argdecl-indent 8)
(setq c-label-offset -8)
(setq c-basic-offset 8)
(global-set-key "\C-m" 'reindent-then-newline-and-indent)
;;(setq indent-tabs-mode nil)
;;(setq standard-indent 4)
;;(setq indent-tabs-mode nil)                           ;;使用空格缩进,不用tab缩进可以避免很多错误
;;(setq tab-always-indent nil)
;;(setq tab-width 4)
;;(setq-default indent-tabs-mode nil)
;;(setq default-tab-width 8)
;;(setq tab-stop-list())
;;(loop for x downfrom 40 to 1 do
;;(setq tab-stop-list (cons (* x 4) tab-stop-list)))
(require 'generic-x)			       	       	;;增加更丰富的高亮
(require 'package)     	               	       	       	;;Emacs中的包管理器
(package-initialize)
(require 'term-settings)			      	;;在Emacs里面使用shell
(require 'multi-term-settings)							
(display-time)					        ;;显示时间
(display-time-mode 1) 					;;启用时间显示设置,在minibuffer上面的那个杠上
(setq display-time-24hr-format t)			;;时间使用24小时制
(setq display-time-day-and-date t)		       	;;时间显示包括日期和具体时间
(setq display-time-use-mail-icon t)		       	;;时间栏旁边启用邮件设置
(setq display-time-interval 10)		       		;;时间的变化频率,单位多少来着?
(require 'setnu)			       		;;每列左边显示行号
(setnu-mode t)
;;(global-set-key[f3] (quote setnu-mode))               ;;按f3显示/隐藏行号
(setq-default fill-column 81)          			;;81列显示提示线
(setq frame-title-format "%f%p%l")	       		;;显示标题栏 %f 缓冲区完整路径 %p 页面百分数 %l 行号
(setq default-line-spaceing 4)	                        ;;设定行距
(setq kill-ring-max 200)		       		;;设置删除记录
;;(setq require-final-newline t)                     	;;以空行结束
(global-font-lock-mode 1)      			        ;;开启语法高亮。
(transient-mark-mode t)			       		;;高亮显示区域选择
(show-paren-mode t)			       		;;高亮显示成对括号
(setq show-paren-style 'parentheses)
(mouse-avoidance-mode 'animate)		       	        ;;鼠标指针避光标
(setq mouse-yank-at-point t)			       	;;粘贴于光标处,而不是鼠标指针处
(setq visible-bell t)				       	;;闪屏报警
(fset 'yes-or-no-p 'y-or-n-p)			       	;;使用y or n提问
(setq resize-mini-windows nil)			       	;;锁定行高
(setq enable-recursive-minibuffers t)	       		;;递归minibuffer
(setq suggest-key-bindings-1)   	       		;;当使用M-x COMMAND后,过1秒显示该COMMAND绑定的键
(setq make-backup-files nil)		       		;;不产生备份文件
(setq-default make-backup-files nil)	       		;;不生成临时文件
;;(setq lazy-lock-defer-on-scrolling t)	       		;;只渲染当前屏幕语法高亮,加快显示速度
(setq font-lock-maximum-decoration t)
(condition-case err                                     ;;将错误信息显示在回显区
	(progn
	  (require 'xxx))
  (error
   (message "Can't load xxx-mode %s" (cdr err))))	
(setq x-select-enable-clipboard t)		       	;;使用X剪贴板
;;(set-clipboard-coding-system 'ctext)		       	;;设定剪贴板的内容格式 适应Firefox
(require 'ibuffer)				       	;;ibuffer,查看bufer
(global-set-key ( kbd "C-x C-b")' ibuffer)              ;;ibuffer键设置,只能放到这里
(global-auto-revert-mode 1)			       	;;自动重载更改的文件
(setq custom-buffer-style 'brackets)		       	;;custome的风格改为单一的树状风格
(ido-mode t)					       	;;这里是直接打开了ido的支持,在emacs23中这个是自带的.
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
						       	;;设置 sentence-end 可以识别中文标点。
(setq sentence-end-double-space nil)	       		;;不用在 fill 时在句号后插入两个空格。
(setq enable-recursive-minibuffers t)	       		;;可以递归的使用 minibuffer
(setq scroll-margin 3  scroll-conservatively 10000)    	;;scroll-margin 3 在靠近屏幕边沿3行时就开始滚动
(setq default-major-mode 'text-mode)   			;;设置缺省主模式是text,,并进入auto-fill次模式.
(add-hook 'text-mode-hook 'turn-on-auto-fill)           ;;而不是基本模式fundamental-mode
(require 'uniquify)					;;可以为重名的buffer在前面加上其父目录的名字来让buffer的名字区分开来
(setq uniquify-buffer-name-style 'forward)
(setq-default kill-whole-line t)	       		;;在行首 C-k 时,同时删除该行。
(add-hook 'comint-output-filter-functions               ;;加密显出你的密码
      'comint-watch-for-password-prompt)	        
;-------------------------------------------------------;;把⚠⚠⚠⚠⚠⚠⚠缺省禁用的功能打开
(put 'scroll-left 'disabled nil)     	       		;;允许屏幕左移
(put 'scroll-right 'disabled nil)    	       		;;允许屏幕右移
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-region 'disabled nil) 
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'LaTeX-hide-environment 'disabled nil)
;-------------------------------------------------------;;把⚠⚠⚠⚠⚠⚠⚠缺省禁用的功能打开
(setq x-select-enable-clipboard t)	       		;;允许emacs和外部其他程序的粘贴
(setq mouse-yank-at-point t)	       			;;使用鼠标中键可以粘贴
(setq require-final-newline t)			       	;;自动的在文件末增加一新行
(setq-default transient-mark-mode t)		       	;;Non-nil if Transient-Mark mode is enabled.
(setq track-eol t)			       		;;当光标在行尾上下移动的时候,始终保持在行尾。
(setq Man-notify-method 'pushy)		       		;;当浏览 man page 时,直接跳转到 man buffer。
(setq next-line-add-newlines nil)	       		;;Emacs 21 中已经是缺省设置。按 C-n 或向下键时不添加新行。
(setq speedbar-show-unknown-files t)	       		;;可以显示所有目录以及文件
(setq dframe-update-speed nil)	       		        ;;不自动刷新,手动 g 刷新
(setq speedbar-update-flag nil)
(setq speedbar-use-images nil)		       		;;不使用 image 的方式
(setq speedbar-verbosity-level 0)
(setq dired-recursive-copies 'top)	       		;;让 dired 可以递归的拷贝和删除目录。
(setq dired-recursive-deletes 'top)
(setq time-stamp-active t)		       		;;设置时间戳,标识出最后一次保存文件的时间。
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S ")
(require 'hl-line-settings)	       			;;高亮当前行
(require 'diff-settings)				;;diff
(require 'ediff-settings)	            		;;Emacs的diff: ediff,有个my-fontest-win的文件很关键
(require 'coding-settings)				;;编码设置
(require 'mode-line-settings)				;;`mode-line'显示格式
(require 'dev-settings)					;;各种语言开发方面的设置,这个设置牵涉到太多配置....
(require 'moccur-settings)				;;在buffer中方便的查找字符串: color-moccur
(require 'isearch-settings)				;;Emacs超强的增量搜索Isearch配置
(if is-before-emacs-21 (require 'table "table-for-21"))	;;可以“所见即所得”的编辑一个文本模式的表格
(require 'htmlize)					;;把文件或buffer彩色输出成html
(require 'time-stamp-settings)				;;time-stamp, 在文件头记录修改时间, 并动态更新
;;(require 'emacs-server-settings)			;;Emacs做一个server, 然后用emacsclient连接这个server,无需打开两个Emacs
(require 'edit-server)                                  ;;Emacs open a port for Chrome to edit text in the browser
(edit-server-start)
(require 'apropos-settings)
(require 'completion-list-mode-settings)
(require 'ascii)					;;显示ascii表
(require 'all-help-settings)				;;所有关于查看帮助方面的配置,很多文件
(if is-before-emacs-21 (require 'for-emacs-21))		;;定义一些emacs 21没有的函数
(setq-default abbrev-mode t)				;;简写模式
(setq save-abbrevs nil)
;;(require 'uniquify)					;;可以为重名的buffer在前面加上其父目录的名字来让buffer的名字区分开来
;;(setq uniquify-buffer-name-style 'forward)
(require 'linkd-settings)				;;以目录形式显示linkd文档
(require 'dired-settings)				;;Emacs的超强文件管理器
(require 'bar-cursor)					;;可以把光标由方块变成一个小长条
(require 'cursor-change)				;;智能的改变光标形状http://emacser.com/cursor-change.htm
(cursor-change-mode 1)
(require 'outline-settings)				;;大纲mode
(delq                                                   ;;关闭buffer的时候, 如果该buffer有对应的进程存在, 不提示,
 'process-kill-buffer-query-function kill-buffer-query-functions)
(require 'wcy-desktop-settings)				;;王纯业的desktop,保留上次关闭时的buffer
;;(require 'zjl-hl-settings)
(setq-default ispell-program-name "aspell")		;;spell check
(require 'redo)						;;redo
(require 'hl-line)					;;hl-line mode
(require 'rect-mark)					;;rect-mark 
;;(require 'tabbar)					;;tabbar页面上显示buffer名称
;;(load "tabbar-group")					;;新建default组
;;(tabbar-mode)                                         ;;页面上显示buffer名称 418
;;(global-set-key (kbd "s-3") 'tabbar-backward-group)
;;(global-set-key (kbd "s-4") 'tabbar-forward-group)
;;(global-set-key (kbd "s-1") 'tabbar-backward)
;;(global-set-key (kbd "s-2") 'tabbar-forward)
(global-linum-mode t)					;;显示列号
(load "shell-buffer.el")				;;buffer name
;;(require 'semantic-tag-folding nil 'noerror)
(require 'rst)						;;RST
(add-hook 'rst-adjust-hook 'rst-toc-insert-update)
(add-hook 'text-mode-hook 'rst-text-mode-bindings)
(setq auto-mode-alist
      (append '(("\\.rst$" . rst-mode)
                 ("\\.rest$" . rst-mode)) auto-mode-alist))
(require 'view-mode-settings)                           ;; when turn on view-mode with M-x view-mode
                                                        ;; then you can't editor the buffer witch you open
;##########################################################################
;  插件
;##########################################################################
;;powerline================================================================
(add-to-list 'load-path "~/.emacs.d/plugins/emacs-powerline")
(require 'powerline)
;;(require 'cl)



;;ibus=====================================================================
;(add-to-list 'load-path "~/.emacs.d/plugins/ibus/")
;(require 'ibus)
;(add-hook 'after-init-hook 'ibus-mode-on)
;(global-set-key (kbd "C-SPC") 'ibus-toggle)               ;;这里既是绑定上面设置的C+=快捷键到ibus中
;(ibus-define-common-key ?\C-\s nil)
;; Use C-/ for Undo command
;(ibus-define-common-key ?\C-/ nil)
;; Change cursor color depending on IBus status
;(setq ibus-cursor-color '("red" "blue" "limegreen"))
;Zen Coding ===============================================================
;'zencoding-expand-line bound to C-Return 
(add-to-list 'load-path "~/.emacs.d/plugins/zencoding")
(require 'zencoding-mode) 
(add-hook 'sgml-mode-hook 'zencoding-mode)              ;;Auto-start on any markup modes
;;makrdown=================================================================
(autoload 'markdown-mode "markdown-mode.el"
    "Major mode for editing Markdown files" t)
(setq auto-mode-alist
    (cons '("\\.markdown" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist
    (cons '("\\.md" . markdown-mode) auto-mode-alist))
;;=========================================================================
;;org-mode
;;=========================================================================
(add-to-list 'load-path "~/.emacs.d/plugins/org-7.9.1/lisp")
(require 'org-install)
(require 'org)
(require 'org-publish)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-hook 'org-mode-hook 'turn-on-font-lock)
(add-hook 'org-mode-hook 
	  (lambda () (setq truncate-lines nil)))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-log-done t)
;;=========================================================================
;;Emacs-w3m插件设置 emacs-w3m-1.4.4
;;=========================================================================
(add-to-list 'load-path "~/.emacs.d/plugins/emacs-w3m")
(require 'w3m-load)
;;(require 'mime-w3m)
(autoload 'w3m "w3m" "interface for w3m on emacs" t) 
(setq w3m-home-page "http://www.hao123.com")
(setq w3m-default-display-inline-images t)              ;;打开图片显示  
(setq w3m-default-toggle-inline-images t)
(setq w3m-use-cookies t)                                ;;使用cooies
(setq w3m-command-arguments '("-cookie" "-F"))          ;;使用cookies和框架
(setq browse-url-browser-function 'w3m-browse-url)      ;;设置为默认浏览器
(setq w3m-view-this-url-new-session-in-background t)
(setq w3m-show-graphic-icons-in-header-line t)          ;;显示图标
(setq w3m-show-graphic-icons-in-mode-line t)
(setq w3m-view-this-url-new-session-in-background t)  
(add-hook 'w3m-fontify-after-hook 'remove-w3m-output-garbages)                                   
(defun remove-w3m-output-garbages ()
  (interactive)                                                   
  (let ((buffer-read-only))                                       
    (setf (point) (point-min))                                      
    (while (re-search-forward "[\200-\240]" nil t)                  
      (replace-match " "))                                            
    (set-buffer-multibyte t))                                       
  (set-buffer-modified-p nil))
;;=========================================================================
;;gdb-UI配置
;;=========================================================================
(setq gdb-many-windows t)
(load-library "~/.emacs.d/config/multi-gud.el")
(load-library "~/.emacs.d/config/multi-gdb-ui.el")
;;=========================================================================
;;cedet插件设置
;;See cedet/common/cedet.info for configuration details.
;;=========================================================================
(add-to-list 'load-path "~/.emacs.d/plugins/cedet-1.0/speedbar")
(add-to-list 'load-path "~/.emacs.d/plugins/cedet-1.0/eieio")
(add-to-list 'load-path "~/.emacs.d/plugins/cedet-1.0/semantic")
(load-file                                              ;;Load CEDET.,从cedet的INSTALL中复制过来的
 "~/.emacs.d/plugins/cedet-1.0/common/cedet.el")
(global-ede-mode 1)					;;Enable EDE (Project Management) features
(semantic-load-enable-minimum-features)
(semantic-load-enable-code-helpers)
(semantic-load-enable-semantic-debugging-helpers)
(global-ede-mode t)
;;==============================================================
;;ecb置
;;==============================================================

(require 'ecb)						;;开启ecb用,M-x:ecb-activate
(require 'ecb-autoloads)								
(setq ecb-auto-activate t)
(setq ecb-tip-of-the-day nil
      ecb-tree-indent 4
      ecb-windows-height 0.5
      ecb-windows-width 0.15
      ecb-auto-compatibility-check nil
      ecb-version-check nil)
;;      (ecb-change-layout "leftright-analyse"))				;;自动启动ecb并且不显示每日提示

(require 'cc-mode)

(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
(define-key c-mode-map [return] 'newline-and-indent)
(global-set-key [M-left] 'windmove-left)		;;为了ecb窗口的切换
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down] 'windmove-down)
(global-set-key [f11] 'ecb-hide-ecb-windows)		;;隐藏和显示ecb窗口
(global-set-key [S-f11] 'ecb-show-ecb-windows)
(global-set-key (kbd "M-g") 'goto-line)			;;设置M-g为goto-line
;;(global-set-key (kbd "C-SPC") 'nil)			;;取消control+space键设为mark
(global-set-key (kbd "M-<SPC>") 'set-mark-command)	;;这样 我就不用按 C-@ 来 setmark 了, C-@ 很不好按。
(global-set-key [home] 'beginning-of-buffer)		;;设置home键指向buffer开头,end键指向buffer结尾
(global-set-key [end] 'end-of-buffer)
(global-set-key (kbd "C-,") 'scroll-left)		;;"C-,"设为屏幕左移命令
(global-set-key (kbd "C-.") 'scroll-right)		;;"C-."设为屏幕右移命令
(global-set-key (kbd "C-z") 'set-mark-command)		;;C-z 设置标记
(global-set-key (kbd "M-4") 'delete-window)		;;关闭当前窗口,alt+4
;;(global-set-key (kbd "M-4") 'kill-this-buffer)
(global-set-key (kbd "M-1") 'delete-other-windows)	;;关闭其他窗口,alt+1
(global-set-key (kbd "M-2") 'split-window-vertically)	;;水平分割窗口,alt+2
(global-set-key (kbd "M-3") 'split-window-horizontally)	;;垂直分割窗口,alt+3
(global-set-key (kbd "M-0") 'other-window)		;;切换到其他窗口,alt+0
(global-set-key (kbd "M-5") 'display-buffer-name)	;;显示缓冲区完整名称
;;==========================================================
;;加载cscope
;;==========================================================
(require 'xcscope)
;;==========================================================
;; This snippet enables lua-mode
;; This line is not necessary, if lua-mode.el is already on your load-path
;;==========================================================
(add-to-list 'load-path "~/.emacs.d/plugins/lua-mode/")
(setq auto-mode-alist (cons '("\\.lua$" . lua-mode) auto-mode-alist))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-hook 'lua-mode-hook 'turn-on-font-lock)
(add-hook 'lua-mode-hook hs-minor-mode)
(defcustom ac-modes
  '(emacs-lisp-mode
    lisp-interaction-mode
    c-mode cc-mode c++-mode clojure-mode java-mode
    perl-mode cperl-mode python-mode ruby-mode
    ecmascript-mode javascript-mode js2-mode php-mode css-mode
    makefile-mode sh-mode fortran-mode f90-mode ada-mode
    xml-mode sgml-mode
    lua-mode muse-mode org-mode)
  "Major modes `auto-complete-mode' can run on."
  :type '(repeat symbol)
  :group 'auto-complete)
;;==========================================================
;;YASnippet的配置
;;==========================================================
(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet)    				;;not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet-0.6.1c/snippets")
;;==========================================================
;;自动补全 auto-complete
;;==========================================================
;(require 'auto-complete-config)
;(ac-config-default)
(add-to-list 'load-path "~/.emacs.d/plugins/auto-complete-1.3.1")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/plugins/auto-complete-1.3.1/dict")
(ac-config-default)
;;(add-to-list ‘ac-modes ‘(lua-mode, muse-mode, org-mode))
;##########################################################################
;  Keybord config
;##########################################################################
(global-semantic-tag-folding-mode 1)			;;代码折叠	
(define-key semantic-tag-folding-mode-map (kbd "C-_")   ;;折叠整个buffer的所有代码
  'semantic-tag-folding-fold-all)
(define-key semantic-tag-folding-mode-map (kbd "C-+")   ;;打开整个buffer的所有代码
  'semantic-tag-folding-show-all)
(define-key semantic-tag-folding-mode-map (kbd "C--")   ;;折叠单个buffer的所有代码
  'semantic-tag-folding-fold-block)
(define-key semantic-tag-folding-mode-map (kbd "C-=")   ;;打开单个buffer的所有代码
  'semantic-tag-folding-show-block)
(define-key-list
 global-map
 `(("C-x G l" goto-my-emacs-lisps-dir)
   ("C-x G m" goto-my-emacs-my-lisps-dir)
   ("C-x G e" goto-my-emacs-dir)
   ("C-x M-H" goto-my-home-dir)))
(define-key global-map (kbd "C-x M-c") 'describe-char)
(define-key global-map (kbd "C-x M-D") 'dos2unix)
(define-key-list
 global-map
 `(("C-x M-k" Info-goto-emacs-key-command-node)
   ("C-x ESC ESC" repeat-complex-command-sb)))
(global-set-key ( kbd "C-9") 'redo)			;;redo
(global-set-key [f1] 'manual-entry)
(global-set-key [C-f1] 'info )
(global-set-key [f3] 'grep-find)			;;为查找字符串,
(global-set-key [M-f3] 'kill-this-buffer)               ;;关闭当前缓冲区
(global-set-key [(f4)] 'speedbar-get-focus)		;;.emacs中设一个speedbar的快捷键
(global-set-key [C-f4] 'ecb-activate)			;;ctrl-f4,激活,ecb
(global-set-key [C-f5] 'tool-bar-mode)			;;ctrl-F5显示/隐藏工具栏 方便调试
(global-set-key [f5] 'menu-bar-mode)			;;F5显示/隐藏菜单栏 ;;M-x menu-bar-open
(global-set-key [f6] 'gdb)                              ;;GDB
(global-set-key [C-f7] 'compile)			;;设置编译命令
(global-set-key [f7] 'du-onekey-compile)                ;;保存所有文件然后编译当前窗口文件
(global-set-key [(f8)] 'open-eshell-other-buffer)	;;就是另开一个buffer然后打开shell
(global-set-key [C-f8] 'eshell)				;;在当前的buffer打开shell
(global-set-key [S-f8] 'my-eshell-clear-buffer)		;;清空eshell
(global-set-key [C-f9] 'dired)				;;调用dired命令
(global-set-key [f9] 'other-window)			;;在其他窗口之间切换
(global-set-key [C-f10] 'undo)				;;撤销
(global-set-key [C-f11] 'calendar) 			;;指定 Emacs 的日历系统
(global-set-key [f12] 'semantic-ia-fast-jump)		;;调到函数定义
(global-set-key [C-f12] 'list-bookmarks)		;;快速察看日程安排
(global-set-key [S-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 frist (cdr (car (cdr alist)))))
	(semantic-mrub-switch-tags first))))
(eal-define-keys-commonly
 global-map
 `(("C-x u"   revert-buffer-no-confirm)
   ("C-x M-K" revert-buffer-with-gbk)
   ("C-x U"   revert-buffer-with-coding-system-no-confirm-sb)))
(eal-define-keys-commonly
 global-map
 `(("C-x l" count-brf-lines)
   ("C-x L" (lambda () (interactive) (count-brf-lines t)))))
(define-key global-map (kbd "C-x M-c") 'describe-char)
(define-key global-map (kbd "C-x M-D") 'dos2unix)
(define-key-list
 global-map
 `(("C-x M-k" Info-goto-emacs-key-command-node)
   ("C-x ESC ESC" repeat-complex-command-sb)))
;##########################################################################
;  Function and Other
;##########################################################################


;;====================== rect-mark设置 =========================
;;按下shift拖拽鼠标即可选择矩形区域
;;Support for marking a rectangle of text with highlighting.
(require 'rect-mark)
(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.")
;=====================  rect-mark设置结束 =========================
;;###############################################################################
;;这个函数是一个 vi 的 "f" 命令的替代品。
;;当按 C-c a x (x 是任意一个字符) 时,光 标就会到下一个 x 处。再次按 x,光标就到下一个 x。比如 C-c a w w w w ..., C-c a b b b b b b ...
(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)
(defun my-c-mode-common-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  ;;;hungry-delete and auto-newline
;; (c-toggle-auto-hungry-state 1)
  (define-key c-mode-base-map [(control \`)] 'hs-toggle-hiding)
 (define-key c-mode-base-map [(return)] 'newline-and-indent)
  (define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
;; (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
;; (define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
  ;;预处理设置
  (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)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(defun my-c++-mode-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  (c-set-style "stroustrup")
;; (define-key c++-mode-map [f3] 'replace-regexp)
)
(setq semanticdb-project-roots                          ;;配置Semantic搜索范围
	  (list
	   (expand-file-name "/")))
(defun my-indent-or-complete()                          ;;自定义补全命令,如果单词在中间就补全,否则就tab
  (interactive)
  (if (looking-at "\\>")
	  (hippie-expand nil)
	  (indent-for-tab-command))
  )
(global-set-key [(control tab)] 'my-indent-or-complete) ;;补全快捷键,ctrl+tab用senator补全,不显示列表
(define-key c-mode-base-map [(meta ?/)]                 ;;alt+/补全,显示列表让选择
  'semantic-ia-complete-symbol-menu)
(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
		)
	  )
(defvar switch-major-mode-last-mode nil)                ;;方便的切换major mode
(defun major-mode-heuristic (symbol)
  (and (fboundp symbol)
       (string-match ".*-mode$" (symbol-name symbol))))
(defun switch-major-mode (mode)
  "切换major mode"
  (interactive
   (let ((fn switch-major-mode-last-mode) val)
     (setq val
           (completing-read
            (if fn (format "切换major-mode为(缺省为%s): " fn) "切换major mode为: ")
            obarray 'major-mode-heuristic t nil nil (symbol-name fn)))
     (list (intern val))))
  (let ((last-mode major-mode))
    (funcall mode)
    (setq switch-major-mode-last-mode last-mode)))
(global-set-key (kbd "C-x q") 'switch-major-mode)
(defun get-mode-name ()
  "显示`major-mode'及`mode-name'"
  (interactive)
  (message "major-mode为%s, mode-name为%s" major-mode mode-name))
(global-set-key (kbd "C-x m") 'get-mode-name)
(autoload                                               ;;查看Emacs内进程
  'list-processes+ "list-processes+" "增强的`list-processes'命令" t)
(require 'view-mode-settings)
(defun revert-buffer-no-confirm ()
  "执行`revert-buffer'时不需要确认"
  (interactive)
  (when (buffer-file-name)
    (let ((emaci emaci-mode))
      (revert-buffer buffer-file-name t)
      (emaci-mode (if emaci 1 -1)))))
(eal-define-keys-commonly
 global-map
 `(("C-x u"   revert-buffer-no-confirm)
   ("C-x M-K" revert-buffer-with-gbk)
   ("C-x U"   revert-buffer-with-coding-system-no-confirm-sb)))
(defun count-brf-lines (&optional is-fun)
  "显示当前buffer或region或函数的行数和字符数"
  (interactive "P")
  (let (min max)
    (if is-fun
        (save-excursion
          (beginning-of-defun) (setq min (point))
          (end-of-defun) (setq max (point))
          (message "当前函数%s内共有%d行, %d个字符" (which-function) (count-lines min max) (- max min)))
      (if mark-active
          (progn
            (setq min (min (point) (mark)))
            (setq max (max (point) (mark))))
        (setq min (point-min))
        (setq max (point-max)))
      (if (or (= 1 (point-min)) mark-active)
          (if mark-active
              (message "当前region内共有%d行, %d个字符" (count-lines min max) (- max min))
            (message "当前buffer内共有%d行, %d个字符" (count-lines min max) (- max min)))
        (let ((nmin min) (nmax max))
          (save-excursion
            (save-restriction
              (widen)
              (setq min (point-min))
              (setq max (point-max))))
          (message "narrow下buffer内共有%d行, %d个字符, 非narrow下buffer内共有%d行, %d个字符"
                   (count-lines nmin nmax) (- nmax nmin) (count-lines min max) (- max min)))))))
(eal-define-keys-commonly
 global-map
 `(("C-x l" count-brf-lines)
   ("C-x L" (lambda () (interactive) (count-brf-lines t)))))
(defun goto-my-emacs-lisps-dir ()
  "Goto `my-emacs-lisps-path'."
  (interactive)
  (dired my-emacs-lisps-path))
(defun goto-my-emacs-my-lisps-dir ()
  "Goto `my-emacs-my-lisps-path'."
  (interactive)
  (dired my-emacs-my-lisps-path))
(defun goto-my-emacs-dir ()
  "Goto `my-emacs-path'."
  (interactive)
  (dired my-emacs-path))
(defun goto-my-home-dir ()
  "Goto my home directory."
  (interactive)
  (dired "~"))
(defun dos2unix ()
  "dos2unix on current buffer."
  (interactive)
  (set-buffer-file-coding-system 'unix))
(defun unix2dos ()
  "unix2dos on current buffer."
  (interactive)
  (set-buffer-file-coding-system 'dos))
(defun du-onekey-compile ()
  "Save buffers and start compile"
  (interactive)
  (save-some-buffers t)
  (switch-to-buffer-other-window "*compilation*")
  (compile compile-command))
(defun open-eshell-other-buffer ()
  "Open eshell in other buffer"
  (interactive)
  (split-window-vertically)
  (eshell))
(defun my-eshell-clear-buffer ()
  "Eshell clear buffer."
  (interactive)
  (let ((eshell-buffer-maximum-lines 0))
    (eshell-truncate-buffer)))
(setq-default compile-command "make")    
;;(hl-line-mode -1)
;;(global-hl-line-mode -1)
;;for hight line mode
(or (facep 'my-hl-line-face) (make-face 'my-hl-line-face))
(setq hl-line-face 'my-hl-line-face)
(face-spec-set 'my-hl-line-face '((t (
                                      :background "DodgerBlue3"
                                                  ;;:bold
                                                  ;;:weight nil
                                      :inverse-video nil
                                      ))))
(defun color-theme-adjust-hl-mode-face()
  "interactive"
  (let* ((color  (x-color-values (face-attribute 'default :background))))
    (if (null color)
        (error "not support.")
      (let ((my-color (mapcar
                       (lambda (x)
                         (let ((y (/ #XFFFF 4))
                               (delta #X18FF))
                           (cond
                            ((< x (* y 1))
                             (+ x delta))
                            ((< x (* y 2))
                             (+ x delta))
                            ((< x (* y 3))
                             (- x delta))
                            (t
                             (- x delta)))))
                       color)))
        (message "%S %S" color my-color)
        (set-face-attribute
         'my-hl-line-face nil
         :background
         (concat "#"
                 (mapconcat
                  (lambda (c) (format "%04X" c))
                  my-color
                  "")))))))
(color-theme-adjust-hl-mode-face)
(defun revert-buffer-no-confirm ()
  "执行`revert-buffer'时不需要确认"
  (interactive)
  (when (buffer-file-name)
    (let ((emaci emaci-mode))
      (revert-buffer buffer-file-name t)
      (emaci-mode (if emaci 1 -1)))))
(defun count-brf-lines (&optional is-fun)
  "显示当前buffer或region或函数的行数和字符数"
  (interactive "P")
  (let (min max)
    (if is-fun
        (save-excursion
          (beginning-of-defun) (setq min (point))
          (end-of-defun) (setq max (point))
          (message "当前函数%s内共有%d行, %d个字符" (which-function) (count-lines min max) (- max min)))
      (if mark-active
          (progn
            (setq min (min (point) (mark)))
            (setq max (max (point) (mark))))
        (setq min (point-min))
        (setq max (point-max)))
      (if (or (= 1 (point-min)) mark-active)
          (if mark-active
              (message "当前region内共有%d行, %d个字符" (count-lines min max) (- max min))
            (message "当前buffer内共有%d行, %d个字符" (count-lines min max) (- max min)))
        (let ((nmin min) (nmax max))
          (save-excursion
            (save-restriction
              (widen)
              (setq min (point-min))
              (setq max (point-max))))
          (message "narrow下buffer内共有%d行, %d个字符, 非narrow下buffer内共有%d行, %d个字符"
                   (count-lines nmin nmax) (- nmax nmin) (count-lines min max) (- max min)))))))
这个是我的配置文件。。大部分是从网络上找的。。
回复