diff --git a/lisp/filenotify.el b/lisp/filenotify.el index 9acf7651df5..96c2c46d1df 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el @@ -233,16 +233,18 @@ It is nil or a `file-notify--rename' defstruct where the cookie can be nil.") (and (stringp file1) (string-equal (file-notify--watch-filename watch) (file-name-nondirectory file1)))) - (when file-notify-debug - (message - "file-notify-callback %S %S %S %S %S %S %S" - desc action file file1 watch - (file-notify--watch-absolute-filename watch) - (file-notify--watch-directory watch))) - (funcall (file-notify--watch-callback watch) - (if file1 - (list desc action file file1) - (list desc action file))))) + ;; The callback could have removed in `file-notify--rm-descriptor'. + (when (file-notify--watch-callback watch) + (when file-notify-debug + (message + "file-notify-callback %S %S %S %S %S %S %S" + desc action file file1 watch + (file-notify--watch-absolute-filename watch) + (file-notify--watch-directory watch))) + (funcall (file-notify--watch-callback watch) + (if file1 + (list desc action file file1) + (list desc action file)))))) (defun file-notify--handle-event (desc actions file file1-or-cookie) "Handle an event returned from file notification.