all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 22720@debbugs.gnu.org
Subject: bug#22720: 25.0.91; url/eww: add function to delete all cookies
Date: Mon, 22 Feb 2016 13:52:21 +0100	[thread overview]
Message-ID: <87lh6caovu.fsf@web.de> (raw)
In-Reply-To: <87k2lyfvw8.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 21 Feb 2016 16:57:27 +1100")

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Oh, I see.  I've now added this to the trunk:
> `url-cookie-delete-cookies'.

Thanks!

I guess it would also make sense to be able to keep cookies with
matching domain name.  I tweaked your defun a bit:


#+begin_src emacs-lisp
(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 KEEP is non-nil, delete all cookies where the domain does not
match REGEXP."
  (dolist (variable '(url-cookie-secure-storage url-cookie-storage))
    (if (not regexp)
        (set variable nil)
      (let ((cookies (symbol-value variable))
            (pred (if keep
                      (lambda (cookie) (not (string-match-p regexp (car cookie))))
                    (lambda (cookie) (string-match-p regexp (car cookie))))))
        (dolist (elem cookies)
          (when (funcall pred elem)
            (setq cookies (delq elem cookies))))
        (set variable cookies))))
  (setq url-cookies-changed-since-last-save t)
  (url-cookie-write-file))
#+end_src

WDYT?


Regards,

Michael.





  reply	other threads:[~2016-02-22 12:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 14:32 bug#22720: 25.0.91; url/eww: add function to delete all cookies Michael Heerdegen
2016-02-19  5:42 ` Lars Ingebrigtsen
2016-02-19 11:48   ` Michael Heerdegen
2016-02-21  5:57     ` Lars Ingebrigtsen
2016-02-22 12:52       ` Michael Heerdegen [this message]
2016-02-23  1:52         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lh6caovu.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=22720@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.