Following the advice given here, I wrote the following code to enclose the text selection in phpbb italics tags :
(defun wrap-in-phpbb-italics-tag (b e)
"does what its name says."
(interactive "r")
(save-excursion
(goto-char b)
(insert (format "[i]"))
(goto-char e)
(insert (format "[/i]"))))
This code almost does what I want : the left tag is positioned correctly but the right tag is three characters too early.
Thus, if the selected goes Adjust end index in selected region
, the result will be [i]Adjust end index in selected reg[/i]ion
.
I tried to fix it as follows, replacing the (e)
with (e+3)
:
(defun wrap-in-phpbb-italics-tag (b e)
"does what its name says."
(interactive "r")
(save-excursion
(goto-char b)
(insert (format "[i]"))
(goto-char (e+3))
(insert (format "[/i]"))))
But with this new code, the right tag simply disappears. What is going on here ? How can I fix this ?