Last active
June 29, 2019 19:14
-
-
Save lawlist/9be45ebf53a1458cb4e7d2d6ff5bae38 to your computer and use it in GitHub Desktop.
Call qlmanage and return focus to Emacs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'dired) | |
(defun qlmanage-return-focus-to-emacs () | |
"Doc-string." | |
(let* ((filename (dired-get-file-for-visit)) | |
(emacs-executable (concat invocation-directory "Emacs")) | |
(emacs-script (concat "tell application \"" emacs-executable "\" to activate"))) | |
(set-process-sentinel | |
(start-process "qlmanage" nil "/usr/bin/qlmanage" "-p" filename) | |
`(lambda (p e) (when (= 0 (process-exit-status p)) | |
(set-process-sentinel | |
(start-process "emacs" nil "osascript" "-e" ,emacs-script) | |
'(lambda (p e) (when (= 0 (process-exit-status p)) | |
(message "Congratulations: %s" ,filename))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment