Add resize features to window manipulation

This commit is contained in:
Diego Berrocal 2015-02-10 22:31:56 -05:00 committed by syl20bnr
parent bc8cb54605
commit e2140fab84
2 changed files with 38 additions and 59 deletions

View file

@ -736,51 +736,6 @@ otherwise it is scaled down."
;;; end scale font micro-state
;;; begin resize window micro-state
(defun spacemacs//resize-window-micro-state-doc ()
(echo (format
"[%sx%s] Resize window: (H/L) shrink/enlarge horizontally, (J/K) shrink/enlarge vertically"
(window-total-width) (window-total-height))))
(defun spacemacs/resize-window-overlay-map ()
"Set a temporary overlay map to easily resize a window."
(interactive)
(set-temporary-overlay-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "H") 'spacemacs/shrink-window-horizontally)
(define-key map (kbd "J") 'spacemacs/shrink-window)
(define-key map (kbd "K") 'spacemacs/enlarge-window)
(define-key map (kbd "L") 'spacemacs/enlarge-window-horizontally)
map) t)
(spacemacs//resize-window-micro-state-doc))
(defun spacemacs/shrink-window-horizontally (delta)
"Wrap `spacemacs/shrink-window-horizontally'."
(interactive "p")
(shrink-window delta t)
(spacemacs/resize-window-overlay-map))
(defun spacemacs/shrink-window (delta)
"Wrap `spacemacs/shrink-window'."
(interactive "p")
(shrink-window delta)
(spacemacs/resize-window-overlay-map))
(defun spacemacs/enlarge-window (delta)
"Wrap `spacemacs/enlarge-window'."
(interactive "p")
(enlarge-window delta)
(spacemacs/resize-window-overlay-map))
(defun spacemacs/enlarge-window-horizontally (delta)
"Wrap `spacemacs/enlarge-window-horizontally'."
(interactive "p")
(enlarge-window delta t)
(spacemacs/resize-window-overlay-map))
;;; end resize window micro-state
(defmacro spacemacs|diminish (mode unicode &optional ascii)
"Diminish MODE name in mode line to UNICODE or ASCII depending on the value
`dotspacemacs-mode-line-unicode-symbols'.
@ -850,8 +805,31 @@ If ASCII si not provided then UNICODE is used instead."
(start-process "" nil "xdg-open" file-path)))
)))
(defun spacemacs//window-manipulation-documentation ()
"Window navigation micro-state
;; Window Manipulation Micro State
(defun spacemacs/shrink-window-horizontally (delta)
"Wrap `spacemacs/shrink-window-horizontally'."
(interactive "p")
(shrink-window delta t))
(defun spacemacs/shrink-window (delta)
"Wrap `spacemacs/shrink-window'."
(interactive "p")
(shrink-window delta))
(defun spacemacs/enlarge-window (delta)
"Wrap `spacemacs/enlarge-window'."
(interactive "p")
(enlarge-window delta))
(defun spacemacs/enlarge-window-horizontally (delta)
"Wrap `spacemacs/enlarge-window-horizontally'."
(interactive "p")
(enlarge-window delta t))
(spacemacs|define-micro-state window-manipulation
:documentation
"Window Manipulation micro-state
h,j,k,l to go to left|bottom|top|right
H,J,K,L to move windows to to far/very left|bottom|top|right
R to Rotate windows
@ -859,10 +837,9 @@ If ASCII si not provided then UNICODE is used instead."
-,/ to split windows bellow|right and focus
u,U restore previous|next window configuration
o/w other frame|window
Press any other key to exit.")
(spacemacs|define-micro-state window-manipulation
:documentation (spacemacs//window-manipulation-documentation)
[,] to shrink/enlarge horizontaly
{,} to shrink/enlarge verticaly
Press any other key to exit."
:bindings
("h" evil-window-left)
("j" evil-window-down)
@ -877,15 +854,18 @@ Press any other key to exit.")
("C" delete-other-windows)
("-" split-window-below-and-focus)
("/" split-window-right-and-focus)
("s" split-window-below-and-focus)
("v" split-window-right-and-focus)
("s" split-window-below)
("v" split-window-right)
("S" split-window-below-and-focus)
("V" split-window-right-and-focus)
("u" winner-undo)
("U" winner-redo)
("o" other-frame)
("w" other-window)
;; ("[" spacemacs/shrink-window-horizontally)
;; ("]" spacemacs/enlarge-window-horizontally)
;; ("{" spacemacs/shrink-window)
;; ("}" spacemacs/enlarge-window)
("?" spacemacs/window-manipulation-micro-state)
("[" spacemacs/shrink-window-horizontally)
("]" spacemacs/enlarge-window-horizontally)
("{" spacemacs/shrink-window)
("}" spacemacs/enlarge-window)
)
;; end of Window Manipulation Micro State

View file

@ -243,7 +243,6 @@
"wM" 'toggle-maximize-centered-buffer
"wm" 'toggle-maximize-buffer
"wo" 'other-frame
"wr" 'spacemacs/resize-window-overlay-map
"wR" 'rotate-windows
;; "wv" 'evenly-split-window-below)
"ws" 'split-window-below