emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r115668: eww: machinery to list browser history


From: Teodor Zlatanov
Subject: [Emacs-diffs] trunk r115668: eww: machinery to list browser history
Date: Sat, 21 Dec 2013 20:32:37 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115668
revision-id: address@hidden
parent: address@hidden
committer: Ted Zlatanov <address@hidden>
branch nick: quickfixes
timestamp: Sat 2013-12-21 15:33:44 -0500
message:
  eww: machinery to list browser history
  
  * 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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/eww.el                eww.el-20130610114603-80ap3gwnw4x4m5ix-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-21 20:13:09 +0000
+++ b/lisp/ChangeLog    2013-12-21 20:33:44 +0000
@@ -1,3 +1,10 @@
+2013-12-21  Kenjiro NAKAYAMA <address@hidden>
+
+        * 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.
+
 2013-12-21  RĂ¼diger Sonderfeld  <address@hidden>
 
        * net/eww.el (eww-back-url, eww-forward-url, eww-next-url)

=== modified file 'lisp/net/eww.el'
--- a/lisp/net/eww.el   2013-12-21 20:13:09 +0000
+++ b/lisp/net/eww.el   2013-12-21 20:33:44 +0000
@@ -414,6 +414,7 @@
     (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)
@@ -433,6 +434,7 @@
        ["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]))
@@ -471,15 +473,6 @@
   ;;(setq buffer-read-only t)
   )
 
-(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)
@@ -1262,6 +1255,98 @@
   (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))))
+      (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]