summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-11-18 20:45:21 +0000
committerjao <jao@gnu.org>2026-11-18 20:45:21 +0000
commite1236d902dd7f7a6cf5a4396ad4074c1e30e7016 (patch)
treeccd1e8531589f38c59250fc3603f423f4c5bd96d /lib
parent2053144c9c0e68b278d8f3fa8ddf9c34fc81e297 (diff)
downloadelibs-e1236d902dd7f7a6cf5a4396ad4074c1e30e7016.tar.gz
elibs-e1236d902dd7f7a6cf5a4396ad4074c1e30e7016.tar.bz2
shuffling code aroundmain
Diffstat (limited to 'lib')
-rw-r--r--lib/eos/jao-buffers.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/eos/jao-buffers.el b/lib/eos/jao-buffers.el
index 3339d33..ae4f14f 100644
--- a/lib/eos/jao-buffers.el
+++ b/lib/eos/jao-buffers.el
@@ -43,6 +43,50 @@
(set-window-buffer (funcall selector) this-win)
(select-window (funcall selector)))
(setq arg (if (> arg 0) (1- arg) (1+ arg))))))
+
+;;;; window navigation (nth)
+;;;###autoload
+(defun jao-nth-window (n)
+ (if (zerop n)
+ 'jao-first-window
+ `(lambda ()
+ (interactive)
+ (select-window (frame-first-window))
+ (dotimes (x ,n) (other-window 1)))))
+
+;;;###autoload
+(defun jao-prev-window ()
+ "Go to previous window."
+ (interactive)
+ (other-window -1))
+
+;;;; window switching
+(defvar jao--previous-window nil)
+
+(defun jao-save-current-window (&rest _ignore)
+ (unless (active-minibuffer-window)
+ (setq jao--previous-window (get-buffer-window (current-buffer)))))
+
+;;;###autoload
+(defun jao-switch-with-previous-window ()
+ (interactive)
+ (let ((previous-window jao--previous-window))
+ (jao-save-current-window)
+ (if (and (window-live-p previous-window)
+ (not (equal previous-window (get-buffer-window (current-buffer)))))
+ (select-window previous-window)
+ (other-window 1))))
+
+;;;###autoload
+(defun jao-switch-with-first-window ()
+ (interactive)
+ (if (eq (selected-window) (frame-first-window))
+ (jao-switch-with-previous-window)
+ (jao-save-current-window)
+ (select-window (frame-first-window))))
+
+(advice-add 'other-window :before #'jao-save-current-window)
+
;;; attached buffers
(defun jao-display-buffer-below-selected (buffer alist)
(delete-other-windows-vertically)