summaryrefslogtreecommitdiffhomepage
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
parent2053144c9c0e68b278d8f3fa8ddf9c34fc81e297 (diff)
downloadelibs-e1236d902dd7f7a6cf5a4396ad4074c1e30e7016.tar.gz
elibs-e1236d902dd7f7a6cf5a4396ad4074c1e30e7016.tar.bz2
shuffling code aroundmain
-rw-r--r--attic/elisp/misc.el12
-rw-r--r--init.el55
-rw-r--r--lib/eos/jao-buffers.el44
3 files changed, 59 insertions, 52 deletions
diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el
index 1668251..14cd56a 100644
--- a/attic/elisp/misc.el
+++ b/attic/elisp/misc.el
@@ -1362,3 +1362,15 @@ It should be the title of the web page as returned by `rdrview'"
(when-let* ((url (or (get-text-property (point) 'w3m-href-anchor)
(thing-at-point-url-at-point))))
(browse-url url)))
+;;; repeat map for window ops
+(defvar jao-prev-window-repeat-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "p" 'jao-prev-window)
+ (define-key map "P" (lambda ()
+ (interactive)
+ (setq repeat-map 'jao-prev-window-repeat-map)
+ (other-window 1)))
+ map)
+ "Keymap to repeat `prev-window' key sequences. Used in `repeat-mode'.")
+
+(put 'jao-prev-window 'repeat-map jao-prev-window-repeat-map)
diff --git a/init.el b/init.el
index d7e4d13..2e75e94 100644
--- a/init.el
+++ b/init.el
@@ -980,65 +980,16 @@
(global-set-key (kbd "C-x _") #'delete-other-windows-vertically)
;;;; window navigation (custom)
-(defun jao-nth-window (n)
- (if (zerop n)
- 'jao-first-window
- `(lambda ()
- (interactive)
- (select-window (frame-first-window))
- (dotimes (x ,n) (other-window 1)))))
-
-(defun jao-prev-window ()
- "Go to previous window."
- (interactive)
- (other-window -1))
-
-(defvar jao-prev-window-repeat-map
- (let ((map (make-sparse-keymap)))
- (define-key map "p" 'jao-prev-window)
- (define-key map "P" (lambda ()
- (interactive)
- (setq repeat-map 'jao-prev-window-repeat-map)
- (other-window 1)))
- map)
- "Keymap to repeat `prev-window' key sequences. Used in `repeat-mode'.")
-
-(put 'jao-prev-window 'repeat-map jao-prev-window-repeat-map)
-
(mapc (lambda (n)
(global-set-key (format "\C-c%s" (1+ n)) (jao-nth-window n)))
'(0 1 2 3 4 5 6 7 8))
-;;;;; last window
-(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)))))
-
-(defun jao-switch-goto-previous-window ()
- (interactive)
- (let ((previous-window jao-previous-window))
- (jao-save-current-window)
- (if (window-live-p previous-window)
- (select-window previous-window)
- (other-window 1))))
-
-(advice-add 'other-window :before #'jao-save-current-window)
-
(global-set-key "\C-xp" 'jao-prev-window)
-(global-set-key (kbd "M-o") #'jao-switch-goto-previous-window)
+(global-set-key (kbd "M-o") #'jao-switch-with-previous-window)
;;;;; first window
-(defun jao-first-window ()
- (interactive)
- (if (eq (selected-window) (frame-first-window))
- (jao-switch-goto-previous-window)
- (jao-save-current-window)
- (select-window (frame-first-window))))
-
-(global-set-key (kbd "s-a") #'jao-first-window)
-(global-set-key (kbd "M-a") #'jao-first-window)
+(global-set-key (kbd "s-a") #'jao-switch-with-first-window)
+(global-set-key (kbd "M-a") #'jao-switch-with-first-window)
;;;; window navigation (switch-window)
(use-package switch-window
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)