sbbs.el

Check-in [93642cb140]
Login
Overview
Comment:check if buffer still exists in url-retrieve callbacks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 93642cb1401885fa78f63e84bc5932280735b44b36b96edfdbade8ad617cde6c
User & Date: philip@warpmail.net on 2020-02-22 21:16:50
Other Links: branch diff | manifest | tags
Context
2020-02-24
16:19
removed sbbs--ornamentum variable check-in: 06efb04e61 user: philip@warpmail.net tags: master, trunk
2020-02-22
21:16
check if buffer still exists in url-retrieve callbacks check-in: 93642cb140 user: philip@warpmail.net tags: master, trunk
20:22
added usage section to readme check-in: f0432e6d61 user: philip@warpmail.net tags: master, trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Modified sbbs.el from [689d8c2215] to [97ee81d344].

   226    226    ;; URL.EL CALLBACKS
   227    227   
   228    228   (defun sbbs--board-loader (status buf)
   229    229     "Callback function for `url-retrieve' when loading board.
   230    230   
   231    231   Load results into buffer BUF. STATUS is used to check for
   232    232   errors."
          233  +  (when (buffer-live-p buf)
   233    234     (when (plist-get status :error)
   234         -    (message "Error while loading: %s"
          235  +      (error "Error while loading: %s"
   235    236                (cdr (plist-get status :error))))
   236    237     (forward-paragraph)
   237    238     (let ((list (read (current-buffer))))
   238    239       (kill-buffer)
   239    240       (with-current-buffer buf
   240    241         (let (ent)
   241    242           (dolist (thread list)
................................................................................
   246    247                                  (cdr (assq 'messages (cdr thread))))
   247    248                                 (propertize
   248    249                                  (cdr (assq 'headline (cdr thread)))
   249    250                                  'face 'variable-pitch)))
   250    251                   ent))
   251    252           (setq-local tabulated-list-entries ent)
   252    253           (tabulated-list-print t t)
   253         -        (hl-line-highlight)))))
          254  +          (hl-line-highlight))))))
   254    255   
   255    256   (defun sbbs--thread-loader (status board id buf)
   256    257     "Callback function for `url-retrieve' when loading thread.
   257    258   
   258    259   The attribute ID determines what thread from board BOARD to
   259    260   load. STATUS is used to check for errors."
          261  +  (when (buffer-live-p buf)
   260    262     (when (plist-get status :error)
   261         -    (message "Error while loading: %s"
          263  +      (error "Error while loading: %s"
   262    264                (cdr (plist-get status :error))))
   263    265     (prog-mode)
   264    266     (forward-paragraph)
   265    267     (save-excursion
   266    268       (save-match-data
   267    269         (while (search-forward "#f" nil t)
   268    270           (unless (cadddr (syntax-ppss))
................................................................................
   285    287                         (cdr (assq 'headline thread))))
   286    288           (dolist (post (cadr (assq 'posts thread)))
   287    289             (sbbs--thread-insert-post post))
   288    290           (delete-blank-lines)
   289    291           (goto-char (point-min)))
   290    292         (rename-buffer (format "*reading /%s/%d*"
   291    293                                (sbbs--board-name board)
   292         -                             id)))))
          294  +                               id))))))
   293    295   
   294    296    ;; INTERACTIVE FUNCTIONS
   295    297   
   296    298   (defun sbbs-view-open (id)
   297    299     "Open thread ID in new buffer."
   298    300     (interactive (list (tabulated-list-get-id)))
   299    301     (let ((url (sbbs--board-url (format "/%d" id) t))