V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
henryshen233
V2EX  ›  程序员

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

  •  
  •   henryshen233 · Nov 26, 2018 · 1698 views
    This topic created in 2713 days ago, the information mentioned may be changed or developed.

    两个 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"
    
    Supplement 1  ·  Apr 26, 2021

    现在我的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
    
    Supplement 2  ·  Apr 26, 2021
    目的就是 Emacs Client.app 的窗口在双击打开时能够被 focus
    1 replies    2018-11-26 20:06:28 +08:00
    henryshen233
        1
    henryshen233  
    OP
       Nov 26, 2018
    新建 AppleScript 文件然后保存为.app 文件到 Applications 文件夹即可
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1077 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:50 · PVG 07:50 · LAX 16:50 · JFK 19:50
    ♥ Do have faith in what you're doing.