Subject: 28.2; `file-notify--handle-event` setting callback function to nil
From: Alejandro Pérez Carballo <[email-masked]>
To: [email-masked]
Date: Wed, 02 Nov 2022 08:41:38 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

The following minimal configuration can be used to trigger the bug on my
end, replacing “~/tmp/test.el” with a path to a file of your choice:

    (require 'filenotify)
    (require 'autorevert)
    (require 'subr-x)
    (global-auto-revert-mode)
    
    (save-window-excursion
      (find-file "~/tmp/test.el"))

Once that’s loaded, calling this:

    (file-notify--handle-event (car (hash-table-keys file-notify-descriptors)) '(renamed attribute-changed deleted) (expand-file-name "~/tmp/test.el") nil)

gives me an error

    file-notify--call-handler: Symbol’s function definition is void: nil

Here’s the backtrace:

    Debugger entered--Lisp error: (void-function nil)
      nil((18 attribute-changed "/Users/apc/tmp/test.el"))
      file-notify--call-handler(#s(file-notify--watch :directory "/Users/apc/tmp" :filename "test.el" :callback nil) 18 attribute-changed "/Users/apc/tmp/test.el" nil)
      file-notify--handle-event(18 (renamed attribute-changed deleted) "/Users/apc/tmp/test.el" nil)
      (progn (file-notify--handle-event (car (hash-table-keys file-notify-descriptors)) '(renamed attribute-changed deleted) (expand-file-name "~/tmp/test.el") nil))
      eval((progn (file-notify--handle-event (car (hash-table-keys file-notify-descriptors)) '(renamed attribute-changed deleted) (expand-file-name "~/tmp/test.el") nil)) t)
      elisp--eval-last-sexp(nil)
      eval-last-sexp(nil)
      funcall-interactively(eval-last-sexp nil)
      call-interactively(eval-last-sexp nil nil)
      command-execute(eval-last-sexp)

Unfortunately, I cannot figure out at which step is `nil` being passed as the value of `:callback`.

In GNU Emacs 28.2 (build 1, x86_64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.5 (Build 21G72))
 of 2022-09-13 built on APCiMacwork.local
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.6

Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs-plus@28/28.2/share/info/emacs
 --prefix=/usr/local/Cellar/emacs-plus@28/28.2 --with-xml2 --with-gnutls
 --without-dbus --without-imagemagick --with-modules --with-rsvg
 --with-ns --disable-ns-self-contained 'CFLAGS=-Os -w -pipe
 -march=nehalem -mmacosx-version-min=12
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 'CPPFLAGS=-I/usr/local/opt/icu4c/include
 -I/usr/local/opt/[email-masked]/include -I/usr/local/opt/readline/include
 -F/usr/local/Frameworks
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 'LDFLAGS=-L/usr/local/opt/icu4c/lib -L/usr/local/opt/[email-masked]/lib
 -L/usr/local/opt/readline/lib -L/usr/local/lib -F/usr/local/Frameworks
 -Wl,-headerpad_max_install_names
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM ZLIB

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

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win 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 cl-generic 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 simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 51202 7299)
 (symbols 48 6554 1)
 (strings 32 18351 1706)
 (string-bytes 1 613349)
 (vectors 16 13830)
 (vector-slots 8 191781 15356)
 (floats 8 21 42)
 (intervals 56 275 0)
 (buffers 992 10))