emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-notify f16d775731 03/23: Allow popping up multiple


From: ELPA Syncer
Subject: [elpa] externals/org-notify f16d775731 03/23: Allow popping up multiple notification windows.
Date: Mon, 25 Jul 2022 12:57:56 -0400 (EDT)

branch: externals/org-notify
commit f16d77573128697977fa327f977d7b4c7a0ce8d3
Author: Peter Münster <pmrb@free.fr>
Commit: Peter Münster <pmrb@free.fr>

    Allow popping up multiple notification windows.
---
 org-notify.el | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/org-notify.el b/org-notify.el
index 9f28d4d5e6..0fdeca8e4f 100644
--- a/org-notify.el
+++ b/org-notify.el
@@ -59,7 +59,6 @@
 (require 'org-element)
 
 (declare-function appt-delete-window         "appt"           ())
-(declare-function appt-select-lowest-window  "appt"           ())
 (declare-function notifications-notify       "notifications"  (&rest params))
 
 (defconst orgntf-actions '("done" "done" "hour" "one hour later" "day"
@@ -225,7 +224,9 @@ for SECS is 50."
 
 (defun orgntf-delete-window (buffer)
   "Delete the notification window."
-  (let ((appt-buffer-name buffer)  (appt-audible nil))
+  (require 'appt)
+  (let ((appt-buffer-name buffer)
+        (appt-audible nil))
     (appt-delete-window)))
 
 (defun orgntf-on-close (id reason)
@@ -248,9 +249,25 @@ for SECS is 50."
 ; todo
 )
 
+(defun orgntf-select-highest-window ()
+  "Select the highest window on the frame, that is not is not an
+org-notify window. Copied mostly from `appt-select-lowest-window'."
+  (let ((highest-window (selected-window))
+        (bottom-edge (nth 3 (window-edges)))
+        next-bottom-edge)
+    (walk-windows (lambda (w)
+                    (when (and
+                           (not (string-match "^\\*org-notify-.*\\*$"
+                                              (buffer-name
+                                               (window-buffer w))))
+                           (> bottom-edge (setq next-bottom-edge
+                                                (nth 3 (window-edges w)))))
+                      (setq bottom-edge next-bottom-edge
+                            highest-window w))) 'nomini)
+    (select-window highest-window)))
+
 (defun org-notify-action-window (plist)
   "Pop up a window, mostly copied from `appt-disp-window'."
-  (require 'appt)
   (save-excursion
     (macrolet ((get (k) `(plist-get plist ,k)))
       (let ((this-window (selected-window))
@@ -263,9 +280,9 @@ for SECS is 50."
             (progn (set-buffer buf) (display-buffer buf))
           (unless (or (special-display-p (buffer-name buf))
                       (same-window-p (buffer-name buf)))
-            (appt-select-lowest-window)
+            (orgntf-select-highest-window)
             (when (>= (window-height) (* 2 window-min-height))
-              (select-window (split-window))))
+              (select-window (split-window nil nil 'above))))
           (switch-to-buffer buf))
         (setq buffer-read-only nil  buffer-undo-list t)
         (erase-buffer)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]