GithubHelp home page GithubHelp logo

alert's Introduction

Alert is a Growl-workalike for Emacs which uses a common notification interface and multiple, selectable "styles", whose use is fully customizable by the user.

For desktop notifications, the notifications package that is installed with emacs, provides a probably better alternative for most users.

For module writers

Just use alert instead of message as follows:

(require 'alert)

;; This is the most basic form usage
(alert "This is an alert")

;; You can adjust the severity for more important messages
(alert "This is an alert" :severity 'high)

;; Or decrease it for purely informative ones
(alert "This is an alert" :severity 'trivial)

;; Alerts can have optional titles.  Otherwise, the title is the
;; buffer-name of the (current-buffer) where the alert originated.
(alert "This is an alert" :title "My Alert")

;; Further, alerts can have categories.  This allows users to
;; selectively filter on them.
(alert "This is an alert" :title "My Alert" :category 'debug)

;; If a backend allows replacing alerts, you may pass an id
;; to your alert; then the next one with the same id will replace the
;; first one:
(alert "You have 30 unread mails" :title "Mail!" :id 'new-mail-alert)
(alert "You have 49 unread mails" :title "Mail!" :id 'new-mail-alert)
;; This avoids piling up lots of alerts, when only the last one is
;; relevant.

For users

For the user, there are several variables to control when and how alerts are presented. By default, they appear in the minibuffer much the same as a normal Emacs message. But there are many more possibilities:

  • alert-fade-time Normally alerts disappear after this many seconds, if the style supports it. The default is 5 seconds.

  • alert-default-style Pick the style to use if no other config rule matches. The default is message, but growl works well too.

  • alert-reveal-idle-time If a config rule choose to match on idle, this is how many seconds idle the user has to be. Defaults to 5 so that users don't miss any alerts, but 120 is also good.

  • alert-persist-idle-time After this many idle seconds, alerts will become sticky, and not fade away more. The default is 15 minutes.

  • alert-log-messages By default, all alerts are logged to *Alerts* (and to *Messages*, if the message style is being used). Set to nil to disable.

  • alert-hide-all-notifications Want alerts off entirely? They still get logged, however, unless you've turned that off too.

  • alert-user-configuration This variable lets you control exactly how and when a particular alert, a class of alerts, or all alerts, get reported -- or if at all. Use this to make some alerts use Growl, while others are completely silent.

Programmatically adding rules

Users can also programmatically add configuration rules, in addition to customizing alert-user-configuration. Here is one that the author currently uses with ERC, so that the fringe gets colored whenever people chat on BitlBee:

(alert-add-rule :status   '(buried visible idle)
                :severity '(moderate high urgent)
                :mode     'erc-mode
                :predicate
                #'(lambda (info)
                    (string-match (concat "\\`[^&].*@BitlBee\\'")
                                  (erc-format-target-and/or-network)))
                :persistent
                #'(lambda (info)
                    ;; If the buffer is buried, or the user has been
                    ;; idle for `alert-reveal-idle-time' seconds,
                    ;; make this alert persistent.  Normally, alerts
                    ;; become persistent after
                    ;; `alert-persist-idle-time' seconds.
                    (memq (plist-get info :status) '(buried idle)))
                :style 'fringe
                :continue t)

Builtin alert styles

There are several builtin styles, and it is trivial to create new ones. The builtins are:

Name Summary
fringe Changes the current frame's fringe background color
mode-line Changes the current frame's mode-line background color
gntp Uses gntp, it requires gntp.el
growl Uses Growl on OS X, if growlnotify is on the PATH
ignore Ignores the alert entirely
libnotify Uses libnotify if notify-send is on the PATH
log Logs the alert text to Alerts, with a timestamp
message Uses the Emacs message facility
notifications Uses notifications library via D-Bus
notifier Uses terminal-notifier on OS X, if it is on the PATH
osx-notifier Native OSX notification using AppleScript
toaster Use the toast notification system
x11 Changes the urgency property of the window in the X Window System
termux Use termux-notification from the Termux API

Defining new styles

To create a new style, you need to at least write a notifier, which is a function that receives the details of the alert. These details are given in a plist which uses various keyword to identify the parts of the alert. Here is a prototypical style definition:

(alert-define-style 'style-name :title "My Style's title"
                    :notifier
                    (lambda (info)
                      ;; The message text is :message
                      (plist-get info :message)
                      ;; The :title of the alert
                      (plist-get info :title)
                      ;; The :category of the alert
                      (plist-get info :category)
                      ;; The major-mode this alert relates to
                      (plist-get info :mode)
                      ;; The buffer the alert relates to
                      (plist-get info :buffer)
                      ;; Severity of the alert.  It is one of:
                      ;;   `urgent'
                      ;;   `high'
                      ;;   `moderate'
                      ;;   `normal'
                      ;;   `low'
                      ;;   `trivial'
                      (plist-get info :severity)
                      ;; Whether this alert should persist, or fade away
                      (plist-get info :persistent)
                      ;; Data which was passed to `alert'.  Can be
                      ;; anything.
                      (plist-get info :data))

                    ;; Removers are optional.  Their job is to remove
                    ;; the visual or auditory effect of the alert.
                    :remover
                    (lambda (info)
                      ;; It is the same property list that was passed to
                      ;; the notifier function.
                      ))

alert's People

Contributors

benreyn avatar codygman avatar colonelpanic8 avatar dalanicolai avatar damiencassou avatar fgallina avatar gergelypolonkai avatar gonewest818 avatar hexmode avatar iqbalansari avatar jabranham avatar jgkamat avatar juergenhoetzel avatar junfx avatar jwiegley avatar krydos avatar ksqsf avatar lurdan avatar mbolivar-nordic avatar myuhe avatar nasyxx avatar nicholastd07 avatar odanoburu avatar pcrama avatar purcell avatar ssl19 avatar syohex avatar tkhoa2711 avatar tzz avatar unhammer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alert's Issues

Incompatibility with emacs 25.1

Hi! I am an emacs user using spacemacs and org-pomodoro which happen to use alert. I didn't receive notificaitons from org-pomodoro because. I am not good with elisp but my hunch is alert is not compatible with emacs 25.1. I kindly request for the compatibility with this one thanks.

notifications needs html escaping

On Xubuntu 15.10, emacs 24.5.1, alert 20151123.759 from melpa, an alert that goes through 'notifications gives an empty (textless) alert if it contains "<", but if I change that to "<" it shows fine. The "<" of course shows fine when using 'message style, and indeed (notifications-notify :body "<") gives an empty alert, while (notifications-notify :body "&lt;") shows the "<".

Use `notifications-notify`, not `notify-send` command?

Since emacs 24.1 (at least?), emacs supports alerting via dbus directly, rather than using notify-send. It would, I believe, be easy to replace or enhance the libnotify alerts to use notifications.el directly, rather than using notify-send.

I am happy to implement this. Is there a reason to retain the old use of notify-send, though? For instance to support emacs older than 24.1?

not working well with notifier style

When I start emacs in terminal, the notifier style works well. If I start emacs in gui mode, it fails.

Describe Variable output:

alert-notifier-command is a variable defined in ‘alert.el’.
Its value is nil
Original value was
"/usr/local/bin/terminal-notifier"

This variable may be risky if used as a file-local variable.

Documentation:
Path to the terminal-notifier command.
From https://github.com/julienXX/terminal-notifier.

You can customize this variable.

Additional info:

(executable-find "terminal-notifier")
;; output is /usr/local/bin/terminal-notifier

I'm pretty sure that I have not set alert-notifier-command variable manually, and no package set it

~/.emacs.d/elpa > ag 'alert-notifier-command'
alert-20180827.422/alert.el
837:(defcustom alert-notifier-command (executable-find "terminal-notifier")
851:  (if alert-notifier-command
856:        (apply #'call-process alert-notifier-command nil nil nil args))
~/.emacs.d/elpa > cat ~/.emacs | grep "alert-notifier-command"

Version:

  • My OS is macOS 10.13.4.
  • Emacs Version is 26.1.1
  • alert version is alert-20180827.422

alert-fade-time not working with osx-notifier

I'm able to generate native OSX alerts without a problem by setting alert-default-style to osx-notifier. However, the generated alerts always remain in place for the same fixed length of time, regardless of the value of alert-fade-time. Is this user option not supposed to work for OSX notifications?

two 'ignore styles?

Why are there two styles named 'ignore? That is,

alert/alert.el

Line 452 in 1f3c954

(alert-define-style 'ignore :title "Ignore Alert"

and

alert/alert.el

Line 535 in 1f3c954

(alert-define-style 'ignore :title "Don't display alerts")

(seems like either a bug or something in need of a comment …)

terminal-notifier style notification never shows

terminal-notifier style notification is never displayed but is added to the Notification Center in OS X. The behavior is like I have Do Not Disturb enabled even when I don't. A notification does correctly display when I invoke terminal-notifier directly via async-shell-command.

Mac OS Version: macOS Sierra
Emacs version: 25.1.1
Alert version: 1.2

alert-add-rule example :persistent key does not work, :status not in base-info

It seems like the :peristent example in

alert/alert.el

Line 101 in d085f70

;; (alert-add-rule :status '(buried visible idle)
doesn't work. The info never has any :status to refer to.

alert/alert.el

Line 1029 in d085f70

(let ((base-info (list :message message
sets base-info to a list that doesn't include any :status, and then the function from the :persistent key is called on base-info:

alert/alert.el

Line 1052 in d085f70

(funcall persist-p base-info)

Would it be possible to just add that key to base-info? Perhaps

alert/alert.el

Line 1079 in d085f70

(memq current-buffer-status (cdr condition)))
could also check against base-info then, instead of the separate local variable current-buffer-status.

Add a windows desktop style desktop notification

Hello,
Thank you for your amazing package.
In your README you suggested using the notifications package for desktop notifications.

However your package seems to be used by some popular packages out there, like org-alert for example.
Would it be possible to include a built-in style for windows desktop notifications ?

As an example (i'm an elisp newbie), here is what I ended up doing in my own init.el, using the built-in w32-notification-notify

(use-package alert
  :config
  ;; Add the windows desktop notifications if on windows
  (when (eq system-type 'windows-nt)
    (alert-define-style
     'windows-desktop-notification-style
     :title "Windows Desktop Notification style"
     :notifier
     (lambda (info)
       (let ((notif-id (w32-notification-notify :title (plist-get info :title) :body (plist-get info :message))))
         ;; Close it after 3 seconds (no new notification can be sent if left unclosed)
         (run-with-timer 3 nil `(lambda() (w32-notification-close ,notif-id))))))
    (setq alert-default-style 'windows-desktop-notification-style)))

Thank you for your amazing work for the emacs community

terminal-notifier style doesn't work

At work, I'm using Emacs for Mac OS X. I installed terminal-notifier using brew, and I cannot get my library to emit notifications using the terminal-notifier style provided by alert, everything I get on Message buffer is this:

hola mundo
[nil 22209 57989 289983 nil alert-remove-when-active (alert-message-remove (:message "hola mundo" :title "*scratch*" :icon nil :severity normal :category nil :buffer #<buffer *scratch*> ...)) nil 0]

Any idea what's going on? thanks!

:persistent doesn't work with libnotify

When I set

(setq alert-default-style 'libnotify)

and then run

(alert "something" :persistent t)

notification is shown, but it disappears after I guess alert-fade-time.
But if I pass :style explicitly it works just fine.

(alert "something" :persistent t :style 'libnotify)

It looks like it shoudn't be like this.

post-command-hook alert-remove-on-command should not act during eval-expression

One minor issue is that [...] 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.

( via #58 (comment) )

I believe this is not documented and somewhat confusing when testing any style that uses an :remover.

Is it possible to wrap the post-command-hook in run-with-timer or similar to fix the issue?

Code, comments and README.md give inconsistent accounts of available notification types

The code comments list the following types of notification

;;   message   - Uses the Emacs `message' facility
;;   log       - Logs the alert text to *Alerts*, with a timestamp
;;   ignore    - Ignores the alert entirely
;;   fringe    - Changes the current frame's fringe background color
;;   growl     - Uses Growl on OS X, if growlnotify is on the PATH
;;   libnotify - Uses libnotify if notify-send is on the PATH
;;   notifier  - Uses terminal-notifier on OS X, if it is on the PATH

While README.md lists these types:

| message       | Uses the Emacs `message` facility                                 |
| log           | Logs the alert text to *Alerts*, with a timestamp                 |
| ignore        | Ignores the alert entirely                                        |
| fringe        | Changes the current frame's fringe background color               |
| growl         | Uses Growl on OS X, if growlnotify is on the PATH                 |
| gntp          | Uses gntp, it requires [gntp.el](https://github.com/tekai/gntp.el)|
| notifications | Uses notifications library via D-Bus                              |

while (mapcar 'car alert-styles) yields:

(fringe gntp growl ignore ignore libnotify log message notifications notifier toaster)

osx-notifier isn't working

I've tried to show alert using sox-notifier and got this error:

Debugger entered--Lisp error: (file-error "Searching for program" "no such file or directory" "osascript -e 'display notification \"test\" with title \".emacs\"'")
  call-process("osascript -e 'display notification \"test\" with title \".emacs\"'")
  apply(call-process "osascript -e 'display notification \"test\" with title \".emacs\"'")
  alert-osx-notifier-notify((:message "test" :title ".emacs" :icon nil :severity normal :category nil :buffer #<buffer .emacs> :mode emacs-lisp-mode :data nil))
  alert-send-notification(#<buffer .emacs> (:message "test" :title ".emacs" :icon nil :severity normal :category nil :buffer #<buffer .emacs> :mode emacs-lisp-mode :data nil) (:title "Notify using native OSX notification" :notifier alert-osx-notifier-notify))
  alert("test")
  eval((alert "test") nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-seep)

I've fixed it with

defun alert-osx-notifier-notify (info)
  (apply #'call-process "osascript" nil nil nil "-e" (list (format "display notification %S with title %S"
                (alert-encode-string (plist-get info :message))
                (alert-encode-string (plist-get info :title)))))
  (alert-message-notify info))

but I'm new to emacs and ELisp and I'm not sure that it's a right way to go.
Would you like to get a PR?

alert broken using growl on Windows

Edit:

The core of the problem seems to be that this code:

(eq (plist-get '(:message "test" :title "test" :severity (quote urgent)) :severity)  (quote urgent))

returns nil when I'd expect it (and apparently others) to return t.

first I'd like to note that I lost quite a bit of time due to the error for not finding an executable being silent

my problem is that alerts using growl for windows are not working for me

this works

  (apply #'call-process "c:/Program Files (x86)/Growl for Windows/growlnotify.exe" nil nil nil (list "test"))
0

substituting the path with executable-find still works

  (apply #'call-process (executable-find "growlnotify") nil nil nil (list "test"))
0

this doesn't work

  (require 'alert)
  (alert-growl-notify '(:message "test message" :title "test title" :severity 'urgent))
just returns message text and no growl notification pops up

I traced this down to a problem an assq call

here are resultes from the message buffer

Result: "c:/Program Files (x86)/Growl for Windows/growlnotify.exe"
 [5 times]
Result: (:message "test message" :title "test title" :severity 'urgent)

Result: "test title"

Result: "test title"
 [3 times]
Result: (:message "test message" :title "test title" :severity 'urgent)

Result: "test message"

Result: "test message"
 [5 times]
Result: (:message "test message" :title "test title" :severity 'urgent)

Result: 'urgent

Result: ((urgent . 2) (high . 2) (moderate . 1) (normal . 0) (low . -1) (trivial . -2))

Result: nil

Result: nil

Wrong type argument: numberp, nil

I tried to replicate the assq call

assq on alert-growl-priorities

  (assq 'urgent alert-growl-priorities)
(urgent . 2)

cdr on that result

  (cdr '(urgent . 2))
2

but when I run the function or execute code within the debugging context assq fails

any ideas why?

test

  (apply #'call-process (executable-find "growlnotify") nil nil nil (list "test"))
0

Alert always labels libnotify notifications as transient

Per #21 and #22, libnotify notifications are always labeled as transient. In the new release of dunst,transient notifications are no longer added to history, so there should be an option to turn transient notifications on or off.

https://dunst-project.org/changelog/

Is a variable a good enough way to configure this, or is there a better way to add this? I'm willing to implement this myself, if I know what the best way to add the setting to alert. I don't like adding a new key argument to the alert function myself.

Getting copyright assignments before inclusion into Emacs

@myuhe @hexmode @lurdan @iqbalansari @purcell @fgallina @IvanMalison

To everyone who has contributed code to alert: I would like to include use
package in the next version of Emacs, but to do so, I need copyright
assignment forms to be signed by anyone who has added code to alert. If you do
not wish to sign such a copyright assignment form, let me know so that I can
find a way to back out any changes you may have made.

It's quite possible that due to recent code rewrites, your change may not
appear anymore. If that is the case, I only ask that you verify this, so I can
take you off of the list of people I need assignment forms from.

Thank you!

John

Lint warnings

FYI, The following warnings are displayed for the *.el file

*** Lint Emacs 24.3.1 2013-06-25 13:50:53 file: alert.el

** Lint M-x lm-verify (list-mnt.el)
Missing: ;; Maintainer:
Missing: ;; URL:
Missing: ;;; History:
Missing: ;;; Code:

** Lint M-x checkdoc-current-buffer (checkdoc.el)
alert.el:232: All variables and subroutines might as well have a documentation string
alert.el:253: All variables and subroutines might as well have a documentation string
alert.el:359: Argument `name' should appear (as NAME) in the doc string
alert.el:488: All variables and subroutines might as well have a documentation string
alert.el:495: All variables and subroutines might as well have a documentation string
alert.el:504: All variables and subroutines might as well have a documentation string
alert.el:517: All variables and subroutines might as well have a documentation string
alert.el:524: All variables and subroutines might as well have a documentation string
alert.el:533: All variables and subroutines might as well have a documentation string
alert.el:537: All variables and subroutines might as well have a documentation string
alert.el:561: All variables and subroutines might as well have a documentation string
alert.el:564: All variables and subroutines might as well have a documentation string
alert.el:589: All variables and subroutines might as well have a documentation string
alert.el:600: All variables and subroutines might as well have a documentation string
alert.el:622: All variables and subroutines might as well have a documentation string
alert.el:631: All variables and subroutines might as well have a documentation string
alert.el:646: All variables and subroutines might as well have a documentation string
alert.el:657: All variables and subroutines might as well have a documentation string

terminal-notifier callback to focus alerting buffer

The terminal-notifier command accepts an argument, "execute", that is an arbitrary command to execute when the user clicks on the notification popup it generates. This argument could be leveraged to activate the buffer that issued the alert command (or execute arbitrary emacs code) using the emacsclient -e command. The following has allowed me to pull up the alerting buffer by clicking a notification in my preliminary testing:

(defun alert-notifier-notify (info)
  (message "%s" info)
  (if alert-notifier-command
      (let ((args
             (list "-title"   (alert-encode-string (plist-get info :title))
                   ;;"-sender"  "org.gnu.Emacs"
                   "-message" (alert-encode-string (plist-get info :message))
                   "-execute" (switch-to-buffer-command (plist-get info :buffer)))))
        (apply #'call-process alert-notifier-command nil nil nil args))
    (alert-message-notify info)))

(defun switch-to-buffer-command (buffer-name)
  (emacsclient-command (format "(switch-to-buffer \\\"%s\\\")" buffer-name)))

(defun emacsclient-command (command)
  (format "\"emacsclient --server-file='%s' -e '%s'\"" server-name command))

The main problems with this approach are the brittleness of relying on server-name, and the fact that sender has to be removed for some odd reason.

Would it be worth it to include something like this in the main repository? Perhaps it could be an optional piece of functionality that would have to be explicitly enabled?

`libnotify` style fails if the category is specified as a string

Easiest way to reproduce this is as follows

(setq alert-default-style 'libnotify)
(alert "test" :category "test")

Evaluating the above fails with the following

(wrong-type-argument stringp t)
call-process("/usr/bin/notify-send" nil (#<buffer libnotify output> t) nil "--icon" "..." "--app-name" "Emacs" "--hint" "int:transient:1" "--urgency" "normal" "--category" t "scratch" "test")

'message, 'fringe not working ... logging not happening.

With no extra configuration nothing seem to work as expected. Logging is not happening. Here is what I do:

(require 'package)
(add-to-list 'package-archives
         '("melpa" . "http://melpa.org/packages/") t)
(setq package-user-dir "~/Dropbox/ELPA")
(package-initialize)

(require 'alert)
(alert "blabla" :style 'fringe) ;; nothing 
(alert "blabla" :style 'message) ;; nothing

M-x alert--log-open-log says [Log4E] Not exist log buffer..

Is this project abandoned? Issue tracker seem to suggest so.

GNU Emacs 25.0.93.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.7) of 2016-04-24

Minor mode to allow users to override the builtin `notifications-notify` command with `alert`?

An issue I've come across in a few different packages now is that they use the builtin notifications library. But as far as I know, this doesn't work on macOS. As suggested here, this can be solved with define-advice:

(define-advice notifications-notify
    (:override (&rest params) using-alert)
  (alert (plist-get params :body)
         :title (plist-get params :title)))

In that same comment, the author suggested a minor-mode that would enable this configuration for you. What do you think about this? While I could just copy this snippet into my config, I feel like this affects a wide variety of packages and users, so a minor mode might make sense.

invalid-function: log4e:deflogger

On Emacs 28/master I get:

Debugger entered--Lisp error: (invalid-function log4e:deflogger)
  log4e:deflogger("alert" "%t [%l] %m" "%H:%M:%S")
  alert-log-notify((:message "This is an alert" :title "*Messages*" :icon nil :severity normal :category nil :buffer #<buffer *Messages*> :mode messages-buffer-mode :id nil :data nil))
  alert("This is an alert")
  eval((alert "This is an alert") t)
  eval-expression((alert "This is an alert") nil nil 127)
  funcall-interactively(eval-expression (alert "This is an alert") nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

When I attempt to M-: (alert "This is an alert")

Please specify license.

I would like to package this and use it as part of other applications. Explicitly providing a license to allow for such use would be beneficial.

Thanks.

Please tag a release

Version 1.2 is almost two years and 22 commits old, including some important bug fixes (Eg, 80374af). Could you please tag a release, so that people who get alert from melpa-stable get the bugfixes?

Also, since Emacs 25.x now has package-archive-priorities, tagged releases for all packages are not needed anymore for people who prefer Melpa Stable. Hence, deleting all the release tags is also an option, alert will then be removed from stable, but properly configured recent Emacs will be able to fallback to Melpa. (Alhough I can't confirm deleting tags is enough to remove a package from Melpa Stable, I believe it can be safely assumed.)

Thanks a lot,
Thibault

`alert-log-messages` and packages.

I was poking at some old configs and I saw alert-log-messages which claims that, when non-nil will cause alerts to go to Alerts. Huh, I use alerts sometimes, and have had this setting for years and I've never seen an *Alerts* buffer. So I did some digging.

It looks like this *Alerts* is a legacy behavior implemented in alert-legacy-log-notify which only runs when log4e isn't installed, which can't happen (I think) if you install alert as a package because log4e always gets pulled in as a dependency.

I managed to do a little big of hacking to my elpa directory and get it to work, and then in the course of writing up this ticket I managed to figure out how to get log4e to work.

I'm not sure what the "right" thing to do here is:

  • I think it'd be reasonable to unwind log4e. I personally don't use it for anything else, and (maybe this is a generational thing) but I also haven't really used log4<x> before and I don't find it super obvious, and I don't really feel like I need a special (optional) logging package that I don't otherwise use, for a really simple alert package (that I do use.)
  • To be honest, I think i'd be fine if, when alert-log-messages is non-nil, we could just call (message (format "[alert:%s] %s" (format-time "%02H:%02M") alert-msg)) and call it good? I don't know that the extra buffer is what I want, and the name of the variable (to me) implies the messages buffer?
  • If we really like log4e, I think it'd be nice to either (both?) document the way to use it (change the variable's docstring, etc.) and also maybe wrap alert--log-open-log (and friends) in something that seems less "internal" (the --) or is more clearly named for manipulation. I certainly had to poke around a lot to find this.
  • Also having spent a lot of time in this code, it seems like we're ending up calling the log4e:deflogger macro potentially for every message. This is probably fine and works as intended, but I think left to my own devices I'd have a variable or struct in the package that would store the log4e logger and functions? I mean, reasonably speaking I think storing a function pointer/message function for this logging (which could be log4e or just message seems reasonable to me? I'm not suggesting you leave me to my devices though.

Thoughts? I'm willing to do a little work to sand off this rough corner, but wouldn't want to begin making changes without some kind of initial agreement. 😄

[FR] Add severity "emoji icons"

While tinkering with #101, I wanted to prepend a custom emoji-based icon to messages with certain severities. As handy as alert-severity-faces and alert-severity-colors are, there is no [customizable] alert-severity-{string|icon|symbol} or similar to use in situations where not all the fancy graphical features are available.
Something along to 🔥 for urgent and ⚠️ for high would do.
I guess I might end up implementing it anyway. But, instead of making it a feature only for tmux alert styles, I thought it could be potentially useful in other alert styles.
So far, just dropping the idea. Comments and feedback welcome.

Subtitle property?

Could we create a "subtitle" property to display another paragraph with a font size between that of the main title and the content?

image

alert-trivial-face foreground color "Dark Purple" is invalid?

In gonewest818/dimmer.el#6 (comment) a bug was reported that my package dimmer gives errors when alert is also used.

In debugging that, I noticed the underlying issue was this one particular face. The error is that my code computes an adjusted rgb value for each foreground color, but when it calls (color-name-to-rgb "Dark Purple") I get a nil. Which can also be confirmed in that there is no dark purple in list-colors-display.

I will obviously need to be more careful in my code, but I thought you might like to know.

Parameter `:style` is not handled correctly

The parameter :style isn't handled correctly, so the behavior of #'alert is overwritten by the default style for some users. That maybe why some users don't receive system notifications as pointed out in

  1. #74
  2. #47

See the following test.

alert-default-style   ;; => message

(alert "Hi")                                   ;; => It uses message style.
(alert "Hi" :style 'libnotify)                 ;; => It uses message style.
(alert "Hi" :style 'message)                   ;; => It uses message style.

(setq alert-default-style 'libnotify)

(alert "Hi")                                   ;; => It uses libnotify style.
(alert "Hi" :style 'libnotify)                 ;; => It uses libnotify style.
(alert "Hi" :style 'message)                   ;; => It uses libnotify style.

Temporary solution

(setq alert-default-style 'libnotify) ;; Or replace "libnotify" by your favorite style.

Race Condition On mode-line Prevents (Meaningful) Restore

Hi,

Cool product - I use it extensively to build out alerts for Weechat etc.

I've noticed their is no locking/semaphore on the stored original mode-line face. This means that if alert-mode-line-notify if called twice in quick succession, such that the second call occurs before the corresponding call to alert-mode-line-restore occurs from the first call, a race condition occurs.

Ultimately the value persisted by the first call in alert-saved-mode-line-face is overwritten by the first alert's face. At this point the original face is lost and the alert's face is never restored to its original value.

This happens frequently in reality when using alert with Weechat in a busy discussion!

You can actually avoid this using predicates in the user configuration of alerts as shown below.

But unless I've misunderstood how to define model-line alerts, I don't think they are ever useful without the predicate, and so this should probably be implemented in the Lisp code itself?

To reproduce just execute something like:

(alert "This is an alert" :title "Alert" :severity 'high :category 'chat)  
(alert "This is an alert" :title "Alert" :severity 'high :category 'chat)  

With the alert configuration set to mode-line for any "chat" event.

To fix it using only config you can do the below (this assumes Prelude's mode-line face is default):

 '(alert-user-configuration                                                                                                                                                                                                                             
   (quote                                                                                                                                                                                                                                               
    ((((:category . "chat"))                                                                                                                                                                                                                            
      message                                                                                                                                                                                                                                           
      ((:continue . t)))                                                                                                                                                                                                                                
     (((:category . "chat")                                                                                                                                                                                                                             
       (:predicate lambda                                                                                                                                                                                                                               
                   (name)                                                                                                                                                                                                                               
                   (equal                                                                                                                                                                                                                               
                    (face-attribute                                                                                                                                                                                                                     
                     (quote mode-line)                                                                                                                                                                                                                  
                     :foreground)                                                                                                                                                                                                                       
                    "#8FB28F")))                                                                                                                                                                                                                        
      mode-line                                                                                                                                                                                                                                         
      ((:continue . t))))))      

Support for :replaces-id in styles that support it

Say a package shows an alert on unread mail, showing the unread mail count every time the count increases. If I use :style 'notifications and I idle a bit, it might "queue" up a bunch of these and on unidling, I end up with a bunch of "2 unread", "3 unread", "ℵ0 unread" etc.

It'd be nice if we could use the :replaces-id from notifications-notify to replace old ones.

I think a nice API would be simply (alert "2 unread" :id 'my-special-id) and then alert internally does

(puthash 'my-special-id
         (notifications-notify :body "2 unread"
                               :replaces-id (gethash 'my-special-id alert-ids))
         alert-ids)

or something like that.

libnotify alerts always disappears after 5 secs

No matter how I configure alert-fade-time, notifications always seem to disappear after 5 secs. I'm using libnotify on Linux.

E.g. I've set:

(setq alert-fade-time 3600)

But still the alerts disappear.

If I manually call notify-send from the commandline, I can pass through time specification without issue, e.g.:

notify-send -t 60000 "hello world" "goodbye world"

Works as expected.

alert shows nothing

Hello!
Trying to run alert:
(alert "TST")

Context:

  • Windows
  • emacs 25.094,
  • (executable-find "growlnotify") finds correct path

Nothing happens.

Message log:

TST
[nil 22729 14218 34573 nil alert-remove-when-active (alert-message-remove (:message "TST" :title ".spacemacs" :icon nil :severity normal :category nil :buffer #<buffer .spacemacs> :mode emacs-lisp-mode :data nil)) nil 300000]

Probably incorrext system parameters.

Is there instruction how to run alert under windows?

alert-hide-all-notifications doesn't

This sends a message to the minibuffer:

(progn 
  (setq alert-hide-all-notifications t) 
  (run-with-timer 0.5 nil 
    (lambda () 
      (alert "Hidden message!" :severity 'normal :title "Alert from erc" :category 'erc))))

Shouldn't alert-hide-all-notifications mean that the alerts are not shown at all?

Feature request: ability to change app name

Hello!

I've just started using this with Mu4e and mu4e-alert. Thanks for going to the effort to build such a handy library.

I know this may sound somewhat strange, but I'd really appreciate the ability to have the app name be another tweakable parameter. While strictly speaking the "app name" is of course emacs, in my DE: solus, (and I imagine I wouldn't be alone) this parameter seems to be used to sort notifications into per-app blocks.

In this respect, I would quite like to be able to use this to sort alerts from different parts of emacs, i.e. have mu4e in its own section in this example.

alert/alert.el

Line 728 in 7046393

"--app-name" "Emacs"

Thanks for your work!

tecosaur.

tmux-specific alert styles

tmux offers two methods of messaging the user:

  • tmux display-message
  • tmux display-popup

Both are suitable for using as alert method.
Not sure if I'll make it to code it soon, just dumping the idea. Comments welcome.

Multiple styles

Hi,
I have a question - is there an easy way to have combine few styles together? What I mean is that, I would like for some messages to be logged via log4e and also via growl.

alert won't notify via notify-send

Arch linux here, with dunst as a notification manager. My notifications problems are emacs-related only because notify-send "wow" works from a terminal. Still, I get desktop notifications in emacs with (notifications-notify :title "You've got mail!").But not with (alert "This is an alert"), neither with mu4e nor circe.
(alert--log-open-log) sends no particular errors.

I think I have tweaked something bad somewhere because at least, mu4e used to notify my new mail. Alas, I've totally lost my memory about that. Any idea ?

May you please create a tag for release?

Good evening,

Tonight I am writing to humbly put in a request for you to tag this project.

The reason is that a lot of users want to rely on the most "stable" release, by
the most broad definition of the term. For me, it is really simple, I am setting
up a "stable" Emacs configuration of my system here https://github.com/grettke/home/blob/master/.emacs.el
and I would like to rely 100% upon MELPA Stable http://stable.melpa.org/#/ .

I've used your package for a long time, love it, and so do many, many others.
This is a way to get that project out to the other thousands and thousands of
users who also rely upon MELPA stable.

All it takes is for you to create a tag, and within hours, it will show up on
MELPA stable.

Can't wait to hear about what you think and whether or not a tag is in this
project's future!

Kind regards,

Grant Rettke

P.S.

This most has been critical to thousands of us for years.

I can't speak for everyone, but I do feel quite strongly that this is
ready for a "release" at whatever number you version it at.

Notification center is great, but I still like growl.

If alert-user-configuration and alert-internal-configuration are both nil, the :style keyword is ignored

Hi John,

This bit in alert seems fishy:

        (catch 'finish
          (dolist (config (append alert-user-configuration
                                  alert-internal-configuration))
            (let* ((style-def (cdr (assq (or style (nth 1 config))
                                         alert-styles)))

The body of this loop will only run if one of the two alert-*-configuration is non-nil; this means that running (alert "This is an alert" :style 'libnotify) without setting either of these variables will cause the default message backend to be used.

Is this expected?

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.