如何在启动新的 emacsclient 框架后运行某些 elisp 代码?
如何自动评估某些 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的 emacsclient 版本不支持
-c
参数,尽管 宣传它的文档。我不确定是否有更干净的方法来执行此操作,但您可以尝试使用
make-frame
和select-frame
,如下所示:这将创建一个新框架,以防您的窗口管理器没有选择它自动授予它焦点,然后使用具有焦点的新框架执行第二个命令。
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
andselect-frame
, like so: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.
将您已经尝试过的两个命令行合并为一个怎么样:
这在 Emacs 23.1 中有效。
How about just combining the two command lines you've already tried into one:
That works in Emacs 23.1.