[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a232821: Add command `file-notify-rm-all-watches'
From: |
Michael Albinus |
Subject: |
master a232821: Add command `file-notify-rm-all-watches' |
Date: |
Sat, 16 Oct 2021 08:34:04 -0400 (EDT) |
branch: master
commit a232821c5127d5ebf862dc229f14a35dfef78e40
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
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'.
---
doc/lispref/os.texi | 4 ++++
etc/NEWS | 20 +++++++++++++-------
lisp/filenotify.el | 8 ++++++++
test/lisp/filenotify-tests.el | 31 +++++++++++++++++++++++++++----
4 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index e3297b1..e3dcd6c 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 2c09d24..5a7b204 100644
--- a/etc/NEWS
+++ b/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.
---
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index e0dceb7..a2a2762 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -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'."
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 6125069..e8a647d 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -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
@@ -517,6 +515,31 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
(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)))
(file-notify--deftest-remote file-notify-test02-rm-watch
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a232821: Add command `file-notify-rm-all-watches',
Michael Albinus <=