emacs_chrome
emacs_chrome copied to clipboard
edit-server-start-hook runs when edit-server-done returns
The following code:
(defun bw-switch-to-emacs ()
"Switches to Emacs"
(interactive)
(do-applescript "set appName to \"Emacs\"
set needsActivation to false
tell application \"System Events\"
if frontmost of process appName then
set visible of process appName to false
else
set needsActivation to true
end if
end tell
if needsActivation then
tell application appName to activate
end if"))
(defun bw-switch-to-chrome ()
"Switches to Chrome"
(interactive)
(do-applescript "set appName to \"Google Chrome\"
set needsActivation to false
tell application \"System Events\"
if frontmost of process appName then
set visible of process appName to false
else
set needsActivation to true
end if
end tell
if needsActivation then
tell application appName to activate
end if"))
(edit-server-start)
(setq edit-server-url-major-mode-alist
'(("github\\.com" . markdown-mode)))
(add-hook 'edit-server-start-hook 'bw-switch-to-emacs)
(add-hook 'edit-server-done-hook 'bw-switch-to-chrome)
when I run C-c C-c
, flips to Chrome them back to Emacs.
Shouldn't start-hook
only run when I invoke it (via option-Enter
or similar)?
Are you sure your not interfering with the usual window promotion rules? For example I don't need any hooks to bring the edit window into focus on Linux. As far as I can see in the code edit-server-start-hook is only called the once when a new buffer is created for editing.
I see something similar when I have (setq edit-server-new-frame nil)
. It kills the buffer but not the window (which is a separate issue), then it passes the text to chrome, but then emacs becomes my active window again. I don't have anything in my edit-server-start-hook
that messes with the windows system. (I am on Windows 7).