emacs--base

1 使用环境

Windows10 + emacs 26.3

2 修改配置

表示修改配置文件 .emacs

2.1 修改配置,取消菜单栏、工具栏、滚动条

(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)

2.2 禁止导出 HTML 时 '-' 转成下标

(setq org-export-with-sub-superscripts nil)

2.3 设置文件编码 utf8

;;设置默认读入文件编码
(prefer-coding-system 'utf-8)
;;设置写入文件编码
(setq default-buffer-file-coding-system 'utf-8)

2.4 显示行号

;;显示行号
(global-linum-mode t)

2.5 开启执行开关

;;可以执行的语言开关是指
(setq org-confirm-babel-evaluate nil)
(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (C . t)
   (js . t)
   (css . t)
   (org . t)
   (latex . t)
   (lisp . t)
   (haskell . t)
   (python . t)
   (shell . t)))

2.6 修改配置,添加源

方便安装包

(setq package-archives '(("gnu"  . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
                         ("melpa stable"  . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa-stable/")
                         ("emacswiki" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/emacswiki/")
                         ("org" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/org/")
                         ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(package-initialize) ;; You might already have this line

3 安装包

安装命令 M-x package-install company

3.1 导出 HTML

htmlize

3.2 补全输入(提示)

安装 company 后修改配置,使用全局补全

;;全局补全
(add-hook 'after-init-hook 'global-company-mode)

3.3 编辑 haskell, 使用 ghci

haskell-mode

3.4 使用主题(需要下载)

使用的书写形式太多了,具体配置需搜索

;;(require 'darcula-theme)
;;(load-theme 'solarized-dark t)
;;(load-theme 'solarized-light t)
;;(load-theme 'molokai t)
;;(load-theme 'solarized t)
(load-theme 'base16-default-dark t)

3.5 中英文对齐(主要适配 org mode 中的 table)

cnfonts

  1. M-x cnfonts-edit-profile 进入GUI设置界面
  2. 分别选择英文、中文字体(中文字体需要等宽字体)
  3. 在字号菜单下调整字体大小,时上面的右边竖线对齐,点击完成(一般减少中文字号即可对齐)
  4. 在其他菜单下生成配置代码,拷贝代码添加到 emacs 配置中
;;中英文字体对齐
;; Auto generated by cnfonts
;; <https://github.com/tumashu/cnfonts>
(set-face-attribute
 'default nil
 :font (font-spec :name "-outline-Consolas-bold-italic-normal-mono-*-*-*-*-c-*-iso10646-1"
                  :weight 'normal
                  :slant 'normal
                  :size 12.5))
(dolist (charset '(kana han symbol cjk-misc bopomofo))
  (set-fontset-font
   (frame-parameter nil 'font)
   charset
   (font-spec :name "-outline-文泉驿等宽微米黑-normal-normal-normal-sans-*-*-*-*-p-*-iso10646-1"
              :weight 'normal
              :slant 'normal
              :size 13.5)))

4 导出 pdf (含有中文)

 

4.1 使用中文包

在编辑的 org 文件起始位置添加说明

#+LATEX_HEADER: usepackage{ctex}

4.2 修改 emacs 配置

(setq org-latex-pdf-process '("xelatex -interaction nonstopmode %f"
                              "xelatex -interaction nonstopmode %f"))

4.3 安装导出软件 texlive

网上搜索很多地方有下载

5 使用 slime (common lisp)

  1. 安装 slime
  2. sbcl 官网 下载安装(安装路径不能有空格)
  3. 修改配置
;;需要添加 sbcl 程序来运行,安装路径不能有空格
;;(setq inferior-lisp-program "/opt/sbcl/bin/sbcl")
(setq inferior-lisp-program "C:/sbcl/sbcl.exe")
(setq slime-contribs '(slime-fancy))

6 emacs 配置源文件

正常使用时的配置,根据对应的安装包进行安装

(require 'package)
(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.
 '(package-archives
   (quote
    (("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/"))))
 '(package-selected-packages
   (quote
    (slime slimee company htmlize base16-theme cnfonts haskell-mode))))
(package-initialize)
(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.
 )

;;全局补全
(add-hook 'after-init-hook 'global-company-mode)
;;显示行号
(global-linum-mode t)

;;html导出时禁‘-’禁止转成下标
(setq org-export-with-sub-superscripts nil)

;;设置默认读入文件编码
(prefer-coding-system 'utf-8)
;;设置写入文件编码
(setq default-buffer-file-coding-system 'utf-8)

;;可以执行的语言开关是指
(setq org-confirm-babel-evaluate nil)
(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (C . t)
   (js . t)
   (css . t)
   (org . t)
   (latex . t)
   (lisp . t)
   (haskell . t)
   (python . t)
   (shell . t)))


;;中英文字体对齐
;; Auto generated by cnfonts
;; <https://github.com/tumashu/cnfonts>
(set-face-attribute
 'default nil
 :font (font-spec :name "-outline-Consolas-bold-italic-normal-mono-*-*-*-*-c-*-iso10646-1"
                  :weight 'normal
                  :slant 'normal
                  :size 12.5))
(dolist (charset '(kana han symbol cjk-misc bopomofo))
  (set-fontset-font
   (frame-parameter nil 'font)
   charset
   (font-spec :name "-outline-文泉驿等宽微米黑-normal-normal-normal-sans-*-*-*-*-p-*-iso10646-1"
              :weight 'normal
              :slant 'normal
              :size 13.5)))

;;关闭工具栏、菜单栏、滚动条
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)

(load-theme 'base16-default-dark t)

;;需要添加 sbcl 程序来运行,安装路径不能有空格
;;(setq inferior-lisp-program "/opt/sbcl/bin/sbcl")
(setq inferior-lisp-program "C:/sbcl/sbcl.exe")
(setq slime-contribs '(slime-fancy))

Created: 2019-12-22 周日 09:45

Validate

原文地址:https://www.cnblogs.com/heidekeyi/p/12067191.html