个人工具

Index/editor/emacs-config/editor/emacs-config/init.el

来自Ubuntu中文

跳转至: 导航, 搜索

这是emacs的通用配置文件, 目的只为了让emacs成为更好用的编辑器.

<nowiki>
;;; -*- mode: Emacs-Lisp -*-
;;;
;;; File  : ~/.emacs.d/init.el
;;; Author: Yonsan <L4_yonsan@hotmail.com>
;;;
;;; Time-stamp: <2006-01-13 02:28:51 Yonsan>

;;; Note: Emacs 22.0.51 on gentoo

;; setup default user information
(setq user-full-name "Yonsan")
(setq user-mail-address "L4_yonsan@hotmail.com")

;; time stamp support
(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-format "%:y-%02m-%02d %02H:%02M:%02S Yonsan")

;; global color( AntiqueWhite, peachpuff, gray80 )
(set-foreground-color "black")
(set-background-color "gray80")

;; modeline color
(set-face-foreground 'modeline "azure")
(set-face-background 'modeline "#b24d7a")

;; cursor color
(set-cursor-color "orange")

;; blink the screen instead of beeping
(setq visible-bell t)

;; disable the tool bar
(tool-bar-mode -1)

;; disable the scroll bar
(set-scroll-bar-mode nil)

;; no startup message
(setq inhibit-startup-message t)

;; no message in the scratch buffer
(setq initial-scratch-message nil)

;; Make all "yes or no" prompts show "y or n" instead
(fset 'yes-or-no-p 'y-or-n-p)

;; mouse auto move when closing the currsor
(mouse-avoidance-mode 'animate)

;; Activate the dynamic completion of buffer names
(iswitchb-mode 1)

;; Activate the dynamic completion in the mini-buffer
(icomplete-mode 1)

;; Show the time
(display-time)

;; Show the column number
(column-number-mode 1)

;; always at the end of current line when move the cursor
(setq track-eol t)

;; keep mini window size
(setq resize-mini-windows nil)

;; set default mode to text-mode and turn on auto-fill-mode
(setq default-major-mode 'text-mode)

;;display dirs first in dired
(setq ls-lisp-dirs-first t)

;;;highlight during query
(defconst query-replace-highlight t)

;;highlight incremental search
(defconst search-highlight t)

;; Show the matching immediately, we are in a hurry
(setq show-paren-delay 0)
(show-paren-mode t)

;; Show matching parenthesis
(setq show-paren-style 'expression)

;; take the CR when killing a line
(setq kill-whole-line t)

;; Do not keep tracks of the autosaved files
(setq auto-save-list-file-prefix nil)

;; Show me empty lines at the end of the buffer
(setq default-indicate-empty-lines t)

;; Show me the region until I do something on it
(setq transient-mark-mode t)

;; do not fill my buffers, you fool
(setq next-line-add-newlines nil)

;; keep the window focused on the messages during compilation
(setq compilation-scroll-output t)

;; don't hide DOS lineendings (^M):
(setq inhibit-eol-conversion t)

;; no name~ backup files
(setq make-backup-files nil)

;; enable copy & paste from other program
(setq x-select-enable-clipboard t)
	
;; Enable emacs functionality that is disabled by default
(put 'eval-expression 'disabled nil)
(put 'set-goal-column 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'eval-expression 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(setq enable-recursive-minibuffers t)

;; locale coding
(setq locale-coding-system'utf-8)
(prefer-coding-system'utf-8)
(set-keyboard-coding-system'utf-8)
(set-terminal-coding-system'utf-8)
(set-selection-coding-system'utf-8)
(set-clipboard-coding-system 'ctext)
(set-buffer-file-coding-system 'utf-8)

;; the first is default font ( I like size of 13 )
(create-fontset-from-fontset-spec
(concat "-*-simsun-medium-r-*-*-13-*-*-*-*-*-fontset-simsun,
chinese-gbk-0:-*-simsun-medium-r-*-*-13-*"))

(create-fontset-from-fontset-spec
(concat "-*-simsun-medium-r-*-*-12-*-*-*-*-*-fontset-simsun,
chinese-gbk-0:-*-simsun-medium-r-*-*-12-*"))

(create-fontset-from-fontset-spec
(concat "-*-simsun-medium-r-*-*-14-*-*-*-*-*-fontset-simsun,
chinese-gbk-0:-*-simsun-medium-r-*-*-14-*"))

(create-fontset-from-fontset-spec
(concat "-*-simsun-medium-r-*-*-15-*-*-*-*-*-fontset-simsun,
chinese-gbk-0:-*-simsun-medium-r-*-*-15-*"))

(create-fontset-from-fontset-spec
(concat "-*-simsun-medium-r-*-*-16-*-*-*-*-*-fontset-simsun,
chinese-gbk-0:-*-simsun-medium-r-*-*-16-*"))

(set-default-font "fontset-simsun")
(setq default-frame-alist (append '((font . "fontset-simsun")
(width . 100) (height . 38))))


;; keys building
(setq ff-map (make-sparse-keymap))
(define-key global-map [(control \`)] ff-map)
(define-key esc-map "`" ff-map)

;;; a shell part
(defun shell-new-buffer (buffername program &rest param)
"Start a terminal-emulator in a new buffer with the shell PROGRAM,
optionally invoked with the parameters PARAM. The process associated
to the shell can be killed without query."

(interactive)

(let ((n 1)
(bn buffername))

(while (get-buffer (concat "*" bn "*"))
(setq n (1+ n)
bn (format "%s<%d>" buffername n)))

(set-buffer (apply 'make-term (append (list bn program nil) param)))
(term-mode)
(setq show-trailing-whitespace nil)
(term-char-mode)

;; A standard setup of the face above is not enough, I have to
;; force them here. Since I have a gray80 background, I like
;; darker colors.

(configure-faces
'((term-green :foreground "green3")
(term-cyan :foreground "cyan3")
(term-default-fg-inv :foreground "gray80" :background "black")))

(process-kill-without-query (get-buffer-process (current-buffer)))
(switch-to-buffer (concat "*" bn "*"))
))

(defcustom default-bash-commands '("ssh")
"*List of commands to be used for completion when invoking a new
bash shell with `bash-new-buffer'.")

(defun bash-new-buffer (universal)
"Starts a bash in a new buffer. When invoked with a universal
argument, asks for a command to execute in that bash shell. The list
of commands in `default-bash-commands' is used for auto-completion"
(interactive "P")
(if universal
(let ((cmd (completing-read
"Command: "
(mapcar (lambda (x) (cons x t)) default-bash-commands))))
(shell-new-buffer cmd "/bin/bash" "-c" cmd)
)
(shell-new-buffer "bash" "/bin/bash")))

(define-key ff-map [(control \`)] 'bash-new-buffer)

;;; ============================= 以下内容为emacs自动添加的 ==========================

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