-If we're only interested in the current entries, then this
-function can only return a list of a single item per buffer."
- (let ((separator (list (current-buffer)
- (vector
- "E"
- (make-string 25 ?-)
- (make-string 25 ?-)))))
- (if (eq major-mode 'elpher-mode)
- ;; every section starts with the current page and ends with
- ;; the separator
- (mapcar (lambda (page)
- (if page
- (list (current-buffer)
- (vector
- "E"
- (or (elpher-address-to-url
- (elpher-page-address page)) "none")
- (or (elpher-page-display-string page) "?")))
- separator))
- (cons elpher-current-page elpher-history))
- (nconc (mapcar (lambda (data)
- (list (current-buffer)
- (vector
- "W"
- (plist-get data :url)
- (plist-get data :title))))
- (cons eww-data eww-history))
- (list separator)))))
+This returns a list of items for the current buffer, based on the
+buffer's history.
+
+An item is a list (BUFFER VECTOR) where BUFFER is the buffer this
+item refers to and VECTOR is what to display in the tabulated
+list established by `elpher-menu-refresh'. See
+`tabulated-list-format'."
+ ;; Every section starts with the current page, followed by some
+ ;; history items, and ends with the separator.
+ (let ((separator (list nil
+ (vector "-"
+ (make-string 25 ?-)
+ (make-string 25 ?-)))))
+ (cond ((eq major-mode 'elpher-mode)
+ ;; A pair is (BUFFER-OR-DATA . PAGE) where BUFFER-OR-DTA is
+ ;; the current buffer, if possible, or list (BUFFER FUNC
+ ;; &rest ARGS) telling us which BUFFER to switch to, and
+ ;; what function to call. The last item of elpher-history
+ ;; has a nil page, so when that shows up, use the separator
+ (mapcar (lambda (pair)
+ (if (cdr pair)
+ (list (car pair)
+ (vector "G"
+ (or (elpher-page-display-string (cdr pair)) "?")
+ (or (elpher-address-to-url
+ (elpher-page-address (cdr pair))) "none")))
+ separator))
+ (cons (cons (current-buffer) elpher-current-page)
+ (mapcar (lambda (page)
+ (cons (list (current-buffer) 'elpher-visit-page page)
+ page))
+ elpher-history))))
+ ((eq major-mode 'gemini-mode)
+ ;; No history means a list of one item. Add a separator.
+ (list (list (current-buffer)
+ (vector "E"
+ (or (elpher-page-display-string elpher-current-page)
+ (buffer-name))
+ (or (elpher-address-to-url
+ (elpher-page-address elpher-current-page)))))
+ separator))
+ ((eq major-mode 'eww-mode)
+ ;; A pair is (BUFFER-OR-DATA . PAGE) where BUFFER-OR-DTA is
+ ;; the current buffer, if possible, or list (BUFFER FUNC
+ ;; &rest ARGS) telling us which BUFFER to switch to, and
+ ;; what function to call. Add the separator at the end.
+ (nconc (cons (list (current-buffer)
+ (vector "W"
+ (or (plist-get eww-data :title) "none")
+ (or (plist-get eww-data :url) "none")))
+ (mapcar (lambda (data)
+ (list
+ (list (current-buffer) 'eww-restore-history data)
+ (vector "W"
+ (or (plist-get data :title) "none")
+ (or (plist-get data :url) "none"))))
+ eww-history))
+ (list separator))))))