Skip to content

Instantly share code, notes, and snippets.

@valpackett
Created November 7, 2010 15:59
Show Gist options
  • Save valpackett/666202 to your computer and use it in GitHub Desktop.
Save valpackett/666202 to your computer and use it in GitHub Desktop.
Refreshing Safari from Emacs
;;; Refreshing Safari on save, Mac only
;; Don't forget to enable assistive devices access
;; in System Preferences -> Universal Access
(if (featurep 'aquamacs)
(add-hook 'after-save-hook
'(lambda ()
(when (string-match "\.html$" (buffer-name))
(do-applescript (concat "tell application \"Safari\"
if \"file://" buffer-file-name "\" = URL of document 1 then
activate
tell application \"System Events\"
tell process \"Safari\"
keystroke \"r\" using {command down}
end tell
end tell
end if
end tell"))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment