Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No notifications - events seemingly not retrieved properly #61

Open
mcs0042 opened this issue Oct 28, 2022 · 1 comment
Open

No notifications - events seemingly not retrieved properly #61

mcs0042 opened this issue Oct 28, 2022 · 1 comment

Comments

@mcs0042
Copy link

mcs0042 commented Oct 28, 2022

First, thank you for your work on this package!

I've been trying to get it set up in my config and I've run into a bit of an issue: although I can get the package installed just fine, emacs doesn't seem to be sending out notifications for org events! I've tried, among other things, adding the "chocolate factory" example from the README (with the timestamp adjusted, of course) to one of my org agenda files, but I don't see notifications at any time.

Evaluating (alert "test") results in a desktop notification as desired. I thought it might have been due to another org-mode package in my config file, so I tried running emacs -Q and evaluating the following code to get org-wild-notifier installed:

(setq straight-check-for-modifications '(check-on-save find-when-checking))

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

(setq org-agenda-files (list "~/org/" "~/org/dailies/"))

(use-package org-wild-notifier)
(setq alert-default-style 'libnotify)
(org-wild-notifier-mode)

The results were the same as in my usual config.

I poked around in the source code a bit and was surprised by the behavior of the following block, lines 265-271 in org-wild-notifier.el at the time of writing:

(--map
 (org-map-entries
  (lambda ()
    (push (org-entry-properties) entries))
  (format "%s>\"<today>\"+%s<\"<+2d>\"" it it)
  'agenda)
 '("DEADLINE" "SCHEDULED" "TIMESTAMP"))

I tried evaluating the following code separately:

(let ((entries)) 
  (--map
   (org-map-entries
    (lambda ()
      (push (org-entry-properties) entries))
    (format "%s>\"<today>\"+%s<\"<+2d>\"" it it)
    'agenda)
   '("DEADLINE" "SCHEDULED" "TIMESTAMP")))

The output was:

(nil (((... ... ... ... ... ... ... ...))) (((... ... ... ... ... ...) (... ... ... ... ... ... ... ...)) ((... ... ... ... ... ...) (... ... ... ... ... ...) (... ... ... ... ... ... ... ...)) ((... ... ... ... ... ...) (... ... ... ... ... ...) (... ... ... ... ... ...) (... ... ... ... ... ... ... ...)) ((... ... ... ... ... ... ...) (... ... ... ... ... ...) (... ... ... ... ... ...) (... ... ... ... ... ...) (... ... ... ... ... ... ... ...))))

I didn't expect this behavior (to be fair, I don't understand the source code super well), so I thought it would be worth mentioning in the issue. This happened when using the "minimal working example" above as well as when using my default emacs config.

EDIT: I tried running the code using ielm rather than M-S-; and the output was reasonable. I realize now that the strange output above is likely just a truncated version of the full output! Oops . . . .

Other things that are probably worth mentioning:

  • OS: NixOS.
  • Emacs version: 29.0.50 (pure GTK, native compilation).
  • Notification daemon: Dunst.

Please let me know if there's any additional information that I can provide that would make debugging easier!

@mcs0042
Copy link
Author

mcs0042 commented Oct 28, 2022

I've made some partial progress on this. First, it seems like org-wild-notifier--apply-whitelist is filtering things out too aggressively, at least when org-wild-notifier-keyword-whitelist is left at its default value: seemingly, all events are filtered out, even ones with TODOs (including the chocolate factory example). I'm not sure why this is the case at the moment. This particular issue doesn't seem to be present when org-wild-notifier-keyword-whitelist is set to nil.

Second, in the function org-wild-notifier--extract-notication-intervals, it looks like 'string-to-number is being mapped over a space-delimited string of digits (e.g., "80 60 55 43 5") instead of a list, which results in an error. The error goes away when we split the string first by redefining org-wild-notifier--extract-notication-intervals as follows:

(defun org-wild-notifier--extract-notication-intervals (event)
  "Extract notification intervals from the event's properties.
Resulting list also contains standard notification
interval (`org-wild-notifier-alert-time')."
  `(,@(-flatten (list org-wild-notifier-alert-time))
    ,@(-map 'string-to-number
            (let ((times
                   (cdr (assoc org-wild-notifier-alert-times-property event))))
              (if times
                  (split-string times)
                nil)))))

In summary: if I set org-wild-notifier-keyword-whitelist to nil and modify org-wild-notifier--extract-notication-intervals as above, org-wild-notifier sends out notifications as expected; however, if org-wild-notifier-keyword-whitelist is left at its default value, no notifications are sent out, even for events with TODOs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant