I have the following code to print an alist
. But I now want to recode this in a way that one can specify the buffer used for display. In addition, I would like that whether on not to erase the buffer is optional (not erasing the buffer as default).
(defun print-alist2 (alist)
"Write an associated list to a buffer."
(let ((table-format "%-20s %-20s\n")
(output-buffer (get-buffer-create "Alist Output")))
(with-current-buffer output-buffer
(erase-buffer)
(insert (format table-format "Key" "Value"))
(dolist (vpair alist)
(insert (format table-format (car vpair) (cdr vpair)))))
(switch-to-buffer output-buffer)))
(setq foo '((a1 . a2) (b1 . b2) (c1 . c2)))
(print-alist2 foo)