[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: [PATCH] w3m-cookie.el: graceful entry, useless code?, documentation



Looking further into the code, I need to update and correct my
previous patch suggestion:

1] It seems better to place the graceful entry snippet in function
`w3m-cookie' instead of `w3m-about-cookie'.

2] The code snippet I proposed for deletion is important. It is how
emacs-w3m processes user requests to change the 'use/ignore' status of
a cookie. In a fashion normal for browsers but not for emacs, this is
done by having emacs send an HTTP POST request to itself, instead of
just changing the data. The optional arg `post-data' is the content of
that request.

2.1] This opens up separate issues I don't understand. Why this
round-about method? Why ever optimally need any of the optional args?

What turns out to be happening is quite round-about. The user invokes
a function which produces a url "about://cookie", which is parsed
generically and then sent to a function `w3m-about-retrieve' which
generates a function call (in this case `w3m-about-cookie') and calls
that function to handle the HTTP request to itself.

But shouldn't all about:// 'pages' always be access-restricted to an
emacs instance on the localhost? If so, none of this seems necessary,
useful, or desirable, not the function generator, nor any of the
optional args.

Rather, in all such cases, the function bound to the keybinding should
point directly to a function to generate the buffer and handle it
related requests.

The only other point to address is the case of a user wanting to
hand-enter a url in the form "about://something". But why would a user
find it desirable to that? He can use the keybinding, and if he
forgets the keybinding it's simpler to enter `M-x w3m-cookie' that 'G
http://about:cookie/'.

Attached is a correction to my suggested patch of a few hours ago.
Please also disregard the related suggested patch to `w3m-load.el' of
a few hours ago.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
--- w3m-cookie_orig.el	2017-06-14 04:26:41.628269575 -0400
+++ w3m-cookie.el	2017-06-14 09:26:59.184616942 -0400
@@ -89,22 +89,31 @@
 
 ;;; Cookie accessor.
 (defmacro w3m-cookie-url (cookie)
+  "Returns the url of the cookie"
   `(aref ,cookie 0))
 (defmacro w3m-cookie-domain (cookie)
+  "Returns the domain of the cookie"
   `(aref ,cookie 1))
 (defmacro w3m-cookie-secure (cookie)
+  "Returns whether the cookie is `secure'"
   `(aref ,cookie 2))
 (defmacro w3m-cookie-name (cookie)
+  "Returns the name of the cookie"
   `(aref ,cookie 3))
 (defmacro w3m-cookie-value (cookie)
+  "Returns the value of the cookie"
   `(aref ,cookie 4))
 (defmacro w3m-cookie-path (cookie)
+  "Returns the relative path of the cookie file"
   `(aref ,cookie 5))
 (defmacro w3m-cookie-version (cookie)
+  "Returns a cookie's version information"
   `(aref ,cookie 6))
 (defmacro w3m-cookie-expires (cookie)
+  "Returns when a cookie will expire"
   `(aref ,cookie 7))
 (defmacro w3m-cookie-ignore (cookie)
+  "Returns `t' if a cookie is marked to be ignored by emacs-w3m"
   `(aref ,cookie 8))
 
 (defun w3m-cookie-create (&rest args)
@@ -514,12 +523,16 @@
 (defun w3m-cookie (&optional no-cache)
   "Display cookies and enable you to manage them."
   (interactive "P")
-  (w3m-goto-url-new-session "about://cookie/" no-cache))
+  (unless w3m-use-cookies
+    (when
+      (y-or-n-p "Use of cookies is currently disable. Enable?")
+     (setq w3m-use-cookies t)))
+  (when w3m-use-cookies
+    (w3m-goto-url-new-session "about://cookie/" no-cache)))
 
 ;;;###autoload
 (defun w3m-about-cookie (url &optional no-decode no-cache post-data &rest args)
   "Make the html contents to display and to enable you to manage cookies."
-  (unless w3m-use-cookies (error "You must enable emacs-w3m to use cookies."))
   (w3m-cookie-setup)
   (let ((pos 0))
     (when post-data