如何启动不同配置的emacs [英] How to start up emacs with different configurations

查看:23
本文介绍了如何启动不同配置的emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常遇到以下流行的 emacs 构建:

I often come across the following popular emacs builds:

目前我正在运行自定义配置,但我想在不破坏我当前的~/.emacs.d 的情况下试验这些构建.

Currently I'm running a custom configuration, but I'd like to experiment with these builds without clobbering my current ~/.emacs.d.

以下是我当前安装的一些背景:

Here's some background on my current installation:

我通过 Homebrew 安装了 Emacs,所以它位于:/usr/local/Cellar/emacs/HEAD/Emacs.app我当前的 emacs 版本是:GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)

I installed Emacs via Homebrew, so it's located here: /usr/local/Cellar/emacs/HEAD/Emacs.app My current version of emacs is: GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)

基本上,以下是我想知道的:

Basically, here's what I'd like to know:

  1. 在这些版本和我当前的自定义配置之间切换的最简单方法是什么?

  1. What's the easiest way to switch between these builds as well as my current custom configuration?

鉴于我当前的设置,是否可以启动多个 emacs 会话,每个会话都有各自的配置/缓冲区?

Given my current setup, is it possible to start multiple emacs sessions, each with their respective configuration/buffers?

推荐答案

(我已经将这种方法包装到一个 shell 脚本中,并添加到 EmacsWiki.)

( I've wrapped this approach up into a shell script which I've added to the EmacsWiki.)

我倾向于使用 $HOME 环境变量:

I'd be inclined to use the $HOME environment variable:

  1. 首先将发行版"(为了更好的术语)复制到一个目录的子目录 .emacs.d 中,该目录将用作替换 $HOME 用于该发行版.即 /path/to/(distribution)/.emacs.d:

  1. Firstly copy the 'distribution' (for want of a better term) into a sub-directory .emacs.d of a directory which will serve as the replacement $HOME for that distribution. i.e. /path/to/(distribution)/.emacs.d:

$ git clone https://github.com/bbatsov/prelude.git ~/emacs/prelude/.emacs.d
$ git clone https://github.com/overtone/emacs-live.git ~/emacs/emacs-live/.emacs.d

  • 然后您可以使用 env 启动 emacs,为该命令在本地设置 HOME 环境变量:

  • Then you can start emacs using env to set the HOME environment variable locally for that command:

    $ env HOME=$HOME/emacs/prelude emacs
    $ env HOME=$HOME/emacs/emacs-live emacs
    

  • 它们不应相互交互,因此您可以将它们一起运行并拥有多个并排的 emacs 实例,每个实例使用不同的配置.

    They shouldn't interact with each other, so you can run them together and have multiple side-by-side emacs instances, each using a different configuration.

    我看到graphene其实是一个ELPA包,所以没有init.el文件,需要通过包管理器安装;但是您仍然可以使用相同的技术将其安装在单独的干净配置中:只需创建与其他目录结构相似的目录结构,然后创建一个 init.el 文件(例如 ~/emacs/graphene/.emacs.d/init.el) 包含石墨烯安装说明中的代码,然后运行 ​​emacs(例如 env HOME=$HOME/emacs/graphene emacs),并完成安装说明的其余部分.

    I see that graphene is actually an ELPA package, so it has no init.el file and needs to be installed via the package manager; but you can still use the same technique to install it in a separate clean configuration: Simply make a similar directory structure to the others, then create an init.el file (e.g. ~/emacs/graphene/.emacs.d/init.el) containing the code from the graphene installation instructions, then run emacs (e.g. env HOME=$HOME/emacs/graphene emacs), and finish the remainder of the installation instructions.

    这种技术的缺点是 Emacs 不会看到您所有的其他点文件(因为它将在 $HOME 中查找),因此从 Emacs 中运行其他进程将不会'不一定正常工作;但是,如果您只是进行试验,这不太可能成为一个大问题,而且您始终可以符号链接或复制您需要的位.

    The down-side to this technique is that Emacs won't see all your other dot files (because it will be looking in $HOME), and so running other processes from within Emacs won't necessarily work as normal; but that's not likely to be a huge issue if you're just experimenting, and you can always symlink or copy the bits you need.

    您甚至可能更喜欢这种方式——好处是,如果您正在试用的发行版中的任何内容将文件写入主目录,它就不会破坏您的真实文件.

    You may even prefer it that way -- the benefit is that if anything in the distribution you're trialing writes files to the home directory, it's not going to clobber your real files.

    这在将 Emacs 升级到新版本时也可能是一种有用的方法(如果您可以同时运行旧版本和新版本),因为您可以设置现有配置的副本以与新 Emacs 一起使用直到您确信一切正常,并且您可以编辑新配置而不会破坏现有配置.或者翻转它,而是将 原始 配置保留在新/备用位置,以防您需要它作为备份.

    This may also be a useful approach when upgrading Emacs to a new release (if you can run both the old and the new versions side by side) as you could set up a copy of your existing config to use with the new Emacs until you're convinced everything is working, and you can edit the new config without the risk of breaking your existing one. Or flip that around, and instead keep the original config in the new/alternate location, in case you need it as a back-up.

    这篇关于如何启动不同配置的emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆