diff options
| author | Michael Albinus | 2015-11-08 15:22:09 +0100 |
|---|---|---|
| committer | Michael Albinus | 2015-11-08 15:22:09 +0100 |
| commit | 82c1b368a227ca710e3582be311f2cbabc33499f (patch) | |
| tree | 0b2e626b097d7c137c50bca87f74670c3b22d007 | |
| parent | d5f110e369bce08ea23b60225f0c9534af2f6c4b (diff) | |
| download | emacs-82c1b368a227ca710e3582be311f2cbabc33499f.tar.gz emacs-82c1b368a227ca710e3582be311f2cbabc33499f.zip | |
Fix Bug#21841
* lisp/filenotify.el (file-notify--rm-descriptor):
Use `descriptor' instead of computing its value.
(file-notify--descriptor): Additional argument FILE. Adapt all callees.
(file-notify-rm-watch): Use `descriptor' when calling file name handler.
(Bug#21841)
| -rw-r--r-- | lisp/filenotify.el | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/lisp/filenotify.el b/lisp/filenotify.el index 132f1644f8f..4c5d43fb44e 100644 --- a/lisp/filenotify.el +++ b/lisp/filenotify.el | |||
| @@ -62,7 +62,7 @@ WHAT is a file or directory name to be removed, needed just for `inotify'." | |||
| 62 | ;; Send `stopped' event. | 62 | ;; Send `stopped' event. |
| 63 | (dolist (entry (cdr registered)) | 63 | (dolist (entry (cdr registered)) |
| 64 | (funcall (cdr entry) | 64 | (funcall (cdr entry) |
| 65 | `(,(file-notify--descriptor desc) stopped | 65 | `(,descriptor stopped |
| 66 | ,(or (and (stringp (car entry)) | 66 | ,(or (and (stringp (car entry)) |
| 67 | (expand-file-name (car entry) dir)) | 67 | (expand-file-name (car entry) dir)) |
| 68 | dir)))) | 68 | dir)))) |
| @@ -123,14 +123,17 @@ This is available in case a file has been moved." | |||
| 123 | ;; `inotify' returns the same descriptor when the file (directory) | 123 | ;; `inotify' returns the same descriptor when the file (directory) |
| 124 | ;; uses the same inode. We want to distinguish, and apply a virtual | 124 | ;; uses the same inode. We want to distinguish, and apply a virtual |
| 125 | ;; descriptor which make the difference. | 125 | ;; descriptor which make the difference. |
| 126 | (defun file-notify--descriptor (descriptor) | 126 | (defun file-notify--descriptor (desc file) |
| 127 | "Return the descriptor to be used in `file-notify-*-watch'. | 127 | "Return the descriptor to be used in `file-notify-*-watch'. |
| 128 | For `gfilenotify' and `w32notify' it is the same descriptor as | 128 | For `gfilenotify' and `w32notify' it is the same descriptor as |
| 129 | used in the low-level file notification package." | 129 | used in the low-level file notification package." |
| 130 | (if (and (natnump descriptor) (eq file-notify--library 'inotify)) | 130 | (if (and (natnump desc) (eq file-notify--library 'inotify)) |
| 131 | (cons descriptor | 131 | (cons desc |
| 132 | (car (cadr (gethash descriptor file-notify-descriptors)))) | 132 | (and (stringp file) |
| 133 | descriptor)) | 133 | (car (assoc |
| 134 | (file-name-nondirectory file) | ||
| 135 | (gethash desc file-notify-descriptors))))) | ||
| 136 | desc)) | ||
| 134 | 137 | ||
| 135 | ;; The callback function used to map between specific flags of the | 138 | ;; The callback function used to map between specific flags of the |
| 136 | ;; respective file notifications, and the ones we return. | 139 | ;; respective file notifications, and the ones we return. |
| @@ -210,9 +213,11 @@ EVENT is the cadr of the event in `file-notify-handle-event' | |||
| 210 | (car file-notify--pending-event))) | 213 | (car file-notify--pending-event))) |
| 211 | ;; If the source is handled by another watch, we | 214 | ;; If the source is handled by another watch, we |
| 212 | ;; must fire the rename event there as well. | 215 | ;; must fire the rename event there as well. |
| 213 | (when (not (equal (file-notify--descriptor desc) | 216 | (when (not (equal (file-notify--descriptor desc file1) |
| 214 | (file-notify--descriptor | 217 | (file-notify--descriptor |
| 215 | (caar file-notify--pending-event)))) | 218 | (caar file-notify--pending-event) |
| 219 | (file-notify--event-file-name | ||
| 220 | file-notify--pending-event)))) | ||
| 216 | (setq pending-event | 221 | (setq pending-event |
| 217 | `((,(caar file-notify--pending-event) | 222 | `((,(caar file-notify--pending-event) |
| 218 | renamed ,file ,file1) | 223 | renamed ,file ,file1) |
| @@ -223,7 +228,10 @@ EVENT is the cadr of the event in `file-notify-handle-event' | |||
| 223 | ;; Apply pending callback. | 228 | ;; Apply pending callback. |
| 224 | (when pending-event | 229 | (when pending-event |
| 225 | (setcar | 230 | (setcar |
| 226 | (car pending-event) (file-notify--descriptor (caar pending-event))) | 231 | (car pending-event) |
| 232 | (file-notify--descriptor | ||
| 233 | (caar pending-event) | ||
| 234 | (file-notify--event-file-name file-notify--pending-event))) | ||
| 227 | (funcall (cadr pending-event) (car pending-event)) | 235 | (funcall (cadr pending-event) (car pending-event)) |
| 228 | (setq pending-event nil)) | 236 | (setq pending-event nil)) |
| 229 | 237 | ||
| @@ -257,14 +265,15 @@ EVENT is the cadr of the event in `file-notify-handle-event' | |||
| 257 | (if file1 | 265 | (if file1 |
| 258 | (funcall | 266 | (funcall |
| 259 | callback | 267 | callback |
| 260 | `(,(file-notify--descriptor desc) ,action ,file ,file1)) | 268 | `(,(file-notify--descriptor desc file) ,action ,file ,file1)) |
| 261 | (funcall | 269 | (funcall |
| 262 | callback | 270 | callback |
| 263 | `(,(file-notify--descriptor desc) ,action ,file))))) | 271 | `(,(file-notify--descriptor desc file) ,action ,file))))) |
| 264 | 272 | ||
| 265 | ;; Modify `file-notify-descriptors'. | 273 | ;; Modify `file-notify-descriptors'. |
| 266 | (when stopped | 274 | (when stopped |
| 267 | (file-notify--rm-descriptor (file-notify--descriptor desc) file))))) | 275 | (file-notify--rm-descriptor |
| 276 | (file-notify--descriptor desc file) file))))) | ||
| 268 | 277 | ||
| 269 | ;; `gfilenotify' and `w32notify' return a unique descriptor for every | 278 | ;; `gfilenotify' and `w32notify' return a unique descriptor for every |
| 270 | ;; `file-notify-add-watch', while `inotify' returns a unique | 279 | ;; `file-notify-add-watch', while `inotify' returns a unique |
| @@ -375,7 +384,8 @@ FILE is the name of the file whose event is being reported." | |||
| 375 | file-notify-descriptors) | 384 | file-notify-descriptors) |
| 376 | 385 | ||
| 377 | ;; Return descriptor. | 386 | ;; Return descriptor. |
| 378 | (file-notify--descriptor desc))) | 387 | (file-notify--descriptor |
| 388 | desc (unless (file-directory-p file) (file-name-nondirectory file))))) | ||
| 379 | 389 | ||
| 380 | (defun file-notify-rm-watch (descriptor) | 390 | (defun file-notify-rm-watch (descriptor) |
| 381 | "Remove an existing watch specified by its DESCRIPTOR. | 391 | "Remove an existing watch specified by its DESCRIPTOR. |
| @@ -396,7 +406,7 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'." | |||
| 396 | (if handler | 406 | (if handler |
| 397 | ;; A file name handler could exist even if there is no local | 407 | ;; A file name handler could exist even if there is no local |
| 398 | ;; file notification support. | 408 | ;; file notification support. |
| 399 | (funcall handler 'file-notify-rm-watch desc) | 409 | (funcall handler 'file-notify-rm-watch descriptor) |
| 400 | 410 | ||
| 401 | (funcall | 411 | (funcall |
| 402 | (cond | 412 | (cond |