受 PopClip 的 Aflred 插件 启发,写了个可以从 Emacs 激活 Alfred 的命令,并填入当前选中文字:
(defun alfred-search (b e)
"Activate Alfred with the selected text."
(interactive "r")
(do-applescript
(format "tell application \"Alfred 4\" to search \"%s\""
;; In AppleScript String, " and \ are speical characters
(mapconcat
(lambda (char)
(pcase char
(?\" (string ?\\ ?\"))
(?\\ (string ?\\ ?\\))
(_ (string char))))
(buffer-substring b e) ""))))
上面代码写死了 Alfred 4,如果你用 Alfred 3 的话,估计应该写 Alfred
。