【问题标题】:Independent emacs installations and locations of the .emacs.d directory and the .emacs file.emacs.d 目录和 .emacs 文件的独立 emacs 安装和位置
【发布时间】:2012-11-24 06:18:56
【问题描述】:

我在我的 Windows 7 计算机上安装了多个 emacs,每个配置都略有不同。假设installation1installation2,其中installation1 是主要的emacs,installation2 是附属的。

我想维护两组.emacs 文件和.emacs.d. 目录,这样installation1 在默认的HOME%appdata% 目录中查找它(C-x C-f ~/.emacs RET),但是 installation2 在这些目录中根本找不到 .emacs 文件。也就是说,我希望installation2 不查看HOME%appdata% 位置的.emacs.d 目录或.emacs 文件。理想情况下,这将通过为 installation2 重新定义 ~ 扩展来实现。

我想我可以拥有一个(add-to-list 'load-path "C:/installation2-location/.emacs.d/lisp/") 并将其保存到与installation2 emacs 可执行文件位于同一目录中的.emacs 文件中,但我不确定这是一个可靠的解决方案。

欢迎提出建议。

【问题讨论】:

  • 这种完全分离真的有必要吗?您知道可以从命令行设置站点和用户初始化文件吗?并且您可以设置.emacs 文件以选择几种基本配置中的一种,具体取决于例如一个环境变量(我猜在 Windoze 上不太有用),一个命令行参数等。
  • @tripleee 您能否再细分一下——我认为我不完全理解您的建议。您是说我从命令行使用 > runemacs --init-file=.emacs-installation1 --init-directory=C:/installation1-location/.emacs.d 之类的东西启动 emacs(我不确定这些开关是否存在——emacs --help 没有显示这样的选项,但可能存在类似的东西)?我完全不确定您对环境的建议是什么意思,但正如您所提到的,这可能是因为我使用的是 Windows(最好的操作系统,顺便说一句)。 ;)
  • Windows 有像%home% 这样的环境变量,但它们的行为不像在类 Unix 系统上那样,因此使用一些本机机制可能会更好——想到注册表,但它是全局的AFAICT,我不知道从 Elisp 访问它的难易程度。
  • 如果你有一个单独的用户,那么emacs -u him 运行他的 Emacs 配置文件而不是你的。您可能更喜欢 emacs -q -l a:\files\config.el 甚至 emacs -Q 作为“白名单”。进一步查看linux.die.net/man/1/emacs
  • 我不确定你为什么想要两个不同的配置,为什么你有两个不同的安装,为什么你特别想在一个安装中使用一个配置,在另一个安装中使用另一个配置。你能提供一些细节吗?根据您的具体需求,解决方案可能简洁明了,也可能相当复杂且不可靠。

标签: emacs dot-emacs


【解决方案1】:

你可以使用系统类型变量。来自 Emacs 帮助

system-type 是在“C 源代码”中定义的变量。它的值为 达尔文

Documentation:该值是表示操作类型的符号 您正在使用的系统。特殊值:gnu' compiled for a GNU Hurd system.gnu/linux' 为 GNU/Linux 系统编译。
gnu/kfreebsd' compiled for a GNU system with a FreeBSD kernel. darwin' 为 Darwin(GNU-Darwin、Mac OS X 等)编译。
ms-dos' compiled as an MS-DOS application.windows -nt'
编译为本机 W32 应用程序。 `cygwin' 编译使用 Cygwin 库。其他任何东西(在 Emacs 24.1 中,可能性 是:aix, berkeley-unix, hpux, irix, usg-unix-v) 表示某种 Unix系统的。

或者使用system-name来判断是否区分相同的机器。

最后,您可以创建一个函数来在安装 1 中加载您想要的内容,另一个在安装 2 中加载您想要的内容。但我看不出有任何正当理由说明您为什么要在同一台机器上维护不同的 emacs.d。

【讨论】:

    猜你喜欢
    • 2012-04-24
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多