From 07a276da6f2721e34c4edc9bbfeb22ba83d008cd Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 27 Sep 2021 20:35:31 +0200 Subject: [PATCH] Simplify `file-notify--rm-descriptor' * lisp/filenotify.el (file-notify--rm-descriptor): Use `file-notify-handle-event'. --- lisp/filenotify.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lisp/filenotify.el b/lisp/filenotify.el index a0c37582386..e0dceb704d5 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el @@ -76,16 +76,17 @@ struct.") "Remove DESCRIPTOR from `file-notify-descriptors'. DESCRIPTOR should be an object returned by `file-notify-add-watch'. If it is registered in `file-notify-descriptors', a `stopped' event is sent." - (when-let* ((watch (gethash descriptor file-notify-descriptors))) - (let ((callback (file-notify--watch-callback watch))) - ;; Make sure this is the last time the callback is invoked. + (when-let ((watch (gethash descriptor file-notify-descriptors))) + (unwind-protect + ;; Send `stopped' event. + (file-notify-handle-event + (make-file-notify + :-event `(,descriptor stopped + ,(file-notify--watch-absolute-filename watch)) + :-callback (file-notify--watch-callback watch))) + ;; Make sure this is the last time the callback was invoked. (setf (file-notify--watch-callback watch) nil) - ;; Send `stopped' event. - (unwind-protect - (funcall - callback - `(,descriptor stopped ,(file-notify--watch-absolute-filename watch))) - (remhash descriptor file-notify-descriptors))))) + (remhash descriptor file-notify-descriptors)))) (cl-defstruct (file-notify (:type list) :named) "A file system monitoring event, coming from the backends." -- 2.39.5