天天看点

Spacemacs使用一、个性化设置二、辅助功能设置三、语言环境设置四、错误解决

文中所有引用的IP均归其原作者所有,本文仅供参考。

本文记录笔者自己在使用Emacs中学习到一些比较有用的知识和技巧,供自己以后参考,同时也方便后来人。

文章目录

  • 一、个性化设置
    • 1. 修改鼠标样式
    • 2. SPC键的设置
    • 3. 背景主题的设置
    • 4. 自动全屏设置
    • 5. Vim 快捷键设置
  • 二、辅助功能设置
    • 1. Spacemacs 换源
    • 2. Emacs(spacemacs)+SumatraPDF逆向搜索设置(Emacsclient ERROR)
      • (1)Spacemacs 中安装 latex
      • (2)SumatraPDF 中设置逆向搜索
    • 3. Windows 下 flycheck 设置
  • 三、语言环境设置
    • 1. C语言环境配置
    • 2. Python语言环境配置
  • 四、错误解决
    • 1. MAC OS:AUCTeX cannot find a working Tex distribution
    • 2. Emacs 中 XXX locked by [email protected]

以下是正文内容

一、个性化设置

1. 修改鼠标样式

参考链接

  1. 在 .spacemacs 文件中的

    defun dotspacemacs/user-config ()

    中加入如下命令:

2. SPC键的设置

  • 可修改在 .spacemacs 中的 defun dotspacemacs/init () 函数下的 dotspacemacs-emacs-leader-key "M-m"

3. 背景主题的设置

  • 可修改在 .spacemacs 中的 defun dotspacemacs/init () 函数下的 dotspacemacs-themes 中按照如下设置
dotspacemacs-themes '(solarized-dark
                          solarized-light
                          solarized
                          )
           

另外,为避免 Spacemacs 每次加载时把主题包删掉,再下载这种令人窒息的操作,可以在 .spacemacs 下的 (defun dotspacemacs/layers ( ) 层中的 dotspacemacs-additional-packages '( ) 进行如下配置

4. 自动全屏设置

  • 在 .spacemacs 下的 (defun dotspacemacs/init ()) 层中将

改为

5. Vim 快捷键设置

  • 在 .spacemacs 下的 (defun dotspacemacs/user-config ()) 层中加入以下代码
(setq-default evil-escape-key-sequence "jk")
	(setq-default evil-escape-delay 0.2)
           

重要参考:

  1. 从 vim 迁移到 spacemacs
  2. evil-escape

二、辅助功能设置

1. Spacemacs 换源

主要在

dotspacemacs/user-init ()

中添加

(setq configuration-layer--elpa-archives
	    '(("melpa-cn" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
	      ("org-cn"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/org/")
	      ("gnu-cn"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")))
           

2. Emacs(spacemacs)+SumatraPDF逆向搜索设置(Emacsclient ERROR)

(1)Spacemacs 中安装 latex

  1. C-x C-f

    输入

    ~/.spacemacs

    后回车
  2. dotspacemacs-configuration-layer

    中输入

    latex

  3. C-x C-s

    关闭 spacemacs
  4. 重新打开spacemacs,此时其会自动下载一些包,下载完成之后自动安装,安装完成就可以使用latex了

(2)SumatraPDF 中设置逆向搜索

  1. 安装SumatraPDF
  2. 打开SumatraPDF,进入settings→options→set inverse search command-line
  3. 输入"C:\Program Files\Emacs\x86_64\bin\emacsclient.exe" -n +%l “%f”
  4. 红色部位根据自己Emacs安装位置进行调整
  5. 最重要的部分: 打开spacemacs,

    M-x

    ,输入:

    server-start

    回车。

    完成以上的部分基本就可以使用了。

注意 : 如果没有第五步,就会出现 Emacsclient ERROR。

并且根据笔者测试,每次完全关掉 spacemacs 后,就要 重新 打开该服务。

3. Windows 下 flycheck 设置

参考链接

用msys2安装aspell

  1. In MingW64 terminal search aspell:
  1. Installing aspell and dictionary you need :
pacman -S mingw64/mingw-w64-x86_64-aspell
    pacman -S mingw64/mingw-w64-x86_64-aspell-en
           
  1. Find aspell.exe location with

    which aspell

    , e.g.

    C:\msys64\mingw64\bin

  2. Update in dotfile. Especially in Spacemacs:
(add-to-list 'exec-path "C:/msys64/mingw64/bin/")
    (setq ispell-program-name "aspell")
    (setq ispell-personal-dictionary "c:/msys64/mingw64/lib/aspell-0.60/en_GB")
           
Spacemacs使用一、个性化设置二、辅助功能设置三、语言环境设置四、错误解决

三、语言环境设置

1. C语言环境配置

准备工作:

安装GCC

  1. Windows下配置Emacs + gcc编写编译C程序的简单方法
  2. window下 ‘g++’ 不是内部或外部命令

正式配置:

  1. 在 .spacemacs 配置文件中的 dotspacemacs-configuration-layers 中加入 c-c++ 配置。
  2. 重启Emacs。
  3. C-x C-f

    新建C语言文件 hello.c,写入测试代码。
#include <stdio.h>
 
int main(void)
{
	printf("This is a program test!\n");
 
	return 0;
}
           
  1. 按下C-x C-s保存文件。
  2. 编译程序。通过命令

    M-x eshell

    进行shell模式,然后使用

    gcc -Wall -o hello hello.c

    进行编译。
  3. 运行:

    ./hello.exe

    即可运行编译好的可执行程序.
  4. 切换回编辑区:

    c-x b 'buffername'

    可以切换到某个buffer,如要切换回刚才那个hello.c编辑区,输入

    c-x b hello.c

2. Python语言环境配置

  1. 在 .spacemacs 配置文件中的 dotspacemacs-configuration-layers 中加入 python 支持。
  2. 重启Emacs。
  3. C-x C-f 新建C语言文件 hello.py,写入测试代码。

    print(“hello world!!!”)

  4. 按下C-x C-s保存文件。
  5. 依次按

    M-m c C

    (或

    M-x compile

    )再输入文件名编译程序。

四、错误解决

1. MAC OS:AUCTeX cannot find a working Tex distribution

  1. SPC j d (或C-x C-f )打开

    .spacemacs.d

    (或者是

    .emacs.d

    根据自己配置决定)下的

    .spacemacs.env

  2. 在 path 中加入 MACTeX 路径

参考链接

其他参考

2. Emacs 中 XXX locked by [email protected]

在 dotspacemacs/user-init () 中添加

(setq make-backup-files nil)
(setq create-lockfiles nil)