Index: sbbs.el ================================================================== --- sbbs.el +++ sbbs.el @@ -228,70 +228,72 @@ (defun sbbs--board-loader (status buf) "Callback function for `url-retrieve' when loading board. Load results into buffer BUF. STATUS is used to check for errors." - (when (plist-get status :error) - (message "Error while loading: %s" + (when (buffer-live-p buf) + (when (plist-get status :error) + (error "Error while loading: %s" (cdr (plist-get status :error)))) - (forward-paragraph) - (let ((list (read (current-buffer)))) - (kill-buffer) - (with-current-buffer buf - (let (ent) - (dolist (thread list) - (push (list (car thread) - (vector (substring (cdr (assq 'date (cdr thread))) - 0 16) - (number-to-string - (cdr (assq 'messages (cdr thread)))) - (propertize - (cdr (assq 'headline (cdr thread))) - 'face 'variable-pitch))) - ent)) - (setq-local tabulated-list-entries ent) - (tabulated-list-print t t) - (hl-line-highlight))))) + (forward-paragraph) + (let ((list (read (current-buffer)))) + (kill-buffer) + (with-current-buffer buf + (let (ent) + (dolist (thread list) + (push (list (car thread) + (vector (substring (cdr (assq 'date (cdr thread))) + 0 16) + (number-to-string + (cdr (assq 'messages (cdr thread)))) + (propertize + (cdr (assq 'headline (cdr thread))) + 'face 'variable-pitch))) + ent)) + (setq-local tabulated-list-entries ent) + (tabulated-list-print t t) + (hl-line-highlight)))))) (defun sbbs--thread-loader (status board id buf) "Callback function for `url-retrieve' when loading thread. The attribute ID determines what thread from board BOARD to load. STATUS is used to check for errors." - (when (plist-get status :error) - (message "Error while loading: %s" + (when (buffer-live-p buf) + (when (plist-get status :error) + (error "Error while loading: %s" (cdr (plist-get status :error)))) - (prog-mode) - (forward-paragraph) - (save-excursion - (save-match-data - (while (search-forward "#f" nil t) - (unless (cadddr (syntax-ppss)) - (replace-match "nil"))))) - (save-excursion - (save-match-data - (while (search-forward "#f" nil t) - (unless (cadddr (syntax-ppss)) - (replace-match "t"))))) - (let ((thread (read (current-buffer)))) - (kill-buffer) - (with-current-buffer buf - (sbbs-read-mode) - (setq sbbs--board board - sbbs--thread-id id) - (let ((buffer-read-only nil)) - (erase-buffer) - (setq header-line-format - (format "Thread %d: %s" id - (cdr (assq 'headline thread)))) - (dolist (post (cadr (assq 'posts thread))) - (sbbs--thread-insert-post post)) - (delete-blank-lines) - (goto-char (point-min))) - (rename-buffer (format "*reading /%s/%d*" - (sbbs--board-name board) - id))))) + (prog-mode) + (forward-paragraph) + (save-excursion + (save-match-data + (while (search-forward "#f" nil t) + (unless (cadddr (syntax-ppss)) + (replace-match "nil"))))) + (save-excursion + (save-match-data + (while (search-forward "#f" nil t) + (unless (cadddr (syntax-ppss)) + (replace-match "t"))))) + (let ((thread (read (current-buffer)))) + (kill-buffer) + (with-current-buffer buf + (sbbs-read-mode) + (setq sbbs--board board + sbbs--thread-id id) + (let ((buffer-read-only nil)) + (erase-buffer) + (setq header-line-format + (format "Thread %d: %s" id + (cdr (assq 'headline thread)))) + (dolist (post (cadr (assq 'posts thread))) + (sbbs--thread-insert-post post)) + (delete-blank-lines) + (goto-char (point-min))) + (rename-buffer (format "*reading /%s/%d*" + (sbbs--board-name board) + id)))))) ;; INTERACTIVE FUNCTIONS (defun sbbs-view-open (id) "Open thread ID in new buffer."