Win10下Emacs編輯器安裝

目錄

安裝包準備

安裝步驟

準備目錄

解壓文件

安裝插件

出現錯誤

解決方案

成功安裝


Emacs中的對齊方式多樣,對於我這種強迫症患者,代碼需要對齊才能好看的人,急需要一種強大的編輯器,用過很多編輯器最後發現還是Emacs比較方便。

安裝包準備

安裝步驟

準備目錄

在D盤中新建文件夾Emacs_26.3,在文件夾Emacs_26.3中新建.emacs.d文件夾,爲存放配置文件準備;

新建用戶變量HOME,路徑設置爲剛纔新建的文件夾:D:\Emacs_26.3

 

解壓文件

  • 解壓Emacs的安裝包到D:\Emacs_26.3目錄下

  • 解壓spacemacs-master壓縮包到.emacs.d文件夾下

安裝插件

運行runemacs.exe,會自動安裝常用插件,需要運行兩次runemacs.exe,第一次運行會在安裝目錄下生成.spacemacs文件,運行後如果生成此文件立馬關閉;然後修改.spacemacs中文源,爲了安裝插件更快。

在.spacemacs文件函數defun dotspacemacs/user-init ()裏添加清華的源,進行第二次運行runemacs.exe。

(defun dotspacemacs/user-init ()
  "Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
 This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
(setq-default
configuration-layer--elpa-archives
'(("melpa-cn" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
("gnu-cn" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("org-cn" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/org/"))) 
  )

出現錯誤

  •  is not a safe directory because it is not owned by you (owner = nil (544))
Warning (initialization): An error occurred while loading ‘d:/Emacs_26.3/.emacs.d/init.el’:

error: ‘d:/Emacs_26.3/.emacs.d/server’ is not a safe directory because it is not owned by you (owner = nil (544))

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
  • warning:spacemacs默認字體”Source Code Pro”不存在
  • emacs 打開有中文內容的文件會卡的解決方案

解決方案

  • 由於server文件夾是另一個用戶創建的,所以我們沒有權限去修改,因此在這裏的解決方案就是刪除重建,這樣就不會出現上述錯誤。
  • 修改~/.spacsmacs文件, 需要把默認字體"Source Code Pro"替換掉
dotspacemacs-default-font '("Consolas"                               
:size      22                               
:weight normal                               
:width normal                               
:powerline-scale 1.1)
  • 在.spacemacs中添加     '(cua-mode t nil (cua-base))
;; Setting English Font
(set-face-attribute
‘default nil :font “Courier New-14”)
;; Setting Chinese Font
(dolist (charset ‘(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil ‘font)
charset
(font-spec :family “Microsoft Yahei” :size 16)))

成功安裝

基礎的功能基本上就可以使用了,欣賞以下完整的代碼提示,至此Emacs安裝成功,更多的插件使用方法後續。

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章