Skip to content

Commit

Permalink
add command
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Aug 29, 2019
1 parent a5d1d9c commit e560031
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/core/window-command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
scroll-up
find-file-other-window
read-file-other-window
select-buffer-other-window))
select-buffer-other-window
switch-to-last-focused-window))

(eval-when (:compile-toplevel :load-toplevel)
(defmacro define-other-window-command (command prompt)
Expand Down Expand Up @@ -91,6 +92,11 @@
(define-command split-active-window-horizontally (&optional n) ("P")
(split-window-horizontally (current-window) n))

(defvar *last-focused-window-id* nil)

(defun update-last-focused-window ()
(setf *last-focused-window-id* (window-id (current-window))))

(define-key *global-keymap* "C-x o" 'other-window)
(define-command other-window (&optional (n 1)) ("p")
(let ((window-list
Expand All @@ -99,6 +105,7 @@
(window-list))))
(when (minusp n)
(setf n (- (length window-list) (abs n))))
(update-last-focused-window)
(dotimes (_ n t)
(setf (current-window)
(get-next-window (current-window)
Expand All @@ -110,6 +117,13 @@
(split-window-sensibly (current-window)))
(other-window n))

(define-command switch-to-last-focused-window () ()
(let ((window (or (and *last-focused-window-id*
(find-window *last-focused-window-id*))
(get-next-window (current-window)))))
(update-last-focused-window)
(setf (current-window) window)))

(define-command window-move-down () ()
(alexandria:when-let ((window (down-window (current-window))))
(setf (current-window) window)))
Expand Down

0 comments on commit e560031

Please sign in to comment.