[ prog / sol / mona ]

prog


Emacs mode for SchemeBBS markup

77 2021-08-20 14:19

>>76
You can probably find something better but I now see what the narrowing is for. I think the following should only traverse the additional newline at the end of each paragraph a second time rather than the whole buffer, still it's not very elegant:

(defun sbbs--insert-sxml-par (sxml)
  "Insert paragraph contents SXML at point."
  (save-restriction
    (narrow-to-region (1- (point)) (point))
    (insert (sbbs--process-sxml sxml))
    (let (beg)
      (goto-char (point-min))
      (while (setq beg (next-single-property-change (point) 'action))
        ;; Buttons use overlays that cannot be passed in
        ;; strings. Therefore whenever a `activity' property was inserted into
        ;; the buffer, `make-button' has to be called once more to add the
        ;; actual overlay.
        (let ((end (or (next-single-property-change beg 'action) (point-max))))
          (make-button beg end 'action (get-text-property beg 'action))
          (goto-char end)))
      (goto-char (point-max)))
    (newline)))
86


VIP:

do not edit these