 
 (defun spacehammer/cancel-edit-with-emacs ()
   (interactive)
+  (run-hook-with-args
+   'spacehammer/before-cancel-edit-with-emacs-hook
+   (buffer-name (current-buffer))
+   systemwide-edit-previous-app-pid)
+
   (kill-buffer)
   (delete-frame)
   (spacehammer/switch-to-app systemwide-edit-previous-app-pid)


(defun spacehammer/finish-edit-with-emacs ()
  (interactive)
  (clipboard-kill-ring-save (point-min) (point-max))
  (kill-buffer)
  (delete-frame)

    - pid         - PID of the app that invoked Edit-with-Emacs
    - title       - title of the app that invoked Edit-with-Emacs")

(defvar spacehammer/before-finish-edit-with-emacs-hook nil
  "Hook for when edit-with-emacs is finished and dedicated buffer and frame are about to get killed.
   Hook function must accept arguments:
    - buffer-name - the name of the edit buffer
    - pid         - PID of the app that invoked Edit-with-Emacs")

(defvar spacehammer/before-cancel-edit-with-emacs-hook nil
  "Hook for when edit-with-emacs is canceled and dedicated buffer and frame are about to get killed.
   Hook function must accept arguments:
    - buffer-name - the name of the edit buffer
    - pid         - PID of the app that invoked Edit-with-Emacs")

(defun spacehammer/edit-with-emacs (&optional pid title screen)
  "Edit anything with Emacs

