51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
+
+
+
+
+
+
+
+
|
:type 'boolean)
(defface sbbs--spoiler-face
'((((background light)) :background "black" :foreground "black")
(((background dark)) :background "white" :foreground "white"))
"Face for spoiler text in threads.")
(defface sbbs--uncover-spoiler-face
'((((background light)) :background "black" :foreground "white")
(((background dark)) :background "white" :foreground "black"))
"Face for spoiler text in threads.")
(defface sbbs--code-face
'((((background light)) :background "gray89")
(((background dark)) :background "gray11"))
"Face for code blocks in threads.")
;; VARIABLES
(defvar-local sbbs--board nil
"Buffer local reference to current board.
See `sbbs-make-board'.")
(defvar-local sbbs--thread-id nil
"Buffer local reference to current thread id.
Used in thread and reply buffers.")
(defvar-local sbbs--limit-stack nil
"Stack of last limit specs.")
(defvar-local sbbs--last-spoiler nil
"Point of last spoiler visited.")
;; BOARD OBJECT AND FUNCTIONS
(defun sbbs-make-board (domain name &optional tls)
"Create board object, using DOMAIN, NAME and TLS flag."
(vector domain name tls))
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(insert " (VIP)"))
(newline 2)
(add-text-properties start (1- (point)) '(face highlight))
(set-text-properties (1- (point)) (point) nil)
(sbbs--insert-sxml (cdr (assq 'content (cdr post))))
(add-text-properties start (point) (list 'sbbs-thread-nr (car post)))))
(defun sbbs--uncover-spoiler ()
""
(cond ((eq (get-text-property (point) 'face) 'sbbs--spoiler-face)
(let* ((start (previous-property-change (1+ (point))))
(end (next-property-change (point)))
(o (make-overlay start end (current-buffer) t t)))
(overlay-put o 'face 'sbbs--uncover-spoiler-face)
(overlay-put o 'sbbs-uncover-p t))
(setq sbbs--last-spoiler (point)))
(sbbs--last-spoiler
(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."
|
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
|
-
+
+
+
|
(define-key map (kbd "f") #'sbbs-show-replies)
map))
(define-derived-mode sbbs-read-mode special-mode "SchemeBBS Read"
"Major mode for reading a thread."
(buffer-disable-undo)
(visual-line-mode t)
(setq-local revert-buffer-function #'sbbs--reload-thread))
(setq-local revert-buffer-function #'sbbs--reload-thread)
(add-hook 'post-command-hook #'sbbs--uncover-spoiler
nil t))
(defvar sbbs-compose-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") #'sbbs-compose-create)
map))
(defvar sbbs--font-lock
|