[ prog / sol / mona ]

prog


Emacs mode for SchemeBBS markup

49 2020-06-06 00:15

>>47
Unfortunately it seems to not work in w3m either, although it was much closer so I assumed it did work and wrote the following ticket:

In the present version ‘sbbs-compose-format’ inserts the literal string “style” rather than the value of the argument ‘style’. Furthermore, ‘insert’ resets the region and makes it when setting the mark to the right of the pointer the ‘style’ is inserted directly instead of wrapping the region, to resolve this we have to save the value of the end of the region before inserting. Since the inserts at the start of the region are inserted before those at the end the ‘style’ inserted at the end are off by ‘(length style)’ this is corrected by reversing the end and start insertions. Lastly, ‘save-excursion’ saves the old position before the insertion of ‘style’ so it is ‘(length style)’ off, the ‘save-excursion’ can be pulled around the conditional to make ‘(forward-char (+ (length style)))’ common to both cases resolving this last issue.

(defun sbbs-compose-format (style)
  "Insert "
  (save-excursion 
    (if (region-active-p)
        (let ((start (region-beginning))
              (end (region-end)))
          (goto-char end)
          (insert style)
          (goto-char start)
          (insert style))
      (insert style style)))
  (forward-char (+ (length style)))) 
50 2020-06-06 00:28

>>49
The ‘+’ is unnecessary ‘(forward-char (length style))’ is correct and the ‘save-excursion’ should have caused it to be off ‘(* 2 (length style))’, but you get the idea.

86


VIP:

do not edit these