1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-13 09:32:47 +00:00

Tweak the look of the cookie buffer after cookie deletion

* lisp/url/url-cookie.el (url-cookie--generate-buffer): Factor out
into its own function.
(url-cookie-delete): Use it to make the buffer look consistent
after deleting a cookie.
This commit is contained in:
Lars Ingebrigtsen 2018-04-15 22:36:16 +02:00
parent a37a14e0a8
commit f262b10b46

View File

@ -404,6 +404,11 @@ Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies."
(error "No cookies are defined"))
(pop-to-buffer "*url cookies*")
(url-cookie-mode)
(url-cookie--generate-buffer)
(goto-char (point-min)))
(defun url-cookie--generate-buffer ()
(let ((inhibit-read-only t)
(domains (sort
(copy-sequence
@ -414,7 +419,6 @@ Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies."
(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)
@ -426,16 +430,15 @@ Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies."
(lambda (c1 c2)
(string< (url-cookie-name c1)
(url-cookie-name c2)))))
(setq start (point)
(setq start (point)
name (url-cookie-name cookie))
(when (> (length name) 20)
(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))))
(insert (format format domain name
(url-cookie-value cookie))
"\n")
(setq domain "")
(put-text-property start (1+ start) 'url-cookie cookie)))))
(defun url-cookie-delete ()
"Delete the cookie on the current line."
@ -459,7 +462,11 @@ Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies."
(delete-region (line-beginning-position)
(progn
(forward-line 1)
(point)))))
(point)))
(let ((point (point)))
(erase-buffer)
(url-cookie--generate-buffer)
(goto-char point))))
(defvar url-cookie-mode-map
(let ((map (make-sparse-keymap)))