-;; Time-stamp: <2016-02-15 14:59:30 kmodi>
+;; Time-stamp: <2016-02-20 01:40:39 kmodi>
 
 ;; Functions to manipulate windows and buffers
 

  ;; overriding `C-x C-p' originally bound to `mark-page'
  ("C-x C-p"      . show-copy-buffer-file-name)
  ;; overriding `C-x <delete>' originally bound to `backward-kill-sentence'
  ("C-x <delete>" . 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-("          . toggle-between-buffers)
  ("C-)"          . modi/kill-buffer-dwim))

  ("<M-mouse-4>" . scroll-other-window-down-dont-move-point) ; M + wheel up
  ("<M-mouse-5>" . scroll-other-window-up-dont-move-point)) ; M + wheel down

;; Allow scrolling of all buffers using mouse-wheel in `scroll-all-mode'.
;; By default, `scroll-all-mode' works only with C-v/M-v.
(defun modi/advice-mwhell-scroll-all (orig-fun &rest args)
  "Execute ORIG-FUN in all the windows."
  (let (ret)
    (if scroll-all-mode
        (save-selected-window (walk-windows (lambda (win)
                                              (select-window win)
                                              (condition-case nil
                                                  (setq ret (apply orig-fun args))
                                                (error nil)))))
      (setq ret (apply orig-fun args)))
    ret))
(advice-add 'scroll-up   :around #'modi/advice-mwhell-scroll-all)
(advice-add 'scroll-down :around #'modi/advice-mwhell-scroll-all)

;; Ediff
(use-package ediff
