简体   繁体   English

使用Cask和Emacs.app

[英]Using Cask with Emacs.app

Cask uses the built-in emacs on OSX which does not support the --script argument which Cask requires. Cask在OSX上使用内置的emacs,它不支持Cask所需的--script参数。 Is there some way to tell Cask to use the Emacs.app version? 有没有办法告诉Cask使用Emacs.app版本?

I tried the solutions here: How to start "emacsformacosx" in terminal but they did not help. 我在这里尝试了解决方案: 如何在终端启动“emacsformacosx”,但他们没有帮助。

I finally just entered the command supplied at the bottom of the cask file: 我终于刚刚输入了cask文件底部提供的命令:

/Applications/Emacs.app/Contents/MacOS/Emacs -Q --script ~/.cask/cask-cli.el

This is not very elegant. 这不是很优雅。

You can tell cask which Emacs executable to run, by exporting the environment variable $EMACS : 您可以通过导出环境变量$EMACS告诉cask运行Emacs可执行文件:

$ export EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs
$ cask install

To avoid the repetitive process of setting this variable any time you want to use cask , you need to create a command line wrapper for Emacs.app. 为了避免设置此变量,您要使用的任何时间的反复过程cask ,你需要创建Emacs.app一个命令行包装。 It must be a proper executable on its own, and not merely a shell alias or function such as recommended at How to start "emacsformacosx" in terminal , because neither aliases nor shell functions are available for subprocesses of a shell. 它本身必须是一个正确的可执行文件,而不仅仅是一个shell别名或函数,如在终端如何启动“emacsformacosx”所推荐的那样 ,因为shell的子进程既没有别名也没有shell函数。

This is easily done by creating a file /usr/local/bin/emacs , with the following contents 这可以通过创建文件/usr/local/bin/emacs轻松完成,其中包含以下内容

#!/bin/bash
exec /Applications/Emacs.app/Contents/MacOS/Emacs -nw "$@"

You will need root privileges to create this file, and you must mark it as executable afterwards: 您将需要root权限才能创建此文件,之后必须将其标记为可执行文件:

$ sudo chmod a+x /usr/local/bin/emacs

After this, you should be able to start Emacs.app from command line with emacs . 在此之后,您应该能够从emacs命令行启动Emacs.app。 This is sufficient for Cask to pick up Emacs.app without setting $EMACS . 这足以让Cask在不设置$EMACS情况下获取Emacs.app。

Alternatively, you may want to install Emacs with Homebrew, by 或者,您可能希望使用Homebrew安装Emacs

$ brew install emacs --cocoa --srgb --with-gnutls
$ brew linkapps

This automatically creates the command line wrapper, and has some other advantages, such as building with some additional libraries. 这会自动创建命令行包装器,并具有一些其他优点,例如使用一些其他库构建。

I strongly recommend the Homebrew approach. 我强烈推荐使用Homebrew方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM