From: <nakayamakenjiro@gmail.com>
To: 16086@debbugs.gnu.org
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 [thread overview]
Message-ID: <87iouuwya5.fsf@dhcp-193-97.nrt.redhat.com> (raw)
In-Reply-To: <87sitzqk8w.fsf@flea.lifelogs.com>
> 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 <nakayamakenjiro@gmail.com>
* 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 <tzz@lifelogs.com> 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
next prev parent reply other threads:[~2013-12-12 3:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-08 5:44 bug#16086: 24.3.50; [PATCH] eww: New command and functions to list the browser histories Kenjiro NAKAYAMA
2013-12-11 0:21 ` Ted Zlatanov
2013-12-11 19:07 ` Ted Zlatanov
2013-12-12 3:20 ` nakayamakenjiro [this message]
2013-12-12 15:42 ` Ted Zlatanov
2013-12-12 23:54 ` Kenjiro NAKAYAMA
2013-12-13 14:39 ` Ted Zlatanov
2013-12-14 1:48 ` Kenjiro NAKAYAMA
2013-12-14 15:56 ` Stefan Monnier
2013-12-14 16:15 ` Lars Magne Ingebrigtsen
2013-12-20 0:53 ` Kenjiro NAKAYAMA
2013-12-21 20:34 ` Ted Zlatanov
2013-12-21 20:34 ` Ted Zlatanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iouuwya5.fsf@dhcp-193-97.nrt.redhat.com \
--to=nakayamakenjiro@gmail.com \
--cc=16086@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.