-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwindows.lisp
32 lines (27 loc) · 1.29 KB
/
windows.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(in-package :stumpwm)
(defparameter *window-class-renumber*
'(("Emacs" . 0)
("Terminator" . 1)
("Chromium-browser" . 2))
"alist of window classes to be renumbered, and their _target numbers.")
(defun renumber-window-by-class (win)
"Renumber window if its class matches *window-class-renumber*."
(let* ((class (window-class win))
(_target-number (cdr (assoc class *window-class-renumber*
:test #'string=))))
(when _target-number
(let ((other-win (find-if #'(lambda (win)
(= (window-number win) _target-number))
(group-windows (window-group win)))))
(if other-win
(when (string-not-equal class (window-class other-win))
;; other window, different class; switch numbers
(setf (window-number other-win) (window-number win))
(setf (window-number win) _target-number))
;; If there's already a window of this class, do nothing.
;; just keep the new number for this window.
;; Else: no other window; _target number is free.
(setf (window-number win) _target-number))
;; Finally
(update-all-mode-lines)))))
(add-hook *new-window-hook* 'renumber-window-by-class)