sbbs.el

Check-in [67d30a2317]
Login
Overview
Comment:Always kill HTTP response buffer after processing it
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 67d30a23170591c903b775fb7124e10475f2812d1291017d3bb1504ef6fdbd2f
User & Date: zge on 2022-01-22 18:49:52
Other Links: branch diff | manifest | tags
Context
2022-01-22
18:57
Kill thread buffers when quitting board buffer check-in: a3e4eb41e0 user: zge tags: master, trunk
18:49
Always kill HTTP response buffer after processing it check-in: 67d30a2317 user: zge tags: master, trunk
18:27
Add support for VIP-posting check-in: 46949449f3 user: zge tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified sbbs.el from [a4c9b26bff] to [1c7c7f43da].

442
443
444
445
446
447
448

449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471

472
473
474
475
476
477

478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510

511
512
513
514
515
516
517
                        'utf-8))

(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 (buffer-live-p buf)
    (when (plist-get status :error)
      (error "Error while loading: %s"
             (cdr (plist-get status :error))))
    (forward-paragraph)
    (sbbs--fix-encoding)
    (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 'sbbs--variable-pitch)))
                  ent))
          (setq-local tabulated-list-entries ent)
          (tabulated-list-print t t)
          (hl-line-highlight))))))


(defun sbbs--thread-loader (status id buf range)
  "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 (buffer-live-p buf)
    (when (plist-get status :error)
      (error "Error while loading: %s"
             (cdr (plist-get status :error))))
    (prog-mode)
    (forward-paragraph)
    (sbbs--fix-encoding)
    (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
        (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)
          (when range
            (sbbs--limit-to-range range))
          (if sbbs-open-at-last-post
              (sbbs-goto-end)
            (goto-char (point-min))))))))


 
;;; INTERACTIVE FUNCTIONS

(defun sbbs-open-externally ()
  "Open the current thread using `browse-url'."
  (interactive)







>
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>






>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







442
443
444
445
446
447
448
449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497

498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
                        'utf-8))

(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."
  (unwind-protect
      (when (buffer-live-p buf)
        (when (plist-get status :error)
          (error "Error while loading: %s"
                 (cdr (plist-get status :error))))
        (forward-paragraph)
        (sbbs--fix-encoding)
        (let ((list (read (current-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 'sbbs--variable-pitch)))
                      ent))
              (setq-local tabulated-list-entries ent)
              (tabulated-list-print t t)
              (hl-line-highlight)))))
    (kill-buffer)))

(defun sbbs--thread-loader (status id buf range)
  "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."
  (unwind-protect
      (when (buffer-live-p buf)
        (when (plist-get status :error)
          (error "Error while loading: %s"
                 (cdr (plist-get status :error))))
        (prog-mode)
        (forward-paragraph)
        (sbbs--fix-encoding)
        (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))))

          (with-current-buffer buf
            (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)
              (when range
                (sbbs--limit-to-range range))
              (if sbbs-open-at-last-post
                  (sbbs-goto-end)
                (goto-char (point-min)))))))
    (kill-buffer)))

 
;;; INTERACTIVE FUNCTIONS

(defun sbbs-open-externally ()
  "Open the current thread using `browse-url'."
  (interactive)