︙ | | | ︙ | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
(require 'text-property-search)
(require 'tabulated-list)
(require 'button)
(require 'url)
(require 'hl-line)
(require 'rx)
;; CUSTOMIZABLE DATA
(defgroup sbbs nil
"SchemeBBS client."
:group 'applications
:prefix "sbbs-")
(defcustom sbbs-boards
|
>
|
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
(require 'text-property-search)
(require 'tabulated-list)
(require 'button)
(require 'url)
(require 'hl-line)
(require 'rx)
;;; CUSTOMIZABLE DATA
(defgroup sbbs nil
"SchemeBBS client."
:group 'applications
:prefix "sbbs-")
(defcustom sbbs-boards
|
︙ | | | ︙ | |
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
"Face for code blocks in threads.")
(defface sbbs--post-header-face
'((nil :extend t
:inherit highlight))
"Face for post headers in the thread view.")
;; 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))
(defsubst sbbs--board-domain (board)
"Get domain part of a BOARD object."
|
>
|
>
|
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
"Face for code blocks in threads.")
(defface sbbs--post-header-face
'((nil :extend t
:inherit highlight))
"Face for post headers in the thread view.")
;;; 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))
(defsubst sbbs--board-domain (board)
"Get domain part of a BOARD object."
|
︙ | | | ︙ | |
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
(sbbs--board-name def))
"Board: ")
boards nil t "/" nil def)))
(if (stringp choice)
(cdr (assoc choice boards))
choice))))
;; UTILITY FUNCTIONS
(defun sbbs--reload-thread (&optional _ignore-auto _noconfirm)
"Function to reload an opened thread."
(when sbbs--thread-id (sbbs-view-open sbbs--thread-id)))
(defun sbbs--reload-board ()
"Function to regenerate thread index.
|
>
|
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
(sbbs--board-name def))
"Board: ")
boards nil t "/" nil def)))
(if (stringp choice)
(cdr (assoc choice boards))
choice))))
;;; UTILITY FUNCTIONS
(defun sbbs--reload-thread (&optional _ignore-auto _noconfirm)
"Function to reload an opened thread."
(when sbbs--thread-id (sbbs-view-open sbbs--thread-id)))
(defun sbbs--reload-board ()
"Function to regenerate thread index.
|
︙ | | | ︙ | |
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
((> nr current) (setq up (point))))))
(unless (and (eq 'highlight (get-text-property (point) 'face))
(looking-at-p "\\`#[[:digit:]]+"))
;; in case we are on the first character of a post, we shouldn't
;; jump back, since that would mean setting to point to NR-1.
(sbbs-read-previous 1)))
;; UI GENERATOR
(defconst sbbs--link-regexp
(rx-to-string
`(: bos
(or (: "/" (group-n 2 (+ alnum))
"/" (group-n 3 (+ digit))
"/" (group-n 4 (: (+ digit) (? "-" (+ digit)))
|
>
|
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
((> nr current) (setq up (point))))))
(unless (and (eq 'highlight (get-text-property (point) 'face))
(looking-at-p "\\`#[[:digit:]]+"))
;; in case we are on the first character of a post, we shouldn't
;; jump back, since that would mean setting to point to NR-1.
(sbbs-read-previous 1)))
;;; UI GENERATOR
(defconst sbbs--link-regexp
(rx-to-string
`(: bos
(or (: "/" (group-n 2 (+ alnum))
"/" (group-n 3 (+ digit))
"/" (group-n 4 (: (+ digit) (? "-" (+ digit)))
|
︙ | | | ︙ | |
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
(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--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
|
>
|
|
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
(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--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
|
︙ | | | ︙ | |
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
(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-show-all ()
"Show all hidden posts."
(interactive)
(sbbs-show-pop -1))
(defun sbbs-show-pop (&optional n)
|
>
|
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
(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-show-all ()
"Show all hidden posts."
(interactive)
(sbbs-show-pop -1))
(defun sbbs-show-pop (&optional n)
|
︙ | | | ︙ | |
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
(url-retrieve url #'sbbs--board-loader
(list (current-buffer)))
(switch-to-buffer (current-buffer))))))
;;;###autoload
(defalias 'sbbs #'sbbs-browse)
;; MAJOR MODES
(defvar sbbs-view-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") #'sbbs-view-open)
(define-key map (kbd "c") #'sbbs-view-compose)
map))
|
>
|
|
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
|
(url-retrieve url #'sbbs--board-loader
(list (current-buffer)))
(switch-to-buffer (current-buffer))))))
;;;###autoload
(defalias 'sbbs #'sbbs-browse)
;;; MAJOR MODES
(defvar sbbs-view-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") #'sbbs-view-open)
(define-key map (kbd "c") #'sbbs-view-compose)
map))
|
︙ | | | ︙ | |