sbbs.el

Diff
Login

Differences From Artifact [7a0569766c]:

To Artifact [e250c11b65]:


186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
...
224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
...
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
           (let* ((text (caddr it))
                  (link (plist-get (cadadr it) 'href)))
             (sbbs--insert-link text link)))
          (t (insert (prin1-to-string it)))))
  (insert ?\n))

(defun sbbs--insert-sxml (sxml)
  "Insert top-level SXML into buffer at point."
  (dolist (par sxml)
    (cond ((eq (car par) 'p)
           (sbbs--insert-sxml-par (cdr par)))
          ((eq (car par) 'blockquote)
           (let ((start (point))
                 (comment-start "> "))
             (sbbs--insert-sxml-par (cdadr par))
................................................................................
    (add-text-properties start (point) (list 'sbbs-thread-nr (car post)))))

  ;; URL.EL CALLBACKS

(defun sbbs--board-loader (status buf)
  "Callback function for `url-retrieve' when loading board.

Load results into buffer BUF."

  (when (plist-get status :error)
    (message "Error while loading: %s"
             (cdr (plist-get status :error))))
  (forward-paragraph)
  (let ((list (read (current-buffer))))
    (kill-buffer)
    (with-current-buffer buf
................................................................................
    (switch-to-buffer buf)
    (hl-line-highlight)))

(defun sbbs--thread-loader (status board id)
  "Callback function for `url-retrieve' when loading thread.

The attribute ID determines what thread from board BOARD to
load."
  (when (plist-get status :error)
    (message "Error while loading: %s"
             (cdr (plist-get status :error))))
  (prog-mode)
  (forward-paragraph)
  (save-excursion
    (save-match-data
................................................................................
      (sbbs-compose-mode)
      (setq sbbs--board board)
      (switch-to-buffer (current-buffer)))))

(defun sbbs-read-reply (arg)
  "Create buffer to start a reply in current thread.

With \\[universal-argument] add a reply reference to thread at
point."
  (interactive "P")
  (let ((id sbbs--thread-id)
        (nr (get-text-property (point) 'sbbs-thread-nr))
        (board sbbs--board))
    (with-current-buffer (generate-new-buffer "*new response*")
      (sbbs-compose-mode)
      (when (and arg (= (car arg) 4))
................................................................................
                                     (cdr (plist-get status :error)))
                          (kill-buffer buf)
                          (let ((sbbs--board board))
                            (sbbs--reload-thread))))
                  (list (current-buffer)))))

(defun sbbs-read-next (arg)
  "Move point to next thread header."
  (interactive "p")
  (dotimes (_ arg)
    (end-of-line)
    (catch 'found
      (while (search-forward-regexp "^#" nil t)
        (when (eq 'highlight (get-text-property (point) 'face))
          (throw 'found t)))))
  (beginning-of-line))

(defun sbbs-read-previous (arg)
  "Move point to previous thread header."
  (interactive "p")
  (dotimes (_ arg)
    (catch 'found
      (while (search-backward-regexp "^#" nil t)
        (when (eq 'highlight (get-text-property (point) 'face))
          (throw 'found t)))))
  (beginning-of-line))







|







 







|
>







 







|







 







|
|







 







|










|







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
...
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
           (let* ((text (caddr it))
                  (link (plist-get (cadadr it) 'href)))
             (sbbs--insert-link text link)))
          (t (insert (prin1-to-string it)))))
  (insert ?\n))

(defun sbbs--insert-sxml (sxml)
  "Insert top level SXML into buffer at point."
  (dolist (par sxml)
    (cond ((eq (car par) 'p)
           (sbbs--insert-sxml-par (cdr par)))
          ((eq (car par) 'blockquote)
           (let ((start (point))
                 (comment-start "> "))
             (sbbs--insert-sxml-par (cdadr par))
................................................................................
    (add-text-properties start (point) (list 'sbbs-thread-nr (car post)))))

  ;; 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 (plist-get status :error)
    (message "Error while loading: %s"
             (cdr (plist-get status :error))))
  (forward-paragraph)
  (let ((list (read (current-buffer))))
    (kill-buffer)
    (with-current-buffer buf
................................................................................
    (switch-to-buffer buf)
    (hl-line-highlight)))

(defun sbbs--thread-loader (status board id)
  "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"
             (cdr (plist-get status :error))))
  (prog-mode)
  (forward-paragraph)
  (save-excursion
    (save-match-data
................................................................................
      (sbbs-compose-mode)
      (setq sbbs--board board)
      (switch-to-buffer (current-buffer)))))

(defun sbbs-read-reply (arg)
  "Create buffer to start a reply in current thread.

With \\[universal-argument] interactivly, or a non-nil ARG, add a
reply reference to thread at point."
  (interactive "P")
  (let ((id sbbs--thread-id)
        (nr (get-text-property (point) 'sbbs-thread-nr))
        (board sbbs--board))
    (with-current-buffer (generate-new-buffer "*new response*")
      (sbbs-compose-mode)
      (when (and arg (= (car arg) 4))
................................................................................
                                     (cdr (plist-get status :error)))
                          (kill-buffer buf)
                          (let ((sbbs--board board))
                            (sbbs--reload-thread))))
                  (list (current-buffer)))))

(defun sbbs-read-next (arg)
  "Move point ARG posts forward."
  (interactive "p")
  (dotimes (_ arg)
    (end-of-line)
    (catch 'found
      (while (search-forward-regexp "^#" nil t)
        (when (eq 'highlight (get-text-property (point) 'face))
          (throw 'found t)))))
  (beginning-of-line))

(defun sbbs-read-previous (arg)
  "Move point ARG posts backwards."
  (interactive "p")
  (dotimes (_ arg)
    (catch 'found
      (while (search-backward-regexp "^#" nil t)
        (when (eq 'highlight (get-text-property (point) 'face))
          (throw 'found t)))))
  (beginning-of-line))