emacs - 如何在 emacs 27 中为外部命令设置别名
问题描述
我试图让 Emacs 27 为 javascript + flow 工作。有很多步骤/包/配置可以让它工作。
我目前坚持的一个特定步骤。
我无法全局安装 npm 包(因为我们的 monorepo 为 repo 中的不同应用程序使用不同版本的 node_module 包)。所以我们不能用 npm -g 安装 flow、typescript 和其他东西,而是需要将 emacs 指向 ./node_modules/.bin/flow (例如)。
这是我在启动 emacs 时收到的具体错误消息
Command "javascript-typescript-stdio" is not present on the path.
Command "typescript-language-server --stdio" is not present on the path.
Command "flow lsp" is not present on the path.
所以,如果可能的话,我想在我的 .emacs javacript-typescript-stdio typescript-language-server 流中定义
这样他们将指向 /node_modules/.bin/ 哪里是我启动 emacs 的目录
当搜索这个主题时,大多数查询都返回了一些关于别名内部 emacs 函数的内容,但这不是我想要的。
我的 .emacs 部分与此相关:
;; lsp-javascript specific start
;; https://github.com/emacs-lsp/lsp-mode/issues/489
(use-package js2-mode
:mode "\\.js\\'"
:init
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
(setf js2-mode-indent-inhibit-undo t)
:config
(with-eval-after-load "lsp-javascript-typescript"
(add-hook 'js2-mode-hook #'lsp)))
;; for flow start
(add-hook 'js2-mode-hook 'flow-minor-enable-automatically)
;; for flow end
;; JSON
(use-package json-mode
:defer t)
解决方案
exec-path
保存位置以搜索可执行文件,因此在那里添加一个条目应该可以工作,
(add-to-list 'exec-path "./node_modules/.bin")
在这种情况下,路径是相对于default-directory
,见。
推荐阅读
- c# - iTextSharp 相对链接中的 Unicode 符号
- django - Django中预保存、保存后、预删除、删除后信号的典型用例是什么?
- amazon-cloudwatchlogs - 适用于 AND 的 AWS CloudWatch Logs 过滤器表达式
- iis - 升级到 TFS 2017 HTTP 错误 401.1 - 未经授权
- winforms - Powershell - 将富文本数据显示为格式化文本而不加载外部文件 - WinForms 或 XAML
- excel - 在 A 列中选择包含内容的单元格?
- node.js - 在 Mongoose 模式中禁用插件
- docker - Jenkins Golang 声明式管道:构建 Docker 映像并推送到 Docker Hub
- python - localhost上的Python计算器 - 获取结果时出现意外结果
- regex - 正则表达式:在双引号之间查找分号