在 term 里启动 emacs 怎么以 GUI 方式启动?

我记得以前要 emacs -nw 才能在 term 里直接运行,否则会以 GUI 方式启动,现在用 emacs-mac,居然 emacs 不起 GUI 了,搞的我想 emacs --with-profile centaur 试验下看不到 GUI 效果。。。

Emacs 27.1, 用这个装的:GitHub - railwaycat/homebrew-emacsmacport: Emacs mac port formulae for the Homebrew package manager

open -a Emacs --args --with-profile centaur 可以起 GUI,奇怪既然默认 -nw 了,还要 -nw 选项干嘛?

我并没有同时在 term 和 gui 用,我把 emacs 全退出了,然后在 term 里输入 emacs,它的效果跟 emacs -nw 一样。

也许是 emacs-mac 这个移植版独有的问题?它做了「智能」判断,如果从 term 启动就总是 term 模式,如果从 finder 或者 spotlight 启动就总是 gui 模式?

不是,我记得那几个参数在emacs mac上因为这个原因就是坏的,不过具体不记得了

好像现在 brew 安装时有个选项了:

--with-starter
	Build with a starter script to start emacs GUI from CLI

就是增加了个脚本,命令就是我上面那条命令🤣

刚重新编译试了下,我这没有问题。 brew install emacs-mac --with-starter 命令行中执行 emacs 启动的是 GUI

❯ cat /usr/local/bin/emacs
#!/bin/bash
exec /usr/local/Cellar/emacs-mac/emacs-27.1-mac-8.1/Emacs.app/Contents/MacOS/Emacs.sh "$@"
1 个赞

所以term键入emacs 怎么启动gui?

安装的时候都 with-starter 了当然是默认就是 GUI。 emacs -nw 才是启动 TUI 即使你使用了 chemacs2 也只需要 emacs --with-profile doom --nw 就能用 TUI 启动特定的配置。

我测试了一下,直接用

brew install --cask emacs

安装,然后在命令行下用 emacs 就能直接启动 GUI 版的 emacs (即 /Applications/Emacs.app),而用 emacs -nw 就能启动 terminal 内文字版的 emacs。这样就不用当前解决方案里面那个特殊的叫 emacs-mac 的变种。