@@ -69,8 +69,12 @@ (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")) @@ -632,16 +636,27 @@ (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))) + (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 ()