从 Emacs 激活 Alfred 并填入当前选中文字

受 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

alfred-search

有一个插件 counsel-osx-app 可以在emacs中选择打开外部应用程序。还有一个插件spolight可以模拟osx的spolight。

1 个赞