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

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

问题描述

我经常遇到以下流行的emacs版本:





目前我正在运行自定义配置,但是我想尝试这些构建,而不会影响我目前的〜/。 emacs.d



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



I通过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)



基本上,这是我想知道的:


  1. 在这些b之间切换最简单的方法是什么uid以及我当前的自定义配置?


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



解决方案

编辑:我把这个方法包装成一个我已经添加到 EmacsWiki 的shell脚本。 )



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


  1. 首先将发行版(为了更好的术语)复制到子目录 .emacs.d ,该目录将作为该分发的替换 $ HOME 。即 / 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


  2. 然后你可以启动emacs env 为该命令本地设置 HOME 环境变量:

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


他们不应该互相交流,所以你可以一起运行,有多方我们看到,石墨烯实际上是一个ELPA包,所以它没有,而是使用另一个emacs实例,每个都使用不同的配置。



init.el 文件,需要通过包管理器进行安装;但您仍然可以使用相同的技术将其安装在单独的干净配置中:只需对其他目录结构进行相似的目录结构,然后创建一个init.el文件(例如〜/ emacs / graphene / .emacs包含来自石墨烯安装说明的代码,然后运行emacs(例如 env HOME = $ HOME / emacs / graphene emacs ),并完成其余的安装说明。



这种技术的一面是Emacs不会看到你所有的其他点文件(因为它会在 $ HOME 中查找),因此在Emacs内运行其他进程不一定正常工作;但是如果您只是在尝试,那么这不太可能是一个巨大的问题,而且您可以随时符号链接或复制所需的位。



您甚至可以喜欢这样 - 好处是,如果您正在试用的发行版中的任何内容将文件写入主目录,则不会破坏您的真实文件。



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


I often come across the following popular emacs builds:

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:

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. What's the easiest way to switch between these builds as well as my current custom configuration?

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

解决方案

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

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

  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
    

  2. 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
    

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.

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.

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.

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天全站免登陆