about summary refs log tree commit diff stats
path: root/.emacs.d
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/init-clojure.el9
-rw-r--r--.emacs.d/lisp/init-windows.el42
2 files changed, 25 insertions, 26 deletions
diff --git a/.emacs.d/lisp/init-clojure.el b/.emacs.d/lisp/init-clojure.el
index 9775a52..20394e3 100644
--- a/.emacs.d/lisp/init-clojure.el
+++ b/.emacs.d/lisp/init-clojure.el
@@ -208,8 +208,17 @@
     (when (apply #'eq (mapcar 'window-buffer (window-list)))
       (delete-other-windows)))
   (advice-add #'cider-close-ancillary-buffers :after #'fix-duplicate-windows)
+
+  (defun switch-to-cider-repl ()
+    "Wrapper around `cider-switch-to-repl-buffer' with custom functionality."
+    (interactive)
+    (if (get-buffer-window (cider-current-repl))
+        (cider-switch-to-repl-buffer)
+      (cider-switch-to-repl-buffer)
+      (transpose-large-frame)))
   :bind
   (:map cider-mode-map
+        ("C-c C-z" . switch-to-cider-repl)
         ("C-c M-l" . cider-load-file)
         ("C-c M-b" . cider-interrupt))
   (:map cider-repl-mode-map
diff --git a/.emacs.d/lisp/init-windows.el b/.emacs.d/lisp/init-windows.el
index 2bf54a3..8b65eca 100644
--- a/.emacs.d/lisp/init-windows.el
+++ b/.emacs.d/lisp/init-windows.el
@@ -8,32 +8,10 @@
   :bind
   ("C-x C-M-b" . ibuffer)
   :config
-  ;; From EmacsWiki
-  (defun toggle-window-split ()
-    (interactive)
-    (if (= (count-windows) 2)
-        (let* ((this-win-buffer (window-buffer))
-               (next-win-buffer (window-buffer (next-window)))
-               (this-win-edges (window-edges (selected-window)))
-               (next-win-edges (window-edges (next-window)))
-               (this-win-2nd (not (and (<= (car this-win-edges)
-                                           (car next-win-edges))
-                                       (<= (cadr this-win-edges)
-                                           (cadr next-win-edges)))))
-               (splitter
-                (if (= (car this-win-edges)
-                       (car (window-edges (next-window))))
-                    'split-window-horizontally
-                  'split-window-vertically)))
-          (delete-other-windows)
-          (let ((first-win (selected-window)))
-            (funcall splitter)
-            (if this-win-2nd (other-window 1))
-            (set-window-buffer (selected-window) this-win-buffer)
-            (set-window-buffer (next-window) next-win-buffer)
-            (select-window first-win)
-            (if this-win-2nd (other-window 1))))))
-  (define-key ctl-x-4-map "t" 'toggle-window-split))
+  (defcustom large-frame-width-threshold 500
+    "Minimum width (in chars) to consider the frame large."
+    :group 'djm
+    :type 'natnum))
 
 (use-feature winner
   :defer 5
@@ -68,6 +46,18 @@
   (fullframe vc-annotate quit-window)
   (fullframe elpaca-fetch-all quit-window))
 
+(use-package transpose-frame
+  :bind (:map ctl-x-4-map ("t" . transpose-frame))
+  :config
+  (defun transpose-large-frame ()
+    "Trasnpose the window arrangement, if the frame is large.
+
+This is based on the frame width, with the threshold being customised using
+`large-frame-width-threshold'."
+    (when (> large-frame-width-threshold (frame-char-width)) (transpose-frame)))
+  :hook
+  (cider-connected . transpose-large-frame))
+
 (use-package ace-window
   :diminish
   :config