From: Lars Ingebrigtsen Date: Tue, 23 Feb 2016 01:51:24 +0000 (+1100) Subject: Allow deleting all non-matching cookies X-Git-Tag: emacs-26.0.90~2512 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dfcdc1cbed773041e907a389b8901ca845af49bb;p=emacs.git Allow deleting all non-matching cookies * lisp/url/url-cookie.el (url-cookie-delete-cookies): Allow keeping matching cookies (bug#22720). --- diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index a4b7a58fdf3..6848230c28f 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el @@ -353,14 +353,19 @@ to run the `url-cookie-setup-save-timer' function manually." url-cookie-save-interval #'url-cookie-write-file)))) -(defun url-cookie-delete-cookies (&optional regexp) +(defun url-cookie-delete-cookies (&optional regexp keep) "Delete all cookies from the cookie store where the domain matches REGEXP. -If REGEXP is nil, all cookies are deleted." +If REGEXP is nil, all cookies are deleted. If KEEP is non-nil, +instead delete all cookies that do not match REGEXP." (dolist (variable '(url-cookie-secure-storage url-cookie-storage)) (let ((cookies (symbol-value variable))) (dolist (elem cookies) - (when (or (null regexp) - (string-match regexp (car elem))) + (when (or (and (null keep) + (or (null regexp) + (string-match regexp (car elem)))) + (and keep + regexp + (not (string-match regexp (car elem))))) (setq cookies (delq elem cookies)))) (set variable cookies))) (setq url-cookies-changed-since-last-save t)