From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.bugs Subject: bug#16086: 24.3.50; [PATCH] eww: New command and functions to list the browser histories.. Date: Thu, 12 Dec 2013 12:20:18 +0900 Message-ID: <87iouuwya5.fsf@dhcp-193-97.nrt.redhat.com> References: <87mwkbq4ko.fsf@dhcp-193-97.nrt.redhat.com> <87a9g8s0ec.fsf@flea.lifelogs.com> <87sitzqk8w.fsf@flea.lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1386818534 5109 80.91.229.3 (12 Dec 2013 03:22:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Dec 2013 03:22:14 +0000 (UTC) To: 16086@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 12 04:22:19 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vqwqv-0002DH-Iu for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Dec 2013 04:22:17 +0100 Original-Received: from localhost ([::1]:33092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqwqu-0001Sx-Qs for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Dec 2013 22:22:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqwql-0001SE-QB for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:22:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vqwqg-00050I-B4 for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:22:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqwqg-00050E-7l for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:22:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vqwqf-0002t9-Ou for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:22:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Dec 2013 03:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16086 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Cc: 16086@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.138681850111078 (code B ref -1); Thu, 12 Dec 2013 03:22:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Dec 2013 03:21:41 +0000 Original-Received: from localhost ([127.0.0.1]:44537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VqwqK-0002sa-S5 for submit@debbugs.gnu.org; Wed, 11 Dec 2013 22:21:41 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55167) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VqwqH-0002sR-1i for submit@debbugs.gnu.org; Wed, 11 Dec 2013 22:21:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqwqB-0004xy-Bc for submit@debbugs.gnu.org; Wed, 11 Dec 2013 22:21:36 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqwqB-0004xt-8M for submit@debbugs.gnu.org; Wed, 11 Dec 2013 22:21:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqwq5-0001QB-GZ for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:21:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vqwq0-0004v2-4p for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:21:25 -0500 Original-Received: from mail-pd0-x232.google.com ([2607:f8b0:400e:c02::232]:36197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqwpz-0004uy-Om for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2013 22:21:20 -0500 Original-Received: by mail-pd0-f178.google.com with SMTP id y10so10775965pdj.9 for ; Wed, 11 Dec 2013 19:21:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-type; bh=ay4cwP4OPzk/v2gnpO3i5/sX8lFcTm9Ds20W9n6Fi88=; b=Hupne805sR+3cxIPsIHlfeN4JTgf2AsDb8ou+taMVgWgM1T26g6+2+uKrOdjC3VeoT U/J82Jm7/9cG72KgMzNy3Jr+9jBhJU+FSnjb95GMHF7+i1mo/VidNYXfe7+KrfNHty+8 UaOGeKqMk+SQEvrZ+GGspbknJ4cbMJ5692wwxFR56Q50Yiym+ANxMaYzed0VEt2qaM7b KeyZ6BY8iqKcK6KCPnw/iFkCrnizwvIF68m1gHZZGKZ9DGIaU4In1um7sKE7BmqMCv5K YP3l3OFJRc9CmjFiCcJP4S30dxW3nMqi26b4M17onv5aT2FH0FuAToX255Px42CD+p34 8Cjw== X-Received: by 10.68.172.196 with SMTP id be4mr7632611pbc.12.1386818478616; Wed, 11 Dec 2013 19:21:18 -0800 (PST) Original-Received: from dhcp-193-97.nrt.redhat.com (nat-pool-nrt-t1.redhat.com. [66.187.238.10]) by mx.google.com with ESMTPSA id xn12sm50186323pac.12.2013.12.11.19.21.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Dec 2013 19:21:17 -0800 (PST) User-agent: mu4e 0.9.9.6pre2; emacs 24.3.50.3 In-reply-to: <87sitzqk8w.fsf@flea.lifelogs.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:81795 Archived-At: > Trailing spaces here and elsewhere, can you please fix? Oh, I'm sorry. I fixed them. > I'd rather see these removed, IIUC what you mean here. I think so too. I removed. > Could this also bind `next-error' and `previous-error'? Actually a > generic "list of items" buffer mode would be useful and perhaps already > exists? Ok, I will try to bind `next-error and `previous-error, but it may take a while. So, before I do that, I resend the patch with fixed of the above. Signed-off-by: Kenjiro NAKAYAMA * net/eww.el (eww-list-histories,eww-list-histories,eww-history-browse,eww-history-quit,eww-history-kill,eww-history-mode-map,eww-history-mode): New command and functions to list browser histories. --- lisp/net/eww.el | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 9 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 34c6728..cbae7d8 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -411,6 +411,7 @@ word(s) will be searched for via `eww-search-prefix'." (define-key map "w" 'eww-copy-page-url) (define-key map "C" 'url-cookie-list) (define-key map "v" 'eww-view-source) + (define-key map "H" 'eww-list-histories) (define-key map "b" 'eww-add-bookmark) (define-key map "B" 'eww-list-bookmarks) @@ -430,6 +431,7 @@ word(s) will be searched for via `eww-search-prefix'." ["Download" eww-download t] ["View page source" eww-view-source] ["Copy page URL" eww-copy-page-url t] + ["List histories" eww-list-histories t] ["Add bookmark" eww-add-bookmark t] ["List bookmarks" eww-list-bookmarks t] ["List cookies" url-cookie-list t])) @@ -462,15 +464,6 @@ word(s) will be searched for via `eww-search-prefix'." (interactive) (quit-window)) -(defun eww-save-history () - (push (list :url eww-current-url - :title eww-current-title - :point (point) - :dom eww-current-dom - :source eww-current-source - :text (buffer-string)) - eww-history)) - ;;;###autoload (defun eww-browse-url (url &optional _new-window) (when (and (equal major-mode 'eww-mode) @@ -1242,6 +1235,98 @@ Differences in #targets are ignored." (setq buffer-read-only t truncate-lines t)) +;;; History code + +(defun eww-save-history () + (push (list :url eww-current-url + :title eww-current-title + :point (point) + :dom eww-current-dom + :source eww-current-source + :text (buffer-string)) + eww-history)) + +(defun eww-list-histories () + "List the eww-histories." + (interactive) + (when (null eww-history) + (error "No eww-histories are defined")) + (set-buffer (get-buffer-create "*eww history*")) + (eww-history-mode) + (let ((inhibit-read-only t) + (domain-length 0) + (title-length 0) + url title format start) + (erase-buffer) + (dolist (history eww-history) + (setq start (point)) + (setq domain-length (max domain-length (length (plist-get history :url)))) p+ (setq title-length (max title-length (length (plist-get history :title)))) + ) + (setq format (format "%%-%ds %%-%ds" title-length domain-length) + header-line-format + (concat " " (format format "Title" "URL"))) + + (dolist (history eww-history) + (setq url (plist-get history :url)) + (setq title (plist-get history :title)) + (insert (format format title url)) + (insert "\n") + (put-text-property start (point) 'eww-history history) + ) + (goto-char (point-min))) + (pop-to-buffer "*eww history*") + ) + +(defun eww-history-browse () + "Browse the history under point in eww." + (interactive) + (let ((history (get-text-property (line-beginning-position) 'eww-history))) + (unless history + (error "No history on the current line")) + (eww-history-quit) + (pop-to-buffer "*eww*") + (eww-browse-url (plist-get history :url)))) + +(defun eww-history-quit () + "Kill the current buffer." + (interactive) + (kill-buffer (current-buffer))) + +(defvar eww-history-kill-ring nil) + +(defun eww-history-kill () + "Kill the current history." + (interactive) + (let* ((start (line-beginning-position)) + (history (get-text-property start 'eww-history)) + (inhibit-read-only t)) + (unless history + (error "No history on the current line")) + (forward-line 1) + (push (buffer-substring start (point)) eww-history-kill-ring) + (delete-region start (point)) + (setq eww-history (delq history eww-history)) + )) + +(defvar eww-history-mode-map + (let ((map (make-sparse-keymap))) + (suppress-keymap map) + (define-key map "q" 'eww-history-quit) + (define-key map [(control k)] 'eww-history-kill) + (define-key map "\r" 'eww-history-browse) + (define-key map "n" 'next-error-no-select) + (define-key map "p" 'previous-error-no-select) + map)) + +(define-derived-mode eww-history-mode nil "eww history" + "Mode for listing eww-histories. + +\\{eww-history-mode-map}" + (buffer-disable-undo) + (setq buffer-read-only t + truncate-lines t)) + (provide 'eww) ;;; eww.el ends here -- 1.8.3.1 tzz@lifelogs.com writes: > On Tue, 10 Dec 2013 19:21:15 -0500 Ted Zlatanov wrote: > > TZ> Actually a generic "list of items" buffer mode would be useful and > TZ> perhaps already exists? > > (This need was also mentioned when we talked about ways to improve the > display of completion candidates.) > > Ted