如何在启动新的 emacsclient 框架后运行某些 elisp 代码?

发布于 2024-08-16 18:59:25 字数 644 浏览 1 评论 0原文

如何自动评估某些 Lisp 代码每次启动 emacsclient,请单击此处。

我的问题有所不同。我想编写一个脚本来打开一个新的 emacs 框架(重点关注它)(一种方法是运行 emacsclient -c ),然后在该框架中运行以下 elisp 代码。

(org-remember)

我尝试过

emacsclient -c & emacsclient -eval '(org-remember)'

,但有时它只是打开一个未聚焦的新框架,然后运行 ​​elisp 代码,而其他时候,它会打开一个聚焦的新框架,但在旧框架中运行 elisp 代码。

一些知道 org-remember 做什么的人可能会问我为什么不这样做:

emacsclient -eval '(org-remember)'

但这并不能把注意力集中在旧框架上。

For how to automatically evaluate certain lisp code every time starting an emacsclient, click here.

My problem is different. I want to write a script that opens a new emacs frame (with focus on it) (one way to do this is to run emacsclient -c) and then run the following elisp code in that frame.

(org-remember)

I tried

emacsclient -c & emacsclient -eval '(org-remember)'

But sometimes it just opens a new frame unfocused and then runs the elisp code, and other times, it opens a new frame focused but runs the elisp code in the old frame.

Some who knows what org-remember does might ask me why not just do this:

emacsclient -eval '(org-remember)'

but that doesn't bring focus on the old frame.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半衬遮猫 2024-08-23 18:59:25

我的 emacsclient 版本不支持 -c 参数,尽管 宣传它的文档

我不确定是否有更干净的方法来执行此操作,但您可以尝试使用 make-frameselect-frame,如下所示:

emacsclient -e '(select-frame (make-frame))' '(org-remember)'

这将创建一个新框架,以防您的窗口管理器没有选择它自动授予它焦点,然后使用具有焦点的新框架执行第二个命令。

My version of emacsclient doesn't support the -c argument, despite the documentation advertising it.

I'm not sure if there's a cleaner way to do this, but you could try using make-frame and select-frame, like so:

emacsclient -e '(select-frame (make-frame))' '(org-remember)'

That will create a new frame and, in case your window manager doesn't select it automatically, grant it focus, and then execute the second command with that new frame having focus.

葮薆情 2024-08-23 18:59:25

将您已经尝试过的两个命令行合并为一个怎么样:

emacsclient -c -e '(org-remember)'

这在 Emacs 23.1 中有效。

How about just combining the two command lines you've already tried into one:

emacsclient -c -e '(org-remember)'

That works in Emacs 23.1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文