feat(functions): Add predicate function to determine last window

Adds a function that can be used to check whether the current buffer
is displayed in the "last" window of the active frame.

The intention is to use this predicate to modify the modeline display
to only show miscellaneous information (time, battery percentage etc.)
on the last window instead of duplicating it.
This commit is contained in:
Vincent Ambo 2018-06-15 00:02:04 +02:00
parent a6a0e28e11
commit ecf68e357c

View file

@ -204,4 +204,14 @@ Including indent-buffer, which should not be called automatically on save."
(epg-sign-string (epg-make-context) "dummy")
nil)
(defun bottom-right-window-p ()
"Determines whether the last (i.e. bottom-right) window of the
active frame is showing the buffer in which this function is
executed."
(let* ((frame (selected-frame))
(right-windows (window-at-side-list frame 'right))
(bottom-windows (window-at-side-list frame 'bottom))
(last-window (car (seq-intersection right-windows bottom-windows))))
(eq (current-buffer) (window-buffer last-window))))
(provide 'functions)