]> code.delx.au - dotemacs/blobdiff - lisp/my-shackle.el
Moved emacs temp files to ~/.cache
[dotemacs] / lisp / my-shackle.el
index 5281a854a1ad1c6654fc698377b83118d4675f4a..6965b965719a6ac401fdef3929d00f0e6badac53 100644 (file)
@@ -2,14 +2,39 @@
 
 (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)
-                      ((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-default-rule '(:align below :select t :size 15))
 
 (setq shackle-default-size 0.5)
 
+(defun shackle-match (buffer-or-name)
+  (cl-loop for (condition . plist) in (my/shackle-rules)
+           when (shackle--match buffer-or-name condition plist)
+           return plist
+           finally return shackle-default-rule))
+
 (shackle-mode)