科學思考 保持疑問 洞悉本質

dotemacs配置文件

Emacs26 windows版下載: https://mirror.tuna.tsinghua.edu.cn/gnu/emacs/windows/

沒空弄插件,下載程序後,直接複製以下內容黏貼到Linux用户家目錄下$ .emacs
或Windows系統下 C:\Users\Administrator\AppData\Roaming\.emacs 文件即可使用。

配置及注釋:

;;關閉Emacs啟動時提示信息
(setq inhibit-startup-message t)
;;去掉煩人的警告鈴聲
(setq visible-bell nil)
;;默認目錄 Linux下用~/
(setq default-directory "C:/emacs/note/")
;;時間格式 
(setq display-time-24hr-format t)
;;顯示時間、星期、日期
(setq display-time-day-and-date t) 
;;设置M-g为goto-line
(global-set-key (kbd "M-g") 'goto-line)
;;自動補全括號
(electric-pair-mode t)
;;匹配括號的時候, 不要跳到另一個括號那裡
(setq show-paren-style 'parentheses)
;;讓所有 "yes or no" 全部使用 "y or n"
(fset 'yes-or-no-p 'y-or-n-p)
;;高亮顯示要拷貝的區域
(transient-mark-mode t)
;;允許emacs和外部其他程式的黏貼
(setq x-select-enable-clipboard t)
;;滾輪支持
(setq mouse-wheel-mode t)
;;保存時自動清除行尾空格及文件結尾空行
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;;防止頁面滾動時跳動,可以在靠近屏幕邊沿3行時就開始滾動
(setq scroll-margin 1 scroll-conservatively 10000)
;;當光標在行尾上下移動的時候,始終保持在行尾。
(setq track-eol t)
;;防止刪除東西,弄一個超大的kill ring
(setq kill-ring-max 200)
;;文字行寬60個英文字母
(setq default-fill-column 60)
;;設置默認打開窗口大小windows下用
(setq default-frame-alist
'((height . 20) (width . 100) (menu-bar-lines . 30) (tool-bar-lines . 0)))
;;生成临时文件
(setq-default make-backup-files t)
(setq make-backup-file t)
(setq make-backup-files t)
;;;;備份策略
;;配置備份文檔的路徑
(setq backup-directory-alist '(("." . "c:/emacs/.emacs.d/auto-save-list/")))
;;啟用版本控制,即能夠備份多次
(setq version-control t)
;;備份最原始的版本兩次,即第一次編輯前的文檔,和第二次編輯前的文檔
(setq kept-old-versions 2)
;;備份最新的版本5次,理解同上
(setq kept-new-versions 5)
;;刪掉不屬於以上版本的版本
(setq delete-old-versions t)
;;自動存盤
(setq auto-save-mode t)
;;擊鍵100次自動保存
(setq auto-save-interval 100)
;;改變emacs標題欄的標題
(setq frame-title-format "%b@Leon")
;;去除ESC提示。
(global-unset-key "\e\e")
(global-unset-key "\C-x\C-u")
;;常用命令鍵綁定,刪除緩衝區
(global-set-key [f9] 'kill-buffer)
;;打開txt文件自動使用Org
(add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
;;Org自動換行
(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)))
;;快速插入時間
(defun insert-current-time ()
"Insert the current time"
(interactive "*")
(insert (format-time-string "%Y/%m/%d %H:%M:%S" (current-time))))
;;(insert (format-time-string "%Y-%m-%d" (current-time))))
;;(insert (format-time-string "%H:%M:%S" (current-time))))
(global-set-key "\C-xt" 'insert-current-time)
;;顯示行號、編碼、主題、時間、縱行、顯示匹配的括號
(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)
 '(current-language-environment "UTF-8")
 '(custom-enabled-themes (quote (tango-dark)))
 '(display-time-mode t)
 '(global-display-line-numbers-mode t)
 '(show-paren-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.
 '(default ((t (:family "MingLiU-ExtB" :foundry "outline" :slant normal :weight normal :height 158 :width normal)))))
back to top