about summary refs log tree commit diff
path: root/init
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-06-14T22·02+0200
committerVincent Ambo <tazjin@gmail.com>2018-06-14T22·02+0200
commitecf68e357c5349d4cda9916152fdb371ee51571d (patch)
treeecaa97f771295718f5244e1980ef2863cfb9e6a4 /init
parenta6a0e28e116e2e8d8826bbc1d3711f3615e919e0 (diff)
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.
Diffstat (limited to 'init')
-rw-r--r--init/functions.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/init/functions.el b/init/functions.el
index ebcc5b5f7d19..4ca7cedb2797 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)