Add command `file-notify-rm-all-watches'
* doc/lispref/os.texi (File Notifications): Add `file-notify-rm-all-watches'. * etc/NEWS: Mention 'file-notify-rm-all-watches'. Fix typos. * lisp/filenotify.el (file-notify-rm-all-watches): New defun. * test/lisp/filenotify-tests.el (file-notify--test-cleanup): Use `file-notify-rm-all-watches'. (file-notify-test02-rm-watch): Test also `file-notify-rm-all-watches'.
This commit is contained in:
parent
a3fb10d94b
commit
a232821c51
4 changed files with 52 additions and 11 deletions
|
@ -3230,6 +3230,10 @@ Removes an existing file watch specified by its @var{descriptor}.
|
|||
@code{file-notify-add-watch}.
|
||||
@end defun
|
||||
|
||||
@deffn Command file-notify-rm-all-watches
|
||||
Removes all existing file notification watches from Emacs.
|
||||
@end deffn
|
||||
|
||||
@defun file-notify-valid-p descriptor
|
||||
Checks a watch specified by its @var{descriptor} for validity.
|
||||
@var{descriptor} should be an object returned by
|
||||
|
|
20
etc/NEWS
20
etc/NEWS
|
@ -28,7 +28,7 @@ applies, and please also update docstrings as needed.
|
|||
* Startup Changes in Emacs 29.1
|
||||
|
||||
+++
|
||||
** Emacs now has a --fingerprint option.
|
||||
** Emacs now has a '--fingerprint' option.
|
||||
This will output a string identifying the current Emacs build.
|
||||
|
||||
+++
|
||||
|
@ -73,7 +73,7 @@ point.
|
|||
|
||||
---
|
||||
*** Improved mouse behavior with auto-scrolling modes.
|
||||
When clicking inside the `scroll-margin' or `hscroll-margin' region
|
||||
When clicking inside the 'scroll-margin' or 'hscroll-margin' region
|
||||
the point is now moved only when releasing the mouse button. This no
|
||||
longer results in a bogus selection, unless the mouse has been
|
||||
effectively dragged.
|
||||
|
@ -106,6 +106,8 @@ default, no automatic renaming is performed.
|
|||
The new command 'image-dired-unmark-all-marks' has been added with a
|
||||
binding in the menu.
|
||||
|
||||
** info-look
|
||||
|
||||
---
|
||||
*** info-look specs can now be expanded at run time instead of a load time.
|
||||
The new ':doc-spec-function' element can be used to compute the
|
||||
|
@ -115,9 +117,9 @@ mode (instead of at load time).
|
|||
** subr-x
|
||||
|
||||
+++
|
||||
*** New macro 'with-memoization' provides a very primitive form of memoization
|
||||
*** New macro 'with-memoization' provides a very primitive form of memoization.
|
||||
|
||||
** ansi-color.el
|
||||
** ansi-color
|
||||
|
||||
---
|
||||
*** Support for ANSI 256-color and 24-bit colors.
|
||||
|
@ -130,14 +132,18 @@ filters and displayed with the specified color.
|
|||
*** Support for ANSI 256-color and 24-bit colors, italic and other fonts.
|
||||
Term-mode can now display 256-color and 24-bit color codes. It can
|
||||
also handle ANSI codes for faint, italic and blinking text, displaying
|
||||
it with new 'ansi-term-faint/italic/slow-blinking/fast-blinking'
|
||||
faces.
|
||||
it with new 'term-{faint,italic,slow-blink,fast-blink}' faces.
|
||||
|
||||
** Xref
|
||||
|
||||
*** 'project-find-file' and 'project-or-external-find-file' now accept
|
||||
a prefix argument which is interpreted to mean "include all files".
|
||||
|
||||
** File notifications
|
||||
|
||||
+++
|
||||
*** The new command 'file-notify-rm-all-watches' removes all file notifications.
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 29.1
|
||||
|
||||
|
@ -183,7 +189,7 @@ If given the new optional KILL-PERMANENT argument, also kill permanent
|
|||
local variables.
|
||||
|
||||
+++
|
||||
** Third 'mapconcat' argument 'separator' is now optional.
|
||||
** Third 'mapconcat' argument SEPARATOR is now optional.
|
||||
An explicit nil always meant the empty string, now it can be left out.
|
||||
|
||||
---
|
||||
|
|
|
@ -478,6 +478,14 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'."
|
|||
;; Modify `file-notify-descriptors' and send a `stopped' event.
|
||||
(file-notify--rm-descriptor descriptor))))
|
||||
|
||||
(defun file-notify-rm-all-watches ()
|
||||
"Remove all existing file notification watches from Emacs."
|
||||
(interactive)
|
||||
(maphash
|
||||
(lambda (key _value)
|
||||
(file-notify-rm-watch key))
|
||||
file-notify-descriptors))
|
||||
|
||||
(defun file-notify-valid-p (descriptor)
|
||||
"Check a watch specified by its DESCRIPTOR.
|
||||
DESCRIPTOR should be an object returned by `file-notify-add-watch'."
|
||||
|
|
|
@ -162,9 +162,7 @@ Return nil when any other file notification watch is still active."
|
|||
|
||||
(defun file-notify--test-cleanup ()
|
||||
"Cleanup after a test."
|
||||
(file-notify-rm-watch file-notify--test-desc)
|
||||
(file-notify-rm-watch file-notify--test-desc1)
|
||||
(file-notify-rm-watch file-notify--test-desc2)
|
||||
(file-notify-rm-all-watches)
|
||||
|
||||
(ignore-errors
|
||||
(delete-file (file-newest-backup file-notify--test-tmpfile)))
|
||||
|
@ -421,7 +419,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
|
|||
|
||||
;; This test is inspired by Bug#26126 and Bug#26127.
|
||||
(ert-deftest file-notify-test02-rm-watch ()
|
||||
"Check `file-notify-rm-watch'."
|
||||
"Check `file-notify-rm-watch' and `file-notify-rm-all-watches'."
|
||||
(skip-unless (file-notify--test-local-enabled))
|
||||
|
||||
(unwind-protect
|
||||
|
@ -516,6 +514,31 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
|
|||
;; The environment shall be cleaned up.
|
||||
(file-notify--test-cleanup-p))))
|
||||
|
||||
;; Cleanup.
|
||||
(file-notify--test-cleanup))
|
||||
|
||||
(unwind-protect
|
||||
;; Check `file-notify-rm-all-watches'.
|
||||
(progn
|
||||
(setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
|
||||
file-notify--test-tmpfile1 (file-notify--test-make-temp-name))
|
||||
(write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
|
||||
(write-region "any text" nil file-notify--test-tmpfile1 nil 'no-message)
|
||||
(should
|
||||
(setq file-notify--test-desc
|
||||
(file-notify-add-watch
|
||||
file-notify--test-tmpfile '(change) #'ignore)))
|
||||
(should
|
||||
(setq file-notify--test-desc1
|
||||
(file-notify-add-watch
|
||||
file-notify--test-tmpfile1 '(change) #'ignore)))
|
||||
(file-notify-rm-all-watches)
|
||||
(delete-file file-notify--test-tmpfile)
|
||||
(delete-file file-notify--test-tmpfile1)
|
||||
|
||||
;; The environment shall be cleaned up.
|
||||
(file-notify--test-cleanup-p))
|
||||
|
||||
;; Cleanup.
|
||||
(file-notify--test-cleanup)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue