 
  
+;; Macros
+
+(defmacro shm-with-fallback (fallback &rest body)
+  "Perform the given action unless we're in a comment, in which
+  case run the fallback function insteaad."
+  `(if (shm-in-comment)
+       (call-interactively ',fallback)
+     (progn ,@body)))
+
++
 ;; Internal mode functions
 
 (defun shm-mode-start ()

(defun shm/close-paren ()
  "Either insert a close paren or go to the end of the node."
  (interactive)
  (if (shm-literal-insertion)
      (shm-insert-string ")")
    (shm/goto-parent-end)))

(defun shm/goto-parent-end ()
  "Set the current node overlay to the parent node, but go to the

  (interactive)
  (if (bound-and-true-p god-local-mode)
      (god-mode-self-insert)
    (cond
     ((shm-in-comment)
      (insert " "))
     ((looking-back "[^a-zA-Z0-9_]case")
      (let ((start (save-excursion (forward-char -1)
                                   (search-backward-regexp "[^a-zA-Z0-9_]")
                                   (forward-char 1)
                                   (point)))
            (template "case  of
  _ -> undefined"))
        (shm-adjust-dependents (point) (- start (point)))
        (delete-region start (point))
        (shm-adjust-dependents (point) (length (car (last (split-string template "\n")))))
        (shm-insert-indented
         (lambda ()
           (insert template)))
        (forward-char 5)))
     ((looking-back "[^a-zA-Z0-9_]if")
      (let ((start (save-excursion (forward-char -1)
                                   (search-backward-regexp "[^a-zA-Z0-9_]")
                                   (forward-char 1)
                                   (point)))
            (template (if (looking-at "$")
                          "if \n   then undefined\n   else undefined"
                        "if  then undefined else undefined")))
        (shm-adjust-dependents (point) (- start (point)))
        (delete-region start (point))
        (shm-adjust-dependents (point) (length (car (last (split-string template "\n")))))
        (shm-insert-indented
         (lambda ()
           (insert template)))
        (forward-char 3)))
     (t (shm-insert-string " ")))))

(defun shm/double-quote ()
  "Insert double quotes.
