From ecf68e357c5349d4cda9916152fdb371ee51571d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 15 Jun 2018 00:02:04 +0200 Subject: [PATCH] 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. --- init/functions.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/init/functions.el b/init/functions.el index ebcc5b5f7..4ca7cedb2 100644 --- a/init/functions.el +++ b/init/functions.el @@ -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)