diff options
| -rw-r--r-- | lisp/filenotify.el | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/lisp/filenotify.el b/lisp/filenotify.el index 4860b4c46a7..e5dc353186d 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el | |||
| @@ -120,10 +120,11 @@ It is nil or a `file-notify--rename' where the cookie can be nil.") | |||
| 120 | (directory-file-name | 120 | (directory-file-name |
| 121 | (expand-file-name file (file-notify--watch-directory watch)))) | 121 | (expand-file-name file (file-notify--watch-directory watch)))) |
| 122 | 122 | ||
| 123 | (defun file-notify--callback-inotify (event) | 123 | (cl-defun file-notify--callback-inotify ((desc actions file |
| 124 | &optional file1-or-cookie)) | ||
| 124 | "Notification callback for inotify." | 125 | "Notification callback for inotify." |
| 125 | (file-notify--handle-event | 126 | (file-notify--handle-event |
| 126 | (car event) | 127 | desc |
| 127 | (delq nil (mapcar (lambda (action) | 128 | (delq nil (mapcar (lambda (action) |
| 128 | (cond | 129 | (cond |
| 129 | ((eq action 'create) 'created) | 130 | ((eq action 'create) 'created) |
| @@ -133,14 +134,14 @@ It is nil or a `file-notify--rename' where the cookie can be nil.") | |||
| 133 | ((eq action 'moved-from) 'renamed-from) | 134 | ((eq action 'moved-from) 'renamed-from) |
| 134 | ((eq action 'moved-to) 'renamed-to) | 135 | ((eq action 'moved-to) 'renamed-to) |
| 135 | ((eq action 'ignored) 'stopped))) | 136 | ((eq action 'ignored) 'stopped))) |
| 136 | (nth 1 event))) | 137 | actions)) |
| 137 | (nth 2 event) | 138 | file file1-or-cookie)) |
| 138 | (nth 3 event))) | ||
| 139 | 139 | ||
| 140 | (defun file-notify--callback-kqueue (event) | 140 | (cl-defun file-notify--callback-kqueue ((desc actions file |
| 141 | &optional file1-or-cookie)) | ||
| 141 | "Notification callback for kqueue." | 142 | "Notification callback for kqueue." |
| 142 | (file-notify--handle-event | 143 | (file-notify--handle-event |
| 143 | (car event) | 144 | desc |
| 144 | (delq nil (mapcar (lambda (action) | 145 | (delq nil (mapcar (lambda (action) |
| 145 | (cond | 146 | (cond |
| 146 | ((eq action 'create) 'created) | 147 | ((eq action 'create) 'created) |
| @@ -148,30 +149,26 @@ It is nil or a `file-notify--rename' where the cookie can be nil.") | |||
| 148 | ((memq action '(attrib link)) 'attribute-changed) | 149 | ((memq action '(attrib link)) 'attribute-changed) |
| 149 | ((eq action 'delete) 'deleted) | 150 | ((eq action 'delete) 'deleted) |
| 150 | ((eq action 'rename) 'renamed))) | 151 | ((eq action 'rename) 'renamed))) |
| 151 | (nth 1 event))) | 152 | actions)) |
| 152 | (nth 2 event) | 153 | file file1-or-cookie)) |
| 153 | (nth 3 event))) | ||
| 154 | 154 | ||
| 155 | (defun file-notify--callback-w32notify (event) | 155 | (cl-defun file-notify--callback-w32notify ((desc actions file |
| 156 | &optional file1-or-cookie)) | ||
| 156 | "Notification callback for w32notify." | 157 | "Notification callback for w32notify." |
| 157 | (let ((action (pcase (nth 1 event) | 158 | (let ((action (pcase actions |
| 158 | ('added 'created) | 159 | ('added 'created) |
| 159 | ('modified 'changed) | 160 | ('modified 'changed) |
| 160 | ('removed 'deleted) | 161 | ('removed 'deleted) |
| 161 | ('renamed-from 'renamed-from) | 162 | ('renamed-from 'renamed-from) |
| 162 | ('renamed-to 'renamed-to)))) | 163 | ('renamed-to 'renamed-to)))) |
| 163 | (when action | 164 | (when action |
| 164 | (file-notify--handle-event | 165 | (file-notify--handle-event desc (list action) file file1-or-cookie)))) |
| 165 | (car event) | ||
| 166 | (list action) | ||
| 167 | (nth 2 event) | ||
| 168 | (nth 3 event))))) | ||
| 169 | 166 | ||
| 170 | (defun file-notify--callback-gfilenotify (event) | 167 | (cl-defun file-notify--callback-gfilenotify ((desc actions file |
| 168 | &optional file1-or-cookie)) | ||
| 171 | "Notification callback for gfilenotify." | 169 | "Notification callback for gfilenotify." |
| 172 | (let ((actions (nth 1 event))) | ||
| 173 | (file-notify--handle-event | 170 | (file-notify--handle-event |
| 174 | (car event) | 171 | desc |
| 175 | (delq nil (mapcar (lambda (action) | 172 | (delq nil (mapcar (lambda (action) |
| 176 | (cond | 173 | (cond |
| 177 | ((memq action | 174 | ((memq action |
| @@ -179,17 +176,12 @@ It is nil or a `file-notify--rename' where the cookie can be nil.") | |||
| 179 | action) | 176 | action) |
| 180 | ((eq action 'moved) 'renamed))) | 177 | ((eq action 'moved) 'renamed))) |
| 181 | (if (consp actions) actions (list actions)))) | 178 | (if (consp actions) actions (list actions)))) |
| 182 | (nth 2 event) | 179 | file file1-or-cookie)) |
| 183 | (nth 3 event)))) | 180 | |
| 184 | 181 | (cl-defun file-notify-callback ((desc actions file &optional file1-or-cookie)) | |
| 185 | ;; Called by file name handlers to deliver a notification. | 182 | "Notification callback for file name handlers." |
| 186 | (defun file-notify-callback (event) | ||
| 187 | "Handle an EVENT returned from file notification. | ||
| 188 | EVENT is the cadr of the event in `file-notify-handle-event' | ||
| 189 | \(DESCRIPTOR ACTIONS FILE [FILE1-OR-COOKIE])." | ||
| 190 | (let ((actions (nth 1 event))) | ||
| 191 | (file-notify--handle-event | 183 | (file-notify--handle-event |
| 192 | (car event) | 184 | desc |
| 193 | ;; File name handlers use gfilenotify or inotify actions. | 185 | ;; File name handlers use gfilenotify or inotify actions. |
| 194 | (delq nil (mapcar | 186 | (delq nil (mapcar |
| 195 | (lambda (action) | 187 | (lambda (action) |
| @@ -207,8 +199,7 @@ EVENT is the cadr of the event in `file-notify-handle-event' | |||
| 207 | ((eq action 'moved-to) 'renamed-to) | 199 | ((eq action 'moved-to) 'renamed-to) |
| 208 | ((eq action 'ignored) 'stopped))) | 200 | ((eq action 'ignored) 'stopped))) |
| 209 | (if (consp actions) actions (list actions)))) | 201 | (if (consp actions) actions (list actions)))) |
| 210 | (nth 2 event) | 202 | file file1-or-cookie)) |
| 211 | (nth 3 event)))) | ||
| 212 | 203 | ||
| 213 | (defun file-notify--call-handler (watch desc action file file1) | 204 | (defun file-notify--call-handler (watch desc action file file1) |
| 214 | "Call the handler of WATCH with the arguments DESC, ACTION, FILE and FILE1." | 205 | "Call the handler of WATCH with the arguments DESC, ACTION, FILE and FILE1." |