-;; Time-stamp: <2015-08-21 14:27:43 kmodi>
+;; Time-stamp: <2015-08-28 12:28:00 kmodi>
 
 ;; Functions related to editing text in the buffer
 


(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
                           :color pink
                           :post (deactivate-mark))
  "

  ^_p_^     _d_   delete   _s_tring
_b_   _f_   _k_   cut      _r_eset
  ^_n_^     _w_   copy     e_x_change
^^^^        _y_   paste    _e_xtend
"
  ("b"   backward-char                      nil)
  ("f"   forward-char                       nil)
  ("p"   previous-line                      nil)
  ("n"   next-line                          nil)
  ("w"   copy-rectangle-as-kill             nil)
  ("k"   kill-rectangle                     nil)
  ("K"   copy-rectangle-as-kill-then-delete nil)
  ("y"   yank-rectangle                     nil)
  ("d"   delete-rectangle                   nil)
  ("s"   string-rectangle                   nil)
  ("t"   string-rectangle                   nil)
  ("x"   ora-ex-point-mark                  nil)
  ("r"   (if (region-active-p)
             (deactivate-mark)
           (rectangle-mark-mode 1))         nil)
  ("e"   modi/extend-rectangle-to-end       nil)
  ("q"   nil                                nil))
(bind-key "C-x SPC" #'hydra-rectangle/body modi-mode-map)

;; http://ergoemacs.org/emacs/modernization_upcase-word.html

       :map region-bindings-mode-map
        ("|" . extend-rectangle-to-end)))))

(defun modi/kill-rectangle-replace-with-space (start end)
  "Kill the rectangle and replace it with spaces."
  (interactive "r")
  (setq killed-rectangle (extract-rectangle start end))
  (clear-rectangle start end)
  (setq deactivate-mark t)
  (if (called-interactively-p 'interactive)
      (indicate-copied-region (length (car killed-rectangle)))))
