1.emacs配置文件
~/.emacs
;;;;;;;;;;;;;;文件內(nèi)容如下;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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.
'(ansi-color-names-vector ["#2d3743" "#ff4242" "#74af68" "#dbdb95" "#34cae2" "#008b8b" "#00ede1" "#e1e1e0"])
'(custom-enabled-themes (quote (sanityinc-solarized-dark)))
'(custom-safe-themes (quote ("4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" default)))
'(delete-selection-mode nil)
'(livedown:autostart nil)
'(livedown:open t)
'(livedown:port 1337)
'(markdown-command "/usr/bin/pandoc")
'(send-mail-function (quote smtpmail-send-it))
'(show-paren-mode t)
'(smtpmail-smtp-server "smtp.163.com")
'(smtpmail-smtp-service 25)
'(tool-bar-mode nil))
(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.
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 以上是自動生成的主題代碼,下面配置加載我們自己的東西
(load "~/.emacs.d/init") ;; 這里可以省略.el后綴,注意備份這個文件。
emacs配置文件夾下的init.el文件
~/.emacs.d/init.el
;;;;;;;;;;;;;;;;;;;;文件內(nèi)容如下;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 窗口令花、按鍵配置開始;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-linum-mode t) ;; M-g g <line number>
;;;不要滾動欄削彬、工具欄乎串。這里的0不能用nil替換站超,否則無效。
(scroll-bar-mode 0)
(tool-bar-mode 0)
;; (menu-bar-mode 0) ;; 菜單欄有時候可以提示一些快捷鍵榆浓,可以保留。
(setq default-frame-alist '((height . 38) (width . 128) )) ;; 設(shè)置屏幕高撕攒、寬度
(global-set-key [(f9)] 'bs-show) ;; 顯示工作緩沖區(qū)列表,q鍵退出陡鹃。
(global-set-key [(f7)] 'bs-cycle-previous)
(global-set-key [(f8)] 'bs-cycle-next)
;; (global-set-key (kbd "C-tab") 'bs-cycle-next) ;; C-tab鍵綁定失敗
(global-set-key [C-tab] 'bs-cycle-next) ;; 這樣寫就成功,奇了個怪
;; (global-set-key [C-tab] 'next-buffer) ;; 這樣顯示的buff包含了所有工作的buff抖坪,
;; 比如*message*等萍鲸。
;; (global-set-key [C-tab] 'next-buffer)
;; (global-set-key [C-S-iso-lefttab] 'previous-buffer);Linux
;; (global-set-key [C-S-tab] 'previous-buffer);Windows/Linux
(global-set-key (kbd "C-M-m") 'set-mark-command) ;; C-@ is hard to use!!
;; 窗口、按鍵配置結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 字體配置開始;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set-face-attribute
'default nil :font "DejaVu Sans Mono" );;英文字體
; Chinese Font
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "YaHei Consolas Hybrid" :size 16)));;中文字體
(provide 'init-fonts)
(require 'init-fonts)
;; 字體配置結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; markdown-mode configure;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)
(add-to-list 'load-path "/home/adam/markdown-mode/markdown-mode")
(add-to-list 'load-path "~/.emacs.d/modes")
(autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
(setq auto-mode-alist (cons '("\\.markdown" . markdown-mode) auto-mode-alist))
(custom-set-variables '(markdown-command "/usr/bin/pandoc"))
;; end of markdown-mode configure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; livedown配置開始柳击,通過瀏覽器實時預(yù)覽md文件;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path (expand-file-name "~/.emacs.d/emacs-livedown"))
(custom-set-variables
'(livedown:autostart nil) ; automatically open preview when opening markdown files
'(livedown:open t) ; automatically open the browser window
'(livedown:port 1337)) ; port for livedown server
(require 'livedown)
;; (global-set-key (kbd "C-M-m") 'livedown:preview)
;; livedown配置結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; switch-window配置看開始猿推,當(dāng)分割的窗口大于等于3個時,插件提示數(shù)字捌肴,按相應(yīng)的數(shù)字跳轉(zhuǎn)窗口;;;;;;;;;
;; package-install RET switch-window RET
;; 會自動安裝到~/.emacs.d/elpa/switch-window-1.0.0/目錄
(global-set-key (kbd "C-x o") 'switch-window) ;; C-x C-e 使之生效
;; switch-window配置結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 設(shè)置窗口透明模式開始;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;set transparent effect
(global-set-key [(f11)] 'loop-alpha)
(setq alpha-list '((100 100) (95 65) (85 55) (75 45) (65 35)))
(defun loop-alpha ()
(interactive)
(let ((h (car alpha-list))) ;; head value will set to
((lambda (a ab)
(set-frame-parameter (selected-frame) 'alpha (list a ab))
(add-to-list 'default-frame-alist (cons 'alpha (list a ab)))
) (car h) (car (cdr h)))
(setq alpha-list (cdr (append alpha-list (list h))))
)
)
;; 設(shè)置窗口透明模式結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 備份相關(guān);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (setq backup-directory-alist (quote (("." . "~/.emacs-backups"))))
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/.emacs-backups")))
(setq backup-by-copying t)
;; 備份相關(guān)結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 應(yīng)用模板配置;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(auto-insert-mode) ;;; Adds hook to find-files-hook
(setq auto-insert-directory "~/.emacs.d/mytemplates") ;;; Or use custom, *NOTE* Trailing slash important
(setq auto-insert-query nil) ;;; If you don't want to be prompted before insertion
(setq auto-insert-alist
(append '((f90-mode . "Template.f90")
(python-mode . "Template.py")
(c-mode . "Template.c")
(markdown-mode . "Template.md")
)
auto-insert-alist))
;; 應(yīng)用模板配置結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; sanityinc solarized theme ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages"))
(package-initialize)
(load-theme 'sanityinc-solarized-dark t)
;; end of theme ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 自定義函數(shù)蹬叭,用于插入日期、占位符和html回車符 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun my-insert-date ()
(interactive)
(insert (format-time-string "%Y-%m-%d" (current-time)))
)
(global-set-key (kbd "C-M-d") 'my-insert-date)
;; 自定義一個插入2個漢字占位符的函數(shù)
(defun my-space-word ()
(interactive)
(insert "??")
)
(global-set-key (kbd "C-M-t") 'my-space-word)
(defun my-enter-char ()
(interactive)
(insert "<br />\n")
)
(global-set-key (kbd "C-M-e") 'my-enter-char)
;; 自定義函數(shù)状知,用于插入日期秽五、占位符和html回車符結(jié)束;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;關(guān)閉emacs啟動時的畫面;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq inhibit-startup-message t)
;;關(guān)閉gnus啟動時的畫面
(setq gnus-inhibit-startup-message t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 啟用自動插入括號;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(electric-pair-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2.~/.bashrc的最后幾行
alias ping='ping -c3'
alias .='source'
alias ..='cd ..'
alias dl='cd ~/下載'
alias wd='cd ~/文檔'
alias cls='clear'
alias ll='ls -la'
3. ~/.emacs.d配置文件夾
重要的是里面的一些模板文件
- ~/.emacs.d/mytemplates/Template.c
/* ========================================================================== */
/* */
/* Filename.c */
/* (c) 2001 Author */
/* */
/* Description */
/* */
/* ========================================================================== */
void main(int argc, char* argv[]) {
}
- ~/.emacs.d/mytemplates/Template.py
# -*- coding:utf-8 -*-
- ~/.emacs.d/mytemplates/Template.md
<!--
author: adam
head:
date: C-M-d 插入日期
title: Input your title here, please.
tags: input your tag here.
images:
category:
status: published
summary:some text C-M-t 插入2個漢字占位符
-->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
#### 1.
#### 2.
#### 3.
#### 4.
***
這個是模板里面用于生成日期的lisp語句,無奈它不會自動執(zhí)行饥悴。還想不到由好的方法
(insert (format-time-string "%Y-%m-%d" (current-time)))
`C-u M-! date <ret>` 直接調(diào)用shell命令的方法坦喘,直接插入也行。
寫個函數(shù)西设,再綁定按鍵瓣铣,調(diào)用也行
記錄幾個好玩的svg圖形,用于超鏈接:
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" width="16" height="16" viewBox="0 0 200 200"><g class="transform-group"><g transform="scale(0.1953125, 0.1953125)"><path d="M616.192 404.352C609.28 397.504 602.048 391.296 594.496 385.6L524.672 455.424c8.128 4.864 15.872 10.56 22.848 17.6L551.04 476.544c44.736 44.736 44.736 117.504 0 162.24l-190.848 190.848c-44.736 44.736-117.504 44.736-162.176 0l-3.52-3.52c-44.736-44.736-44.736-117.504 0-162.176l86.336-86.336c-14.976-37.056-22.08-76.48-21.504-115.84L125.76 595.2c-82.368 82.368-82.368 217.152 0 299.584l3.52 3.52c82.368 82.368 217.152 82.368 299.584 0l190.848-190.848c82.368-82.368 82.368-217.152 0-299.52L616.192 404.352zM898.24 129.344 894.72 125.824c-82.368-82.368-217.152-82.368-299.52 0L404.288 316.672c-82.368 82.368-82.368 217.152 0 299.52l3.52 3.52C414.72 626.56 422.016 632.768 429.504 638.528l69.824-69.824C491.2 563.84 483.52 558.08 476.48 551.104L472.96 547.584c-44.736-44.736-44.736-117.504 0-162.24l190.848-190.848c44.736-44.736 117.504-44.736 162.176 0l3.52 3.52c44.736 44.736 44.736 117.504 0 162.176l-86.336 86.336c14.976 37.056 22.08 76.48 21.504 115.84l133.568-133.504C980.608 346.496 980.608 211.712 898.24 129.344z" fill="#27ae60"></path></g></g></svg>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="octicon octicon-link" role="img" width="16" version="1.1" height="16" viewbox="0 0 16 16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg>
中文縮進(jìn)分隔符,代表一個漢字寬度贷揽,`?`棠笑,空格` `,半個漢字寬度`?`
正文從一下開始禽绪,編輯完成后記得刪除這些消息蓖救。要是用ReText編輯器洪规,可以直接預(yù)覽上面的圖形哦。
***
*<h6 style="text-align:right">--end--<h6>*
4. emacs統(tǒng)一備份目錄
把emacs編輯過的文件自動備份到這個目錄下循捺,不然原目錄會顯得很雜亂斩例。
~/.emacs-backups