V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
henryshen233
V2EX  ›  程序员

Emacs 服务器模式,分享用 AppleScript 启动 emacsclient 的配置 ,能够永远点击前置窗口的

  •  
  •   henryshen233 · 2018-11-26 20:05:47 +08:00 · 1342 次点击
    这是一个创建于 1948 天前的主题,其中的信息可能已经有所发展或是发生改变。

    两个 AppleScript 文件,弄了好久一直是一开始几次窗口能够自动前置,可是后来却不会前置了,终于弄好分享下 一个是 Emacs Client.app 的:

    try
    	set frameVisible to do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'"
    	if frameVisible is not "t" then
    		do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
    		do shell script "open -a Emacs"
    	end if
    end try
    

    还有 Emacs Daemon 的:

    do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon"
    
    第 1 条附言  ·  2021-04-26 16:14:20 +08:00

    现在我的Emacs Client.app是这样的,用系统自带的“脚本编辑器”编辑。

    try
    	do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -e \"(select-frame-set-input-focus (selected-frame))\""
    on error
    	do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon"
    	do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c"
    end try
    
    第 2 条附言  ·  2021-04-26 16:15:47 +08:00
    目的就是 Emacs Client.app 的窗口在双击打开时能够被 focus
    1 条回复    2018-11-26 20:06:28 +08:00
    henryshen233
        1
    henryshen233  
    OP
       2018-11-26 20:06:28 +08:00
    新建 AppleScript 文件然后保存为.app 文件到 Applications 文件夹即可
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3218 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:39 · PVG 19:39 · LAX 04:39 · JFK 07:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.