alphapapa / hammy.el

Programmable, interactive interval timers (e.g. for working/resting)
GNU General Public License v3.0
141 stars 6 forks source link

Error running timer ‘hammy-next’: (void-variable --cl-cancel-reminder--) #19

Closed jingchengx closed 10 months ago

jingchengx commented 10 months ago

I'm encountering a weird bug: the error message in the title appears whenever the hammy is supposed to advance.

Minimal reproducible example: With the following init.el, do M-x hammy-start RET test RET, wait for 3 seconds and the error message will appear.

However if the :config portion is removed in the init.el and I manually eval (hammy-define ...) then there is no error. Also the predefined hammies work fine always.

init.el:

;; Package configs
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives
      '(
    ("GNU ELPA"     . "http://elpa.gnu.org/packages/")
        ("MELPA Stable" . "https://stable.melpa.org/packages/")
        ("MELPA"        . "https://melpa.org/packages/")
        )
      package-archive-priorities
      '(("MELPA Stable" . 0)
        ("GNU ELPA"     . 5)
        ("MELPA"        . 10)))
(package-initialize)

;; Bootstrap `use-package`
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)

(use-package hammy :ensure t
  :config
  (hammy-define "test"
    :intervals
    (list
     (interval :name "Working"
           :duration "3 seconds"
           :before (do (announce "Starting work time."))
           :advance (remind "2 seconds"
                (do (announce "Break time!")
                    (notify "Break time!"))))
     (interval :name "Resting"
           :duration "3 seconds"
           :before (do (announce "Starting break time.")
                           (notify "Starting break time."))
           :advance (remind "4 seconds"
                (do (announce "Break time is over!")
                                    (notify "Break time is over!"))))))
  )

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages '(hammy)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

report-emacs-bug:

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
cairo version 1.17.8)
System Description: Arch Linux

Configured using:
 'configure --with-pgtk --with-native-compilation=aot --sysconfdir=/etc
 --prefix=/usr --libexecdir=/usr/lib --with-tree-sitter
 --localstatedir=/var --with-cairo --disable-build-details
 --with-harfbuzz --with-libsystemd --with-modules 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2
 -Wformat -Werror=format-security -fstack-clash-protection
 -fcf-protection -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto'
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto'
 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug dired-aux mule-util display-line-numbers
cus-edit pp cus-start cus-load wid-edit hammy notifications dbus ts
org-macs format-spec hammy-autoloads svg-lib color svg dom xml
svg-lib-autoloads pcase comp comp-cstr warnings icons s dash
ts-autoloads rx info dash-autoloads compile comint ansi-osc ansi-color
ring s-autoloads loaddefs-gen lisp-mnt radix-tree tar-mode arc-mode
archive-mode gnutls mm-archive message sendmail yank-media dired
dired-loaddefs rfc822 mml mml-sec epa derived gnus-util
text-property-search time-date mailabbrev gmm-utils mailheader mm-decode
mm-bodies mm-encode mail-utils network-stream url-cache url-http
url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr url-gw nsm puny epg rfc6068 epg-config cl-extra help-mode
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core finder-inf
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 466080 28977)
 (symbols 48 20233 0)
 (strings 32 138423 4735)
 (string-bytes 1 3339218)
 (vectors 16 38411)
 (vector-slots 8 683299 42303)
 (floats 8 205 274)
 (intervals 56 1311 0)
 (buffers 984 22))
alphapapa commented 10 months ago

This kind of error indicates a macro-expansion failure, which usually indicates an installation problem.

However, in this case, you may be encountering a problem which I have sometimes seen and don't yet fully understand.

If it ever happens to me, I'm able to solve it by re-evaluating the hammy-define form.

It may also be possible that adding :init (hammy-mode) to the use-package form solves the problem; I can't recall seeing it since I added that. Of course, that would be a side-effect of that change; AFAICT the solution is to ensure that the hammy-define macro is loaded before the hammy-define form is expanded inside the use-package form. And AFAIK the code in the :config section should only be evaluated after the package is loaded, which should take care of that. However, some of the code gets wrapped in lambdas, which might affect the expansion. So you might also be able to solve it with :demand t added to the use-package form.

jingchengx commented 10 months ago

Thanks! I've tried the following but none of them is working so far:

  1. :demand t
  2. :init (hammy-mode)
  3. re-eval hammy-define form

I suspect it is caused by native compilation, but have no time to dig further for now. Thanks again for the help.

alphapapa commented 10 months ago

Native compilation shouldn't have anything to do with it, because macro expansion happens at an earlier stage of compilation. Anyway, if you ever figure it out, please let me know. Thanks.