 ;; Command line shortcuts
 ;; ****************************************************************
 
-;; Window with code
-(setq code-win (selected-window))
 ;; Window with Pig running
 (setq pig-win 'nil)
 

      (setq line-command (buffer-substring begin end))
      (setq real-line-command (replace-regexp-in-string "--.*\n" "" line-command))
      (setq real-line-command (replace-regexp-in-string "\n" " " real-line-command))
      (select-window pig-win)
      (goto-char (point-max))
      (insert real-line-command)
      (comint-send-input)
      (select-window code-win)
      (message "Line executed"))

(defun send-undo ()
      "Send undo to Pig"
      (may-open-pig)
      (interactive)
      (select-window pig-win)
      (goto-char (point-max))
      (insert "undo")
      (comint-send-input)
      (select-window code-win)
      (forward-line -1)
      (message "Undone"))



(defun open-pig ()
      "Open Pig"
      (interactive)
      (delete-other-windows)
      (switch-to-buffer-other-window "*Pig*")
      (erase-buffer)
      (comint-run "Pig")
      (other-window -1)
      (setq pig-win 't)
      (message "Pig opened"))

(defun send-line ()
