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

A git-ish patch for w3m-db-history



Function w3m-db-history is what gives us a flat listing of all URLs
visited by all emacs-w3m buffers, along with a timestamp for each. The
attached patch allows a user to actually use the options claimed for the
function, fixes those options so they work, and makes minor cosmetic
changes to the display.

I performed this task not knowing how close Tsuchiya-san was to
announcing an official git repo for the project, and it was with the
idea producing something in a format that could be usable both by cvs
now, and by git in the future.

Attached are two diff files generated by git from my personal
development version of the project. As patches go, the first has the
advantage of being the type of diff that can be applied straight to a
cvs repository. It was produced from my git branch 'history' using:

   git diff -u master >~/w3m-db-hist.patch

The second has the advantage of including a step-by-step granular
incremental diff of each commit that led to the final result, along with
the git commit message. AFAIK, it can't be simply applied to a cvs
repository using a single 'patch' command, but if the project wants to
accept only some of the features of the work, each git commit (~6) can
easily be cut/pasted and patched. The command for creating that file
was:

   git log -p --full-diff master..HEAD >~/w3m-db-hist.git.patch

I will separately push the branch to my github account and create a pull
request against the official git repository, so at this point I'm not
sure whether the files are of practical use to the project, but they may
be of use to others on the list who may not be using git, or who want to
familiarize themselves with some git options.

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
diff --git a/ChangeLog b/ChangeLog
index bf218787..8f85df06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-01-29  Boruch Baum  <boruch_baum@xxxxxxx>
+
+	* w3m.el (w3m-db-history, w3m-about-db-history): New option: display
+	histories in new buffers. Add details to docstrings. Allow interactive
+	user to set function options. Properly handle START and SIZE arguments.
+	Modify html output for clarity, date display format, use of ellipsis,
+	maximum use of page width, center heading, align page navigation links
+	to page edges, remove extraneous ';' after url's, add ellipsis when
+	truncating url's.
+
 2018-06-13  Katsumi Yamaoka  <yamaoka@xxxxxxx>
 
 	* w3m.el (w3m-user-agent-default-alist): Fix default value;
diff --git a/w3m.el b/w3m.el
index d3397fdb..ae7573b7 100644
--- a/w3m.el
+++ b/w3m.el
@@ -10887,6 +10887,9 @@ A history page is invoked by the `w3m-about-history' command.")
 
 (defun w3m-about-history (&rest args)
   "Show a tree-structured history."
+; ARGS is not used. It is necessary in order to >/dev/null unnecessary
+; arguments because this function is one of several called by
+; `w3m-about-retrieve' using a generic constructed `funcall'.
   (let (start history current)
     (with-current-buffer w3m-current-buffer
       (setq history w3m-history-flat
@@ -10970,16 +10973,22 @@ A history page is invoked by the `w3m-about-history' command.")
     "text/html"))
 
 (defun w3m-about-db-history (url &rest args)
+; ARGS is not used. It is necessary in order to >/dev/null unnecessary
+; arguments because this function is one of several called by
+; `w3m-about-retrieve' using a generic constructed `funcall'.
   (let ((start 0)
-        (size nil)
-        (width (- (w3m-display-width) 18))
+        (size 0)
+        (print-all t)
+        (width (- (w3m-display-width) 23))
         (now (current-time))
         title time alist prev next page total)
     (when (string-match "\\`about://db-history/\\?" url)
       (dolist (s (split-string (substring url (match-end 0)) "&"))
-        (when (string-match "\\`\\(?:start\\|\\(size\\)\\)=" s)
-          (set (if (match-beginning 1) 'size 'start)
-               (string-to-number (substring s (match-end 0)))))))
+        (when (string-match "\\`\\(?:size\\|\\(start\\)\\)=" s)
+          (if (match-beginning 1)
+            (setq start (string-to-number (substring s (match-end 0))))
+           (setq size (string-to-number (substring s (match-end 0))))
+           (when (/= size 0) (setq print-all nil))))))
     (when w3m-arrived-db
       (mapatoms
        (lambda (sym)
@@ -10994,7 +11003,7 @@ A history page is invoked by the `w3m-about-history' command.")
                           (w3m-time-newer-p (cdr a) (cdr b))))))
     (setq total (length alist))
     (setq alist (nthcdr start alist))
-    (when size
+    (when (/= size 0)
       (when (> start 0)
         (setq prev
               (format "about://db-history/?start=%d&size=%d"
@@ -11010,47 +11019,54 @@ A history page is invoked by the `w3m-about-history' command.")
             (if prev (format "<link rel=\"prev\" href=\"%s\">\n" prev) "")
             (if next (format "<link rel=\"next\" href=\"%s\">\n" next) "")
             (format
-             "</head>\n<body>\n<h1>Arrived URL history in DataBase%s</h1>\n"
+             "</head><body><center><h1>Global URL history for all w3m buffers%s</h1></center>\n"
              (if (and page total)
-                 (format " (%d/%d)" page total) "")))
+                 (format " (page %d/%d)" page total) "")))
     (setq prev
           (if (or prev next)
               (setq next
                     (concat
-                     "<p align=\"left\">"
+                     "<table width=100%><tr>"
                      (if prev
-                         (format "[<a href=\"%s\">Prev History</a>]" prev)
-                       "")
+                         (format "<td width=50%% align=\"left\">[<a href=\"%s\">Prev Page</a>]</td>" prev)
+                       "<td width=50%%></td>")
                      (if next
-                         (format "[<a href=\"%s\">Next History</a>]" next)
-                       "")
-                     "</p>\n"))
+                         (format "<td width=50%% align=\"right\">[<a href=\"%s\">Next Page</a>]</td>" next)
+                       "<td width=50%%></td>")
+                     "</tr></table>\n"))
             ""))
     (if (null alist)
         (insert "<em>Nothing in DataBase.</em>\n")
-      (insert prev "<table cellpadding=0>
+      (insert prev "<table width=100% cellpadding=0>
 <tr><td><h2> Title/URL </h2></td><td><h2>Time/Date</h2></td></tr>\n")
-      (while (and alist
-                  (or (not size)
-                      (>= (decf size) 0)))
+      (while (and alist (or (>= (decf size) 0) print-all))
         (setq url (car (car alist))
               time (cdr (car alist))
               alist (cdr alist)
               title (w3m-arrived-title url))
-        (if (or (null title)
-                (string= "<no-title>" title))
-            (setq title (concat "<" (w3m-truncate-string url width) ">"))
-          (when (>= (string-width title) width)
-            (setq title (concat (w3m-truncate-string title width) "..."))))
+        (cond
+         ((or (null title) (string= "<no-title>" title))
+          (setq title
+            (concat
+              "&lt;"
+              (if (>= (string-width url) width)
+                (concat (w3m-truncate-string url (1- width)) "…")
+               url)
+              "&gt")))
+         (t
+          (setq title
+            (w3m-encode-specials-string
+              (if (>= (string-width title) width)
+                (concat (w3m-truncate-string title width) "…")
+               title)))))
         (insert (format "<tr><td><a href=\"%s\">%s</a></td>"
-                        url
-                        (w3m-encode-specials-string title)))
+                        url title))
         (when time
           (insert "<td>"
                   (if (<= (w3m-time-lapse-seconds time now)
                           64800) ;; = (* 60 60 18) 18hours.
-                      (format-time-string "%H:%M:%S" time)
-                    (format-time-string "%Y-%m-%d" time))
+                      (format-time-string "%H:%M:%S Today" time)
+                    (format-time-string "%H:%M:%S %Y-%m-%d" time))
                   "</td>"))
         (insert "</tr>\n"))
       (insert "</table>"
@@ -11100,22 +11116,59 @@ It does manage history position data as well."
   :type '(radio (const :tag "All entries are displayed in single page." nil)
                 (integer :format "%t: %v\n")))
 
+(defcustom w3m-history-in-new-buffer nil
+  "Whether to display URL histories in the current buffer."
+  :group 'w3m
+  :type 'boolean)
+
 (defun w3m-db-history (&optional start size)
-  "Display arrived URLs."
-  (interactive
-   (list nil w3m-db-history-display-size))
-  (w3m-goto-url (concat
-                 (format "about://db-history/?start=%d" (or start 0))
-                 (if size (format "&size=%d" size) ""))
-                 nil nil nil nil nil nil nil t))
+  "Display arrived URLs.
+
+This is a flat (not hierarchial) presentation of all URLs visited
+by ALL w3m buffers, and includes a timestamp for when the URL was
+visited. The list is presented in reverse-chronological order,
+ie. most recent URL first.
+
+START is a positive integer for the point in the history list at
+which to begin displaying, where 0 is the most recent entry.
+
+SIZE is the maximum number of arrived URLs which are displayed
+per page. Variable `w3m-db-history-display-size' sets the
+default. Use 0 to display the entire history on a single page."
+  (interactive)
+  (cond
+   ((or executing-kbd-macro noninteractive)
+    (when (not start) (setq start 0))
+    (when (not size)  (setq size w3m-db-history-display-size)))
+   (t ; called interactively; possibly indirectly
+    (setq start (read-number "start: " (or w3m-db-history-display-size 0)))
+    (setq size (read-number "size: " (or size 0)))))
+  (let ((url (format "about://db-history/?start=%d&size=%d"
+               (or start 0) (or size 0))))
+   (if w3m-history-in-new-buffer
+     (w3m-goto-url-new-session url)
+    (w3m-goto-url url :save-pos t))))
 
 (defun w3m-history (&optional arg)
-  "Display the history of all the links you have visited in the session.
-If it is called with the prefix argument, display the arrived URLs."
+  "Display the buffer's history tree.
+
+If called with the prefix argument, display the arrived URLs.
+
+The buffer's history tree is a hierarchal presentation of all
+URLs visited by the current bufferand its \"parents\", meaning
+that if the buffer was spawned using a command such as
+`w3m-goto-url-new-session', its history will include that of the
+prior w3m buffer.
+
+The display of arrived URLs is a flat (not hierarchial)
+chronological presentation of all URLs visited by ALL w3m
+buffers, and includes a timestamp for when the URL was visited. "
   (interactive "P")
-  (if (null arg)
-      (w3m-goto-url "about://history/" nil nil nil nil nil nil nil t)
-    (w3m-db-history nil w3m-db-history-display-size)))
+  (if arg
+    (w3m-db-history nil w3m-db-history-display-size)
+   (if w3m-history-in-new-buffer
+     (w3m-goto-url-new-session "about://history/")
+    (w3m-goto-url "about://history/" :save-pos t))))
 
 (defun w3m-w32-browser-with-fiber (url)
   (let ((proc (start-process "w3m-w32-browser-with-fiber"
commit 4cad2ddf6d2fe69f5cf6e3500c8c35c4337c8d9c
Author: Boruch Baum <boruch_baum@xxxxxxx>
Date:   Tue Jan 29 23:46:23 2019 -0500

    Update changelog for this branch's commits

diff --git a/ChangeLog b/ChangeLog
index bf218787..8f85df06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-01-29  Boruch Baum  <boruch_baum@xxxxxxx>
+
+	* w3m.el (w3m-db-history, w3m-about-db-history): New option: display
+	histories in new buffers. Add details to docstrings. Allow interactive
+	user to set function options. Properly handle START and SIZE arguments.
+	Modify html output for clarity, date display format, use of ellipsis,
+	maximum use of page width, center heading, align page navigation links
+	to page edges, remove extraneous ';' after url's, add ellipsis when
+	truncating url's.
+
 2018-06-13  Katsumi Yamaoka  <yamaoka@xxxxxxx>
 
 	* w3m.el (w3m-user-agent-default-alist): Fix default value;

commit 23c039419568fa1c94783b9b774b409094583280
Author: Boruch Baum <boruch_baum@xxxxxxx>
Date:   Tue Jan 29 23:18:56 2019 -0500

    Cosmetic display changes for global history listing
    
    + Center heading
    
    + Page navigation links aligned to page edges
    
    + Remove extraneous ';' after url's
    
    + Add ellipsis when truncating url's

diff --git a/w3m.el b/w3m.el
index 0dc5a0bd..ae7573b7 100644
--- a/w3m.el
+++ b/w3m.el
@@ -11019,39 +11019,48 @@ A history page is invoked by the `w3m-about-history' command.")
             (if prev (format "<link rel=\"prev\" href=\"%s\">\n" prev) "")
             (if next (format "<link rel=\"next\" href=\"%s\">\n" next) "")
             (format
-             "</head>\n<body>\n<h1>Global URL history for all w3m buffers%s</h1>\n"
+             "</head><body><center><h1>Global URL history for all w3m buffers%s</h1></center>\n"
              (if (and page total)
                  (format " (page %d/%d)" page total) "")))
     (setq prev
           (if (or prev next)
               (setq next
                     (concat
-                     "<p align=\"left\">"
+                     "<table width=100%><tr>"
                      (if prev
-                         (format "[<a href=\"%s\">Prev Page</a>]" prev)
-                       "")
+                         (format "<td width=50%% align=\"left\">[<a href=\"%s\">Prev Page</a>]</td>" prev)
+                       "<td width=50%%></td>")
                      (if next
-                         (format "[<a href=\"%s\">Next Page</a>]" next)
-                       "")
-                     "</p>\n"))
+                         (format "<td width=50%% align=\"right\">[<a href=\"%s\">Next Page</a>]</td>" next)
+                       "<td width=50%%></td>")
+                     "</tr></table>\n"))
             ""))
     (if (null alist)
         (insert "<em>Nothing in DataBase.</em>\n")
-      (insert prev "<table cellpadding=0>
+      (insert prev "<table width=100% cellpadding=0>
 <tr><td><h2> Title/URL </h2></td><td><h2>Time/Date</h2></td></tr>\n")
       (while (and alist (or (>= (decf size) 0) print-all))
         (setq url (car (car alist))
               time (cdr (car alist))
               alist (cdr alist)
               title (w3m-arrived-title url))
-        (if (or (null title)
-                (string= "<no-title>" title))
-            (setq title (concat "<" (w3m-truncate-string url width) ">"))
-          (when (>= (string-width title) width)
-            (setq title (concat (w3m-truncate-string title width) "…"))))
+        (cond
+         ((or (null title) (string= "<no-title>" title))
+          (setq title
+            (concat
+              "&lt;"
+              (if (>= (string-width url) width)
+                (concat (w3m-truncate-string url (1- width)) "…")
+               url)
+              "&gt")))
+         (t
+          (setq title
+            (w3m-encode-specials-string
+              (if (>= (string-width title) width)
+                (concat (w3m-truncate-string title width) "…")
+               title)))))
         (insert (format "<tr><td><a href=\"%s\">%s</a></td>"
-                        url
-                        (w3m-encode-specials-string title)))
+                        url title))
         (when time
           (insert "<td>"
                   (if (<= (w3m-time-lapse-seconds time now)

commit 251552bfe038f54dbb3157129c89b3522aaa5c20
Author: Boruch Baum <boruch_baum@xxxxxxx>
Date:   Tue Jan 29 21:35:55 2019 -0500

    Modify display of global history listing (date format, ellipsis)
    
    + All dates display full timestamp, with today's entries labeled
      "Today".
    
    + Unicode ellipsis sign used instead of three ascii dots (buys two
      characters for long titles).
    
    + Extend width of title string to maximum.

diff --git a/w3m.el b/w3m.el
index d5f6768d..0dc5a0bd 100644
--- a/w3m.el
+++ b/w3m.el
@@ -10979,7 +10979,7 @@ A history page is invoked by the `w3m-about-history' command.")
   (let ((start 0)
         (size 0)
         (print-all t)
-        (width (- (w3m-display-width) 18))
+        (width (- (w3m-display-width) 23))
         (now (current-time))
         title time alist prev next page total)
     (when (string-match "\\`about://db-history/\\?" url)
@@ -11048,7 +11048,7 @@ A history page is invoked by the `w3m-about-history' command.")
                 (string= "<no-title>" title))
             (setq title (concat "<" (w3m-truncate-string url width) ">"))
           (when (>= (string-width title) width)
-            (setq title (concat (w3m-truncate-string title width) "..."))))
+            (setq title (concat (w3m-truncate-string title width) "…"))))
         (insert (format "<tr><td><a href=\"%s\">%s</a></td>"
                         url
                         (w3m-encode-specials-string title)))
@@ -11056,8 +11056,8 @@ A history page is invoked by the `w3m-about-history' command.")
           (insert "<td>"
                   (if (<= (w3m-time-lapse-seconds time now)
                           64800) ;; = (* 60 60 18) 18hours.
-                      (format-time-string "%H:%M:%S" time)
-                    (format-time-string "%Y-%m-%d" time))
+                      (format-time-string "%H:%M:%S Today" time)
+                    (format-time-string "%H:%M:%S %Y-%m-%d" time))
                   "</td>"))
         (insert "</tr>\n"))
       (insert "</table>"

commit 8da4a1466fecaa942d84a4aa1f293bdfec7cc10d
Author: Boruch Baum <boruch_baum@xxxxxxx>
Date:   Tue Jan 29 21:18:41 2019 -0500

    Fix improper use of called-interactively-p

diff --git a/w3m.el b/w3m.el
index 8759167e..d5f6768d 100644
--- a/w3m.el
+++ b/w3m.el
@@ -11126,20 +11126,19 @@ which to begin displaying, where 0 is the most recent entry.
 SIZE is the maximum number of arrived URLs which are displayed
 per page. Variable `w3m-db-history-display-size' sets the
 default. Use 0 to display the entire history on a single page."
-  (interactive
-   (list nil w3m-db-history-display-size))
-   (when (called-interactively-p 'interactive)
-
-(setq start (read-number "start: " (or w3m-db-history-display-size 0)))
-(setq size (read-number "size: " (or size 0)))
-
-)
-
-   (let ((url (format "about://db-history/?start=%d&size=%d"
-                (or start 0) (or size 0))))
-    (if w3m-history-in-new-buffer
-      (w3m-goto-url-new-session url)
-     (w3m-goto-url url :save-pos t))))
+  (interactive)
+  (cond
+   ((or executing-kbd-macro noninteractive)
+    (when (not start) (setq start 0))
+    (when (not size)  (setq size w3m-db-history-display-size)))
+   (t ; called interactively; possibly indirectly
+    (setq start (read-number "start: " (or w3m-db-history-display-size 0)))
+    (setq size (read-number "size: " (or size 0)))))
+  (let ((url (format "about://db-history/?start=%d&size=%d"
+               (or start 0) (or size 0))))
+   (if w3m-history-in-new-buffer
+     (w3m-goto-url-new-session url)
+    (w3m-goto-url url :save-pos t))))
 
 (defun w3m-history (&optional arg)
   "Display the buffer's history tree.

commit 205762a09df959c647a1192f94c29b005d8266d3
Author: Boruch Baum <boruch_baum@xxxxxxx>
Date:   Tue Jan 29 20:56:28 2019 -0500

    Fix feature to display global history
    
    + Function w3m-db-history was not allowing an interactive user to set
      its options.
    
    + Function w3m-about-db-history was not properly handling its START
      and SIZE arguments.
    
    + Modified docstrings to explain the functions' options.
    
    + Modified html output for clarity.

diff --git a/w3m.el b/w3m.el
index e9757112..8759167e 100644
--- a/w3m.el
+++ b/w3m.el
@@ -10887,6 +10887,9 @@ A history page is invoked by the `w3m-about-history' command.")
 
 (defun w3m-about-history (&rest args)
   "Show a tree-structured history."
+; ARGS is not used. It is necessary in order to >/dev/null unnecessary
+; arguments because this function is one of several called by
+; `w3m-about-retrieve' using a generic constructed `funcall'.
   (let (start history current)
     (with-current-buffer w3m-current-buffer
       (setq history w3m-history-flat
@@ -10970,16 +10973,22 @@ A history page is invoked by the `w3m-about-history' command.")
     "text/html"))
 
 (defun w3m-about-db-history (url &rest args)
+; ARGS is not used. It is necessary in order to >/dev/null unnecessary
+; arguments because this function is one of several called by
+; `w3m-about-retrieve' using a generic constructed `funcall'.
   (let ((start 0)
-        (size nil)
+        (size 0)
+        (print-all t)
         (width (- (w3m-display-width) 18))
         (now (current-time))
         title time alist prev next page total)
     (when (string-match "\\`about://db-history/\\?" url)
       (dolist (s (split-string (substring url (match-end 0)) "&"))
-        (when (string-match "\\`\\(?:start\\|\\(size\\)\\)=" s)
-          (set (if (match-beginning 1) 'size 'start)
-               (string-to-number (substring s (match-end 0)))))))
+        (when (string-match "\\`\\(?:size\\|\\(start\\)\\)=" s)
+          (if (match-beginning 1)
+            (setq start (string-to-number (substring s (match-end 0))))
+           (setq size (string-to-number (substring s (match-end 0))))
+           (when (/= size 0) (setq print-all nil))))))
     (when w3m-arrived-db
       (mapatoms
        (lambda (sym)
@@ -10994,7 +11003,7 @@ A history page is invoked by the `w3m-about-history' command.")
                           (w3m-time-newer-p (cdr a) (cdr b))))))
     (setq total (length alist))
     (setq alist (nthcdr start alist))
-    (when size
+    (when (/= size 0)
       (when (> start 0)
         (setq prev
               (format "about://db-history/?start=%d&size=%d"
@@ -11010,19 +11019,19 @@ A history page is invoked by the `w3m-about-history' command.")
             (if prev (format "<link rel=\"prev\" href=\"%s\">\n" prev) "")
             (if next (format "<link rel=\"next\" href=\"%s\">\n" next) "")
             (format
-             "</head>\n<body>\n<h1>Arrived URL history in DataBase%s</h1>\n"
+             "</head>\n<body>\n<h1>Global URL history for all w3m buffers%s</h1>\n"
              (if (and page total)
-                 (format " (%d/%d)" page total) "")))
+                 (format " (page %d/%d)" page total) "")))
     (setq prev
           (if (or prev next)
               (setq next
                     (concat
                      "<p align=\"left\">"
                      (if prev
-                         (format "[<a href=\"%s\">Prev History</a>]" prev)
+                         (format "[<a href=\"%s\">Prev Page</a>]" prev)
                        "")
                      (if next
-                         (format "[<a href=\"%s\">Next History</a>]" next)
+                         (format "[<a href=\"%s\">Next Page</a>]" next)
                        "")
                      "</p>\n"))
             ""))
@@ -11030,9 +11039,7 @@ A history page is invoked by the `w3m-about-history' command.")
         (insert "<em>Nothing in DataBase.</em>\n")
       (insert prev "<table cellpadding=0>
 <tr><td><h2> Title/URL </h2></td><td><h2>Time/Date</h2></td></tr>\n")
-      (while (and alist
-                  (or (not size)
-                      (>= (decf size) 0)))
+      (while (and alist (or (>= (decf size) 0) print-all))
         (setq url (car (car alist))
               time (cdr (car alist))
               alist (cdr alist)
@@ -11108,11 +11115,26 @@ It does manage history position data as well."
 (defun w3m-db-history (&optional start size)
   "Display arrived URLs.
 
-This is a flat (not hierarchial) chronological presentation of
-all URLs visited by ALL w3m buffers, and includes a timestamp for
-when the URL was visited."
+This is a flat (not hierarchial) presentation of all URLs visited
+by ALL w3m buffers, and includes a timestamp for when the URL was
+visited. The list is presented in reverse-chronological order,
+ie. most recent URL first.
+
+START is a positive integer for the point in the history list at
+which to begin displaying, where 0 is the most recent entry.
+
+SIZE is the maximum number of arrived URLs which are displayed
+per page. Variable `w3m-db-history-display-size' sets the
+default. Use 0 to display the entire history on a single page."
   (interactive
    (list nil w3m-db-history-display-size))
+   (when (called-interactively-p 'interactive)
+
+(setq start (read-number "start: " (or w3m-db-history-display-size 0)))
+(setq size (read-number "size: " (or size 0)))
+
+)
+
    (let ((url (format "about://db-history/?start=%d&size=%d"
                 (or start 0) (or size 0))))
     (if w3m-history-in-new-buffer

commit 43166382daf994521d3140e6c84fe5456d15c212
Author: Boruch Baum <boruch_baum@xxxxxxx>
Date:   Tue Jan 29 18:04:34 2019 -0500

    New option: display histories in new buffers
    
    + New boolean defcustom w3m-history-in-new-buffer, default to current
      behavior: nil.
    
    + Add details to docstrings for functions w3m-db-history and
      w3m-history.

diff --git a/w3m.el b/w3m.el
index d3397fdb..e9757112 100644
--- a/w3m.el
+++ b/w3m.el
@@ -11100,22 +11100,45 @@ It does manage history position data as well."
   :type '(radio (const :tag "All entries are displayed in single page." nil)
                 (integer :format "%t: %v\n")))
 
+(defcustom w3m-history-in-new-buffer nil
+  "Whether to display URL histories in the current buffer."
+  :group 'w3m
+  :type 'boolean)
+
 (defun w3m-db-history (&optional start size)
-  "Display arrived URLs."
+  "Display arrived URLs.
+
+This is a flat (not hierarchial) chronological presentation of
+all URLs visited by ALL w3m buffers, and includes a timestamp for
+when the URL was visited."
   (interactive
    (list nil w3m-db-history-display-size))
-  (w3m-goto-url (concat
-                 (format "about://db-history/?start=%d" (or start 0))
-                 (if size (format "&size=%d" size) ""))
-                 nil nil nil nil nil nil nil t))
+   (let ((url (format "about://db-history/?start=%d&size=%d"
+                (or start 0) (or size 0))))
+    (if w3m-history-in-new-buffer
+      (w3m-goto-url-new-session url)
+     (w3m-goto-url url :save-pos t))))
 
 (defun w3m-history (&optional arg)
-  "Display the history of all the links you have visited in the session.
-If it is called with the prefix argument, display the arrived URLs."
+  "Display the buffer's history tree.
+
+If called with the prefix argument, display the arrived URLs.
+
+The buffer's history tree is a hierarchal presentation of all
+URLs visited by the current bufferand its \"parents\", meaning
+that if the buffer was spawned using a command such as
+`w3m-goto-url-new-session', its history will include that of the
+prior w3m buffer.
+
+The display of arrived URLs is a flat (not hierarchial)
+chronological presentation of all URLs visited by ALL w3m
+buffers, and includes a timestamp for when the URL was visited. "
   (interactive "P")
-  (if (null arg)
-      (w3m-goto-url "about://history/" nil nil nil nil nil nil nil t)
-    (w3m-db-history nil w3m-db-history-display-size)))
+  (if arg
+    (w3m-db-history nil w3m-db-history-display-size)
+   (if w3m-history-in-new-buffer
+     (w3m-goto-url-new-session "about://history/")
+    (w3m-goto-url "about://history/" :save-pos t))))
 
 (defun w3m-w32-browser-with-fiber (url)
   (let ((proc (start-process "w3m-w32-browser-with-fiber"