From: Lars Magne Ingebrigtsen Date: Wed, 26 Jun 2013 12:54:33 +0000 (+0200) Subject: Implement a command and mode for displaying and editing cookies X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1992^2~28 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=843571cba9e46385c1e46a6d78e2838edde4c564;p=emacs.git Implement a command and mode for displaying and editing cookies --- diff --git a/etc/NEWS b/etc/NEWS index db6ad061b28..8df6153e808 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1194,6 +1194,9 @@ and the `attributes' slot is always nil. The `url-retrieve' function now uses this to encode its URL argument, in case that is not properly encoded. +*** New command `url-cookie-list' displays all the current cookies, and +allows deleting selected cookies. + ** notifications.el supports now version 1.2 of the Notifications API. The function `notifications-get-capabilities' returns the supported server properties. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7aa962b9ada..76d1f065401 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-06-26 Lars Magne Ingebrigtsen + + * net/eww.el (eww-mode): Undo isn't necessary in eww buffers, + probably. + 2013-06-26 Glenn Morris * htmlfontify.el (hfy-triplet): Handle unspecified-fg, bg. diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 61bb4235c34..5ad4c327627 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -346,6 +346,7 @@ word(s) will be searched for via `eww-search-prefix'." (set (make-local-variable 'after-change-functions) 'eww-process-text-input) (set (make-local-variable 'eww-history) nil) (set (make-local-variable 'eww-history-position) 0) + (buffer-disable-undo) ;;(setq buffer-read-only t) ) diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 0d963eddc02..7b64b4cb3eb 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog @@ -1,3 +1,8 @@ +2013-06-26 Lars Magne Ingebrigtsen + + * url-cookie.el: Implement a command and mode for displaying and + editing cookies. + 2013-06-21 Glenn Morris * url-future.el (url-future-call): Remove useless value call. diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index 6692c812871..3e543300b30 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el @@ -349,6 +349,94 @@ to run the `url-cookie-setup-save-timer' function manually." url-cookie-save-interval #'url-cookie-write-file)))) +;;; Mode for listing and editing cookies. + +(defun url-cookie-list () + "List the URL cookies." + (interactive) + + (when (and (null url-cookie-secure-storage) + (null url-cookie-storage)) + (error "No cookies are defined")) + + (pop-to-buffer "*url cookies*") + (let ((inhibit-read-only t) + (domains (sort + (copy-sequence + (append url-cookie-secure-storage + url-cookie-storage)) + (lambda (e1 e2) + (string< (car e1) (car e2))))) + (domain-length 0) + start name format domain) + (erase-buffer) + (url-cookie-mode) + (dolist (elem domains) + (setq domain-length (max domain-length (length (car elem))))) + (setq format (format "%%-%ds %%-20s %%s" domain-length) + header-line-format + (concat " " (format format "Domain" "Name" "Value"))) + (dolist (elem domains) + (setq domain (car elem)) + (dolist (cookie (sort (copy-sequence (cdr elem)) + (lambda (c1 c2) + (string< (url-cookie-name c1) + (url-cookie-name c2))))) + (setq start (point) + name (url-cookie-name cookie)) + (when (> (length name) 20) + (setq name (substring name 0 20))) + (insert (format format domain name + (url-cookie-value cookie)) + "\n") + (setq domain "") + (put-text-property start (1+ start) 'url-cookie cookie))) + (goto-char (point-min)))) + +(defun url-cookie-delete () + "Delete the cookie on the current line." + (interactive) + (let ((cookie (get-text-property (line-beginning-position) 'url-cookie)) + (inhibit-read-only t) + variable) + (unless cookie + (error "No cookie on the current line")) + (setq variable (if (url-cookie-secure cookie) + 'url-cookie-secure-storage + 'url-cookie-storage)) + (let* ((list (symbol-value variable)) + (elem (assoc (url-cookie-domain cookie) list))) + (setq elem (delq cookie elem)) + (when (zerop (length (cdr elem))) + (setq list (delq elem list))) + (set variable list)) + (setq url-cookies-changed-since-last-save t) + (url-cookie-write-file) + (delete-region (line-beginning-position) + (progn + (forward-line 1) + (point))))) + +(defun url-cookie-quit () + "Kill the current buffer." + (interactive) + (kill-buffer (current-buffer))) + +(defvar url-cookie-mode-map + (let ((map (make-sparse-keymap))) + (suppress-keymap map) + (define-key map "q" 'url-cookie-quit) + (define-key map [delete] 'url-cookie-delete) + map)) + +(define-derived-mode url-cookie-mode nil "eww" + "Mode for listing cookies. + +\\{url-cookie-mode-map}" + (buffer-disable-undo) + (setq buffer-read-only t + truncate-lines t)) + (provide 'url-cookie) ;;; url-cookie.el ends here