我正在尝试执行一个emacs命令,该命令将当前选定的文本内容包装到phpbb斜体标签(即[i] ... [/ i])中。因此,这几乎是这个较旧的question的副本,只是那里的答案给出了以标签为参数的解决方案。
因此,我尝试按照我的需要将旧问题中可接受的解决方案进行调整,如下所示:
(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]"))))
但是当我尝试它时,它具有意外的行为:如果我在由以下组成的一行中选择由两个单词“棕色毛毛虫”组成的区域,则
The brown caterpillar said to the lazy dog
然后执行M-x wrap-in-phpbb-italics-tag
,结果是
The [i]brown caterpil[/i]lar said to the lazy dog
我做错了什么?