sbbs.el

Check-in [4d43170777]
Login
Overview
Comment:Add sbbs-format-word-at-point user option
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 4d43170777cf046c123096c3d8e16caf20470898044043c08f1f26f5647eee1e
User & Date: zge on 2022-01-24 09:22:48
Other Links: branch diff | manifest | tags
Context
2022-01-24
09:30
Prevent nobreak-space from being highlighted check-in: c728f51a59 user: zge tags: master, trunk
09:22
Add sbbs-format-word-at-point user option check-in: 4d43170777 user: zge tags: master, trunk
09:16
Fix type update from [d0b75dd168] check-in: c6c6a90cab user: zge tags: master, trunk
Changes

Modified sbbs.el from [2fdcb74ccb] to [a32d58a0ff].

66
67
68
69
70
71
72




73
74
75
76
77
78
79
(defcustom sbbs-open-at-last-post nil
  "Jump to last post in a thread when opening a thread."
  :type 'boolean)

(defcustom sbbs-kill-threads-on-quit t
  "Kill all thread buffers when quitting a board buffer."
  :type 'boolean)





(defface sbbs--semi-spoiler-face
  '((((background light)) :background "gray80" :foreground "black")
    (((background dark)) :background "gray20" :foreground "white"))
  "Face for spoiler text in threads.")

(defface sbbs--spoiler-face







>
>
>
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(defcustom sbbs-open-at-last-post nil
  "Jump to last post in a thread when opening a thread."
  :type 'boolean)

(defcustom sbbs-kill-threads-on-quit t
  "Kill all thread buffers when quitting a board buffer."
  :type 'boolean)

(defcustom sbbs-format-word-at-point t
  "Format the word at point if no region is active."
  :type 'boolean)

(defface sbbs--semi-spoiler-face
  '((((background light)) :background "gray80" :foreground "black")
    (((background dark)) :background "gray20" :foreground "white"))
  "Face for spoiler text in threads.")

(defface sbbs--spoiler-face
629
630
631
632
633
634
635

636
637
638
639
640
641
642










643
644
645
646
647
648
649
650
            sbbs--thread-id id
            sbbs--board board)
      (switch-to-buffer (current-buffer)))))

(defun sbbs-compose-format (style)
  "Insert string STYLE around region or point."
  (save-excursion

    (if (region-active-p)
        (let ((beg (region-beginning))
              (end (region-end)))
          (goto-char end)
          (insert style)
          (goto-char beg)
          (insert style))










      (insert style style)))
  (when (or (not (region-active-p)) (< (point) (mark)))
    (forward-char (length style))))

(defun sbbs-compose-format-code ()
  "Insert code syntax markers."
  (interactive)
  (sbbs-compose-format "```\n"))







>
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
|







633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
            sbbs--thread-id id
            sbbs--board board)
      (switch-to-buffer (current-buffer)))))

(defun sbbs-compose-format (style)
  "Insert string STYLE around region or point."
  (save-excursion
    (cond
     ((use-region-p)
      (let ((beg (region-beginning))
            (end (region-end)))
        (goto-char end)
        (insert style)
        (goto-char beg)
        (insert style)))
     (sbbs-format-word-at-point
      (save-mark-and-excursion
        (let ((bounds (bounds-of-thing-at-point 'word)))
          (if bounds
              (progn
                (set-mark (car bounds))
                (goto-char (cdr bounds))
                (sbbs-compose-format style))
            (let ((sbbs-format-word-at-point nil))
              (sbbs-compose-format style))))))
     ((insert style style))))
  (when (or (not (region-active-p)) (< (point) (mark)))
    (forward-char (length style))))

(defun sbbs-compose-format-code ()
  "Insert code syntax markers."
  (interactive)
  (sbbs-compose-format "```\n"))