all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#22720: 25.0.91; url/eww: add function to delete all cookies
@ 2016-02-17 14:32 Michael Heerdegen
  2016-02-19  5:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2016-02-17 14:32 UTC (permalink / raw)
  To: 22720; +Cc: Lars Ingebrigtsen


Hello!

as for any popular browser, it would be cool if eww users had a mean to
delete all cookies - in a command, or by adding a function to a hook.
And probably also something to do this selectively for only some cookies
etc.

AFAIK, eww uses the cookie mechanism from url, so the command should
probably be added there.

But AFAICT, direct cookie manipulation is not really possible yet, so I
need the following hack currently:

--8<---------------cut here---------------start------------->8---
(defun my-url-delete-all-cookies ()
  "Delete all cookies"
  (interactive)
  (require 'url)
  (cl-letf (((symbol-function 'url-cookie-expired-p) (lambda (&rest _args) t)))
    (url-cookie-write-file)))
--8<---------------cut here---------------end--------------->8---

Of course we should not do it like this.


Regards,

Michael.




In GNU Emacs 25.0.91.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.7)
 of 2016-02-14 built on drachen
Repository revision: 23ca48d3d867cfff9f49ef600e2aad7a26c7a870
Windowing system distributor 'The X.Org Foundation', version 11.0.11800000
System Description:	Debian GNU/Linux testing (stretch)

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_COLLATE: C
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22720: 25.0.91; url/eww: add function to delete all cookies
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-19  5:42 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 22720

Michael Heerdegen <michael_heerdegen@web.de> writes:

> AFAIK, eww uses the cookie mechanism from url, so the command should
> probably be added there.

There's `M-x url-cookie-list' that will list all the cookies and allow
you to delete any (or all by holding down the `C-k' key).  Does that do
what you want to?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22720: 25.0.91; url/eww: add function to delete all cookies
  2016-02-19  5:42 ` Lars Ingebrigtsen
@ 2016-02-19 11:48   ` Michael Heerdegen
  2016-02-21  5:57     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2016-02-19 11:48 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 22720

Lars Ingebrigtsen <larsi@gnus.org> writes:

> There's `M-x url-cookie-list' that will list all the cookies and allow
> you to delete any (or all by holding down the `C-k' key).  Does that
> do what you want to?

I know that feature, but it's interactive, so that's not what I mean.
With that, you can't e.g. make Emacs delete all cookies when closing,
like you can in internet browsers.


Regards,

Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22720: 25.0.91; url/eww: add function to delete all cookies
  2016-02-19 11:48   ` Michael Heerdegen
@ 2016-02-21  5:57     ` Lars Ingebrigtsen
  2016-02-22 12:52       ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-21  5:57 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 22720

Michael Heerdegen <michael_heerdegen@web.de> writes:

> I know that feature, but it's interactive, so that's not what I mean.
> With that, you can't e.g. make Emacs delete all cookies when closing,
> like you can in internet browsers.

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

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22720: 25.0.91; url/eww: add function to delete all cookies
  2016-02-21  5:57     ` Lars Ingebrigtsen
@ 2016-02-22 12:52       ` Michael Heerdegen
  2016-02-23  1:52         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2016-02-22 12:52 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 22720

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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#22720: 25.0.91; url/eww: add function to delete all cookies
  2016-02-22 12:52       ` Michael Heerdegen
@ 2016-02-23  1:52         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-23  1:52 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 22720

Michael Heerdegen <michael_heerdegen@web.de> writes:

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

Yeah, that seems like a good idea.  Then you can have an exit hook that
deletes all cookies except a few that you want to have around.

I've now done this change (slightly different from your version).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-23  1:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-02-23  1:52         ` Lars Ingebrigtsen

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.