问题描述
我正在emacs开发一个文本注释系统,其中注释的格式是这样的。如果这是文本: Lorem ipsem por赞成
我需要这样注释:
{latin} Lorem imsem {/ latin} {西班牙语}赞成{/西班牙语}
所以我想做的是选择一个区域,然后运行一个函数或一个宏,它将提示标签名称,并将大括号,关闭/和标签名称插入到区域开始和结尾的缓冲区。
这可能很简单,但是我一直发现emacs lisp比较困惑,开始使用,因为我根本不经常使用它。
嗯,有一堆方法。 是一个,确保一堆各种xml / html模式有一个。
为了简单起见,您可以使用一些elisp,如:
(defun my-tag-region(be tag)
'tag'a region
(interactiver\\\
MTag for region: )
(save-excursion
(goto-char e)
(插入(格式{/%s}标签))
(goto-char b)
(插入(格式{%s}标签))))
I'm developing a text annotation system in emacs, where the format of the annotation is something like this. If this is the text:
Lorem ipsem por favor
I need to annotate it like this:
{latin}Lorem imsem{/latin} {spanish}por favor{/spanish}
So what I want to do is select a region and then run a function or a macro that will prompt for the tag name, and insert the curly braces, the closing / and the tag name into the buffer at the start and end of the region.
This is probably pretty straightforward, but I've always found emacs lisp to be rather confusing to get started with, because I don't use it very often at all.
Well, there are a bunch of ways. yasnippet
is one, and I'm sure a bunch of the various xml/html modes have one.
For simplicity, you can use some elisp like:
(defun my-tag-region (b e tag)
"'tag' a region"
(interactive "r\nMTag for region: ")
(save-excursion
(goto-char e)
(insert (format "{/%s}" tag))
(goto-char b)
(insert (format "{%s}" tag))))
这篇关于如何在emacs中标记文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!