+(defun elopher-insert-margin (&optional type-name)
+ (if type-name
+ (insert (propertize
+ (format (concat "%" (number-to-string elopher-margin-width) "s")
+ (concat "[" type-name "] "))
+ 'face '(foreground-color . "yellow")))
+ (insert (make-string elopher-margin-width ?\s))))
+
+(defun elopher-follow-index-link (button)
+ (apply #'elopher-get-index (button-get button 'link-address)))
+
+(defun elopher-follow-text-link (button)
+ (apply #'elopher-get-text (button-get button 'link-address)))
+
+(defun elopher-follow-image-link (button)
+ (apply #'elopher-get-image (button-get button 'link-address)))
+
+(defun elopher-process-record (line)
+ (let* ((type (elt line 0))
+ (fields (split-string (substring line 1) "\t"))
+ (display-string (elt fields 0))
+ (selector (elt fields 1))
+ (hostname (elt fields 2))
+ (port (elt fields 3))
+ (address (list selector hostname port)))
+ (pcase type
+ (?i (elopher-insert-margin)
+ (insert (propertize display-string
+ 'face '(foreground-color. "white"))))
+ (?0 (elopher-insert-margin "T")
+ (insert-text-button display-string
+ 'face '(foreground-color . "gray")
+ 'link-address address
+ 'action #'elopher-follow-text-link
+ 'follow-link t))
+ (?1 (elopher-insert-margin "/")
+ (insert-text-button display-string
+ 'face '(foreground-color . "cyan")
+ 'link-address address
+ 'action #'elopher-follow-index-link
+ 'follow-link t))
+ (?p (elopher-insert-margin "img")
+ (insert-text-button display-string
+ 'face '(foreground-color . "gray")
+ 'link-address address
+ 'action #'elopher-follow-image-link
+ 'follow-link t))
+ (?.) ; Occurs at end of index, can safely ignore.
+ (tp (elopher-insert-margin (concat (char-to-string tp) "?"))
+ (insert (propertize display-string
+ 'face '(foreground-color . "red")))))
+ (insert "\n")))
+
+(defvar elopher-incomplete-record "")
+
+(defun elopher-process-complete-records (string)
+ (let* ((til-now (string-join (list elopher-incomplete-record string)))
+ (lines (split-string til-now "\r\n")))
+ (dotimes (idx (length lines))
+ (if (< idx (- (length lines) 1))
+ (let ((line (elt lines idx)))
+ (unless (string-empty-p line)
+ (elopher-process-record line)))
+ (setq elopher-incomplete-record (elt lines idx))))))
+
+(defun elopher-index-filter (proc string)