sbbs.el

Diff
Login

Differences From Artifact [40f6a50d8a]:

To Artifact [cec4081882]:


335
336
337
338
339
340
341


























342
343
344
345
346
347
348
349
350
351
352

353
354
355
356
357
358
359
         (dolist (o (overlays-at sbbs--last-spoiler))
           (when (overlay-get o 'sbbs-uncover-p)
             (delete-overlay o)))
         (setq sbbs--last-spoiler nil))))

 ;; URL.EL CALLBACKS



























(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))))
    (decode-coding-region (point-min) (point-max) 'utf-8)
    (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)))







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









<

>







335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

377
378
379
380
381
382
383
384
385
         (dolist (o (overlays-at sbbs--last-spoiler))
           (when (overlay-get o 'sbbs-uncover-p)
             (delete-overlay o)))
         (setq sbbs--last-spoiler nil))))

 ;; URL.EL CALLBACKS

(defun sbbs--fix-encoding ()
  "Convert the raw response after point to utf-8."
  (save-excursion
    ;; see http://textboard.org/prog/39/263
    (set-buffer-multibyte nil)
    (while (search-forward-regexp
            ;; rx generates a multibyte string, that confuses
            ;; search-forward-regexp, therefore the regexp literal
            ;; here
            "[\x80-\xff]\\(\\(?:\\\\[0-7]\\{3\\}\\)+\\)" 
            nil t)
      (let (new)
        (goto-char (match-beginning 1))
        (while (< (point) (match-end 1))
          (push (string-to-number (buffer-substring
                                   (+ (point) 1)
                                   (+ (point) 4))
                                  8)
                new)
          (forward-char 4))
        (replace-match (apply #'string (nreverse new))
                       nil t nil 1))))
  (set-buffer-multibyte t)
  (decode-coding-region (point) (point-max)
                        '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)))
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
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)
    (decode-coding-region (point) (point-max) 'utf-8)
    (save-excursion
      (save-match-data
        (while (search-forward "#f" nil t)
          (unless (cadddr (syntax-ppss))
            (replace-match "nil")))))
    (save-excursion
      (save-match-data







|







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
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