有时可能需要在单独的一行中开始段落中的每个句子。例如,这可以更容易区分大型文本文档,因为一个句子的更改不会影响整个段落。一些标记系统(例如* roff)也需要每个句子从新行开始。有没有办法在句子末尾加上`fill-paragraph`?
有没有办法,例如通过明智地重新定义paragraph-separate
和paragraph-start
,使fill-paragraph
在句子之间停止?
(注意:我使用Emacs 23.3.1)
更新:样品MDOC(的* roff)标记:这
The
.Nm
utility makes a series of passes with increasing block sizes.
In each pass, it either reads or writes (or both) a number of
non-consecutive blocks at increasing offsets relative to the ideal
alignment, which is assumed to be multiples of the block size.
The results are presented in terms of time elapsed, transactions per
second and kB per second.
这是三句话一个段落,每即使在上一行的第一个单词有空间,也可以单独开始。目前,fill-paragraph
将转换成
The
.Nm
utility makes a series of passes with increasing block sizes. In each
pass, it either reads or writes (or both) a number of non-consecutive
blocks at increasing offsets relative to the ideal alignment, which is
assumed to be multiples of the block size. The results are presented
in terms of time elapsed, transactions per second and kB per second.
这是我想要避免的。
更新:在重新句子和段落
我看到,我的问题是有点不清楚,因为我使用的术语“段落”是什么最终双方参考一下Emacs的调用一个段落,并作为我使用的任何处理器(groff,latex等)输出中的连续文本块。澄清,
- 我需要保持句子在一起没有任何空白行之间; groff不喜欢空行,而latex则将它们视为段落分隔符。
- 我需要
fill-paragraph
对单个句子进行操作,即我想将段落重新定义为在空白行或上一段落结束后开始的段落,并以句号结尾,后跟换行符或至少两个空白字符。 - 我很想有
fill-paragraph
将文本块分割成单独的句子,但我不认为这可以轻松完成。
举例来说,如果我键入以下内容:
The
.Nm
utility makes a series of passes with increasing block sizes.
In each pass, it either reads or writes (or both) a number of non-consecutive blocks at increasing offsets relative to the ideal alignment, which is assumed to be multiples of the block size.
The results are presented in terms of time elapsed, transactions per second and kB per second.
然后移动光标到以“在每一个通”开始的行,按M-q
,我应该得到以下几点:
The
.Nm
utility makes a series of passes with increasing block sizes.
In each pass, it either reads or writes (or both) a number of
non-consecutive blocks at increasing offsets relative to the ideal
alignment, which is assumed to be multiples of the block size.
The results are presented in terms of time elapsed, transactions per second and kB per second.
请注意,最后一句话是不变的。
嗯,如果Emacs的regexp语法支持零宽度可变长度的后顾断言,应该可以构造一个对应于Perl regexp的正则表达式。(?:\ n | \ s {2, })\ K \ S/s',它与第一个非空白字符后跟一个换行符或至少两个空白字符。 – DES
你已经失去了我。我发布的正则表达式何时失败?我假设您在输入每个句子后手动按回车,以便Emacs不必为您分割段落,只需在填充时尊重句子边界。 – Tyler
我不认为Emacs支持断言。 – Tyler