Emacs 重新開始,從心開始
重裝系統之後,也重裝了emacs,采用了GNU Emacs 25.3.1,重新整理了.emacs配置
隻保留最基本的功能.達到簡化的目的,我認為以下功能是必需的,記錄與此.
1. emacs 預設白底黑字, 通過菜單改為黑底白字. 儲存後會在.emacs生成對應客戶化配置.
2. emacs 預設啟動About Gnu Emacs 視窗, 禁用之:
3. 用list-package指令, 發現才269個包, 怎麼那麼少, 沒有我喜歡的插件,是以需要配置一下源.
添加gnu 和 melpa 的源, 用國内鏡像也許會快點,但也可能有别的問題.
再啟動emacs, 一下子有4057個包, 這下夠用了,從裡面選擇喜歡的吧.
4. 最大化視窗設定 (隻用滑鼠點選,最後還是要輸入幾個字的,fullscreen,maximized.
5. 關閉産生備份檔案(~檔案),設定一個變量.
同時通過變量設定也設定了标題欄顯示i格式,顯示列号
6. ace-jump 插件,友善螢幕上光标移動. 設定快捷鍵C-c SPC, C-x SPC
7. ace-window 插件,友善切換視窗. 設定快捷鍵 C-x o (覆寫舊切換方式)
8. 打開recentf minor 模式
9. 引入autosave 插件, 能自動幫我們存儲改動的檔案.
關于不啟動emacs, 重新加載.emacs 或者執行其中的語句或函數
C-x C-e 執行光标前面的一條語句。
選擇一個 region , M-x eval-region
M-x load-file ~/.emacs
都是立即生效!
如此便是一個強悍的shell 和 具有完備功能的文本編輯器
附上配置代碼:
(setq package-archives '(("gnu". "http://elpa.gnu.org/packages/")
("melpa"."http://melpa.milkbox.net/packages/")))
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
;;禁用啟動畫面
(setq inhibit-startup-message t)
(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.
'(initial-frame-alist (quote ((fullscreen . maximized))))
'(package-selected-packages (quote (ace-window ace-jump-mode))))
(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 (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 128 :width normal :foundry "unknown" :family "Ubuntu Mono")))))
;;for ace-jump mode
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
;; shell mode 自己重新定義了c-c SPC, 我們這裡重新定義c-c SPC到ace-jump-mode
(add-hook 'shell-mode-hook
(lambda ()
(local-set-key (kbd "C-c SPC") 'ace-jump-mode)))
(global-set-key [C-return] 'set-mark-command);; 重新設定mark 快捷鍵
(global-set-key (kbd "C-x o") 'ace-window);; 啟用ace-window 快捷鍵
(setq frame-title-format "%f");;标題欄顯示 %f 緩沖區完整路徑 %p 頁面百分數 %l 行号
(setq column-number-mode t);; 顯示列号
(setq make-backup-files nil) ;; 不出現備份檔案(~檔案)
(show-paren-mode t);; 高亮比對符号
(fset 'yes-or-no-p 'y-or-n-p);;用y-n替代yes,no
;;recentf
(recentf-mode t)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 100)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
;;autosave
(add-to-list 'load-path "~/mylisp") ;;添加路徑
(require 'auto-save) ;; 加載自動儲存子產品
(auto-save-enable) ;; 開啟自動儲存功能
(setq auto-save-slient t) ;; 自動儲存的時候靜悄悄的, 不要打擾我
換國内的源:
(setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/")
("melpa" . "http://elpa.emacs-china.org/melpa/")))
用list-packages 指令,出現如下錯誤
Failed to verify signature archive-contents.sig:
No public key for 066DAFCB81E42C40 created at 2019-10-02T10:10:02+0100 using RSA
Command output:
gpg: Signature made Wed 02 Oct 2019 10:10:02 AM BST
gpg: using RSA key C433554766D3DDC64221BFAA066DAFCB81E42C40
gpg: Can't check signature: No public key
說是沒有密鑰,需要從伺服器獲得.
其它方法沒實驗成功,下面方法可行.
gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40
gpg: 密鑰 066DAFCB81E42C40:公鑰“GNU ELPA Signing Agent (2019) <[email protected]>”已導入
gpg: 沒有找到任何絕對信任的密鑰
gpg: 合計被處理的數量:1
gpg: 已導入:1
确實下來了一些檔案,重新開機emacs, list-packages 檢查通過