sbbs.el

Diff
Login

Differences From Artifact [a4c9b26bff]:

To Artifact [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)