(require 'shackle)
-(setq shackle-rules '(((:custom buffer-file-name) :other t)
- (direx:direx-mode :align left :size 40 :select t)
- ("*magit-.*-popup*" :regexp t :align right :size 63 :select t)
- (magit-status-mode :align below :size 20 :select t)
- ("*Flycheck error messages*" :align below :size 15 :select nil)
- ((magit-diff-mode magit-revision-mode) :align right)))
+(defun my/shackle-rules ()
+ (let ((rules-common
+ '(((:custom buffer-file-name) :other t)
+ (direx:direx-mode :align left :size 40 :select t)
+ ("*Flycheck error messages*" :align below :size 15 :select nil)))
+ (rules-wide
+ '(("magit-.*-popup" :regexp t :align right :select t)
+ ((magit-log-mode magit-status-mode) :align bottom :size 15 :select t)
+ ((magit-diff-mode magit-revision-mode) :align right :size 80)))
+ (rules-narrow-tall
+ '(("magit-.*-popup" :regexp t :align bottom :select t)
+ (magit-status-mode :align bottom :size 25 :select t)
+ ((magit-diff-mode magit-revision-mode) :align bottom :size 25)))
+ (rules-narrow-short
+ '(("magit-.*-popup" :regexp t :align bottom :select t)
+ (magit-status-mode :align bottom :size 0.8 :select t)
+ ((magit-diff-mode magit-revision-mode) :align bottom :size 0.65))))
+ (cond
+ ((>= (frame-text-cols) 120)
+ (append rules-common rules-wide))
+ ((>= (frame-text-lines) 30)
+ (append rules-common rules-narrow-tall))
+ (t
+ (append rules-common rules-narrow-short)))))
+
+(setq shackle-rules #'my/shackle-rules)
(setq shackle-default-rule '(:align below :select t :size 15))