-;; Time-stamp: <2017-05-16 17:37:11 kmodi>
+;; Time-stamp: <2017-05-27 01:08:47 kmodi>
 
 ;; Windows and buffers manipulation
 

         ("s-<right>" . windmove-right)
         ("s-<up>"    . windmove-up)
         ("s-<down>"  . windmove-down)
         ("C-c ]"     . hydra-win-resize/body)
         ("C-c ["     . hydra-win-resize/body))
  :config
  (progn
    (setq windmove-wrap-around t) ; default = nil

    ;; Move window splitters / Resize windows
    ;; https://github.com/abo-abo/hydra/blob/master/hydra-examples.el
    (defun hydra-move-splitter-left (delta)
      "Move window splitter left."
      (interactive "p")
      (let ((windmove-wrap-around nil))
        (if (windmove-find-other-window 'right)
            (shrink-window-horizontally delta)
          (enlarge-window-horizontally delta))))

    (defun hydra-move-splitter-right (delta)
      "Move window splitter right."
      (interactive "p")
      (let ((windmove-wrap-around nil))
        (if (windmove-find-other-window 'right)
            (enlarge-window-horizontally delta)
          (shrink-window-horizontally delta))))

    (defun hydra-move-splitter-up (delta)
      "Move window splitter up."
      (interactive "p")
      (let ((windmove-wrap-around nil))
        (if (windmove-find-other-window 'up)
            (enlarge-window delta)
          (shrink-window delta))))

    (defun hydra-move-splitter-down (delta)
      "Move window splitter down."
      (interactive "p")
      (let ((windmove-wrap-around nil))
        (if (windmove-find-other-window 'up)
            (shrink-window delta)
          (enlarge-window delta))))

    (defhydra hydra-win-resize (:color red)
      "win-resize"
      ("]"        hydra-move-splitter-right "→")
      ("["        hydra-move-splitter-left  "←")
      ("p"        hydra-move-splitter-up    "↑") ; mnemonic: `p' for `up'
      ("{"        hydra-move-splitter-up    "↑")
      ("\\"        hydra-move-splitter-down  "↓")
      ("}"        hydra-move-splitter-down  "↓")
      ("="        balance-windows           "Balance")
      ("q"        nil "cancel" :color blue)
      ("<return>" nil "cancel" :color blue))))


;;;; Other Bindings
(bind-keys
 :map modi-mode-map
 ("C-x 1"        . modi/toggle-one-window) ; default binding to `delete-other-windows'
 ;; overriding `C-x C-p' originally bound to `mark-page'
 ("C-x C-p"      . modi/copy-buffer-file-name)
 ;; overriding `C-x <delete>' originally bound to `backward-kill-sentence'
 ("C-x <delete>" . modi/delete-current-buffer-file)
 ("C-x C-r"      . rename-current-buffer-file)
 ("C-S-t"        . reopen-killed-file) ; mimick reopen-closed-tab in browsers
 ("C-c 6"        . reopen-killed-file) ; alternative to C-S-t for terminal mode
 ("C-("          . toggle-between-buffers)
 ("C-c ("        . toggle-between-buffers) ; alternative to C-( for terminal mode
 ("C-)"          . modi/kill-buffer-dwim)
 ("C-c )"        . modi/kill-buffer-dwim) ; alternative to C-) for terminal mode
 ("C-c 0"        . modi/kill-buffer-dwim)) ; alternative to C-) for terminal mode

;; Below bindings are made in global map as I want them to work even when my
;; minor mode is disabled
