Skip to content

Instantly share code, notes, and snippets.

@lawlist lawlist/example.el
Last active Jun 29, 2019

Embed
What would you like to do?
Call qlmanage and return focus to Emacs.
(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
You can’t perform that action at this time.