;;-------------------------括号匹配--------------------------
;;括号匹配时显示另一端的括号,而不是跳过去
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;;-------------------------语法加亮--------------------------
(global-font-lock-mode t)
;;C默认格式为linux
(add-hook 'c-mode-hook
'(lambda()
(c-set-style "linux")))
;;取消开机画面
(setq inhibit-startup-message t)
;;-------------------------显示列号--------------------------
;;(setq column-number-mode t)
;;display the column number and line number
(setq column-number-mode t)
(setq line-number-mode t)
;;-------------------------标题拦显示buffer的名字------------
;;(setq frame-title-format "emacs@%b")
;Emacs title bar to reflect file name
;(defun frame-title-string ()
;"Return the file name of current buffer, using ~ if under home directory"
;(let
;((fname (or
;(buffer-file-name (current-buffer))
;(buffer-name))))
;;let body
;(when (string-match (getenv "HOME") fname)
;(setq fname (replace-match "~" t t fname)) )
; fname))
; (defun display-buffer-name ()
; (interactive)
; (message (buffer-file-name (current-buffer))))
;;; Title = 'system-name File: foo.bar'
;(setq frame-title-format '("" system-name " File: "(:eval (frame-title-string))))
(defun frame-title-string ()
"Return the file name of current buffer, using ~ if under home directory"
(let ((fname (or (buffer-file-name (current-buffer)) (buffer-name))))
;;let body
(when (string-match (getenv "HOME") fname)
(setq fname (replace-match "~" t t fname)) )
fname))
;;; Title = 'system-name File: foo.bar'
(setq frame-title-format '("" system-name " File: "(:eval (frame-title-string))))
;;-------------------------设置emacs启动时初始化大小-------------------------
;;(setq initial-frame-alist '((top . 0) (left . 0) (width . 1280) (height . 1024)))
;字体设置
;(set-default-font "YaHeiConsolas-13")
;(set-fontset-font "fontset-default"
; 'unicode '("YaHeiConsolas-13" . "unicode-bmp"))
;(setq default-frame-alist
; (append '((font . "YaHeiConsolas-13")) default-frame-alist))
;解决emacs shell 乱码
(setq ansi-color-for-comint-mode t)
(customize-group 'ansi-colors)
(kill-this-buffer);关闭customize窗口
;自定义按键
(global-set-key [f1] 'shell);F1进入Shell
(global-set-key [f5] 'gdb);F5调试程序
(setq compile-command "make -f Makefile")
(global-set-key [f7] 'do-compile);F7编译文件
(global-set-key [f8] 'other-window);F8窗口间跳转
(global-set-key [C-return] 'kill-this-buffer);C-return关闭当前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 关闭其它窗口
(global-set-key [f12] 'my-fullscreen);F12 全屏
(global-set-key (kbd "C-,") 'backward-page);文件首
(global-set-key (kbd "C-.") 'forward-page);文件尾
;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
;最大化
(defun my-maximized-horz ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(defun my-maximized-vert ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(defun my-maximized ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(my-maximized)
;;-------------------------设置Emacs的前景色和背景色(手工设置)-------------------------
(setq default-frame-alist
'(
(foreground-color . "Wheat")
(background-color . "DarkSlateGray")
(cursor-color . "green1")
) ls
)
;; -------------------------将文件模式和文件后缀关联起来。append表示追加-------------------------
(
setq auto-mode-alist
( append
'(("\\.py\\'" . python-mode)
("\\.s?html?\\'" . html-helper-mode)
(" \\.asp\\'" . html-helper-mode)
("\\.phtml\\'" . html-helper-mode)
("\\.css\\'" . css-mode)
("\\.pc$" . c-mode)
)
auto-mode-alist))
;;------------------------------------其它设置---------------------------------------
;;(setq default-major-mode 'text-mode);一打开就起用 text 模式。
(auto-image-file-mode t);打开图片显示功能
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no,可能你觉得不需要,呵呵。
(display-time-mode 1);显示时间,格式如下
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
;(tool-bar-mode nil);去掉那个大大的工具栏
;(scroll-bar-mode nil);去掉滚动条,因为可以使用鼠标滚轮了 ^_^
(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(transient-mark-mode t);
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq default-fill-column 80);默认显示 80列就换行
;;(setq-default make-backup-files nil);不要生成临时文件
(setq track-eol t);當光標在行尾上下移動的時候,始終保持在行尾。
(setq scroll-margin 3 scroll-conservatively 10000);防止頁面滾動時跳動 scroll-margin 3 可以在靠近屏幕边沿3行时就开始滚动,可以很好的看到上下文。
(setq mouse-yank-at-point t);中鍵粘貼
;;(setq require-final-newline t);; 自动的在文件末增加一新行
(prefer-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq load-path (cons "/home/black/.emacs.d/" load-path))
(setq auto-mode-alist
(cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
(cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
;;; add these lines if you like color-based syntax highlighting
;(global-font-lock-mode t)
;(setq font-lock-maximum-decoration t)
;(set-language-environment 'Chinese-GB)
;(set-keyboard-coding-system 'euc-cn)
;(set-clipboard-coding-system 'euc-cn)
;(set-terminal-coding-system 'euc-cn)
;(set-buffer-file-coding-system 'euc-cn)
;(set-selection-coding-system 'euc-cn)
;(modify-coding-system-alist 'process "*" 'euc-cn)
;(setq default-process-coding-system
; '(euc-cn . euc-cn))
;(setq-default pathname-coding-system 'euc-cn)
atl + . 看函数或者变量定义
ctrl + u alt + . 跳到下一个定义处, 如果有更多的话
加快捷键,如果光标放在函数上,直接有另外一个窗口显示函数的定义,那就更好了, 不需要跳转, 因为有些函数很小,跳转也是比较繁琐, 能直接看到就OK了。利用Emacs看阿拉伯文字,还有收发邮件, 看bbs, 应该要去尝试一下。