From 7911d5bc6761be4d772a8a28a680965ec6b4cd9e Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 18 Nov 2020 23:40:15 +0000 Subject: ednc improvements --- misc/jao-ednc.el | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/misc/jao-ednc.el b/misc/jao-ednc.el index b808e2d..6a28658 100644 --- a/misc/jao-ednc.el +++ b/misc/jao-ednc.el @@ -28,9 +28,16 @@ (require 'ednc) (require 'jao-minibuffer) +(declare-function tracking-add-buffer "tracking") +(declare-function tracking-remove-buffer "tracking") + (defvar jao-ednc--count-format "{%d}") (defvar jao-ednc--last-notification nil) +(defface jao-ednc-tracking '((t :inherit warning)) + "Tracking notifications face" + :group 'jao-ednc) + (defun jao-ednc--format-last () (when jao-ednc--last-notification (let ((s (ednc-format-notification jao-ednc--last-notification t))) @@ -42,26 +49,36 @@ (defun jao-ednc--on-notify (old new) (when old + (tracking-remove-buffer (get-buffer ednc-log-name)) (setq jao-ednc--last-notification nil) (jao-minibuffer-pop-notification)) (when new + (tracking-add-buffer (get-buffer ednc-log-name)) (setq jao-ednc--last-notification new) (jao-minibuffer-push-notification '(:eval (jao-ednc--format-last))))) ;;;###autoload (defun jao-ednc-setup () - (with-eval-after-load "jao-notify" - (defun jao-ednc--notify (msg &optional title _) - (message "%s%s%s" (or title "") (if title " " "") msg)) - (advice-add 'jao-notify :override #'jao-ednc--notify)) + (setq jao-notify-use-messages-p t) + (with-eval-after-load "tracking" + (add-to-list 'tracking-faces-priorities 'jao-ednc-tracking) + (when (listp tracking-shorten-modes) + (add-to-list 'tracking-shorten-modes 'ednc-view-mode))) (jao-minibuffer-add-variable '(jao-ednc--count) t) (add-hook 'ednc-notification-presentation-functions #'jao-ednc--on-notify) (ednc-mode)) +;;;###autoload +(defun jao-ednc-pop () + (interactive) + (pop-to-buffer-same-window ednc-log-name)) + ;;;###autoload (defun jao-ednc-show () (interactive) - (pop-to-buffer-same-window "*ednc-log*")) + (if jao-ednc--last-notification + (ednc-pop-to-notification-in-log-buffer jao-ednc--last-notification) + (jao-ednc-pop))) ;;;###autoload (defun jao-ednc-invoke-last-action () @@ -71,5 +88,12 @@ (message "No active notifications")) (jao-minibuffer-pop-notification)) +;;;###autoload +(defun jao-ednc-dismiss () + (interactive) + (if jao-ednc--last-notification + (ednc-dismiss-notification jao-ednc--last-notification) + (jao-minibuffer-pop-notification))) + (provide 'jao-ednc) ;;; jao-ednc.el ends here -- cgit v1.2.3