GithubHelp home page GithubHelp logo

Comments (6)

jwiegley avatar jwiegley commented on May 27, 2024

This sounds like a great idea!

from alert.

unhammer avatar unhammer commented on May 27, 2024

#61

from alert.

unhammer avatar unhammer commented on May 27, 2024

If the style notifier is https://github.com/julienXX/terminal-notifier, then it seems like it can take a -group ID (no need to keep a hashmap for that one); I don't have a Mac to test that on though.

If growlnotify is the same as http://www.growlforwindows.com/gfw/help/growlnotify.aspx then this one seems usable: /c:coalesingid The coalescing id used to update/replace existing notifications.

I don't know if any other styles would support replacing.

from alert.

unhammer avatar unhammer commented on May 27, 2024

Would it also make sense to add this as the :remover of the style? Ie.:

diff --git a/alert.el b/alert.el
index 9b5ce12..c699e33 100644
--- a/alert.el
+++ b/alert.el
@@ -798,8 +798,18 @@ by the `notifications' style.")
       (puthash (plist-get info :id) id alert-notifications-ids)))
   (alert-message-notify info))
 
+(defun alert-notifications-remove (info)
+  "Remove the `notifications-notify' message based on INFO :id."
+  (message "remove %S" info)
+  (let ((id (and (plist-get info :id)
+                 (gethash (plist-get info :id) alert-notifications-ids))))
+    (when id
+      (notifications-close-notification id)
+      (remhash (plist-get info :id) alert-notifications-ids))))
+
 (alert-define-style 'notifications :title "Notify using notifications"
-                    :notifier #'alert-notifications-notify))
+                    :notifier #'alert-notifications-notify
+                    :remover #'alert-notifications-remove))
 
 
 (defcustom alert-notifier-command (executable-find "terminal-notifier")

One minor issue is that this makes it a bit confusing to test, since simply doing (alert "test test" :id "new-mail") from eval-expression will get immediately removed by the post-command-hook alert-remove-on-command, unless you also provide some :buffer to it.

OTOH, adding a :remover probably makes the alert styles act more like each other wrt. never-persist and buffer changes and such.

from alert.

unhammer avatar unhammer commented on May 27, 2024

@jwiegley I find the above (defun alert-notifications-remove handy, but I'm not sure if having it as :remover can mess up things. Should I make a PR with just the defun for now?

from alert.

jwiegley avatar jwiegley commented on May 27, 2024

Sure, that's safe enough to merge right away.

from alert.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.