有时需要在一个单独的行中开始一个段落中的每个句子.例如,这使得更容易区分大型文本文档,因为一个句子的更改不会影响整个段落.一些标记系统(例如*roff)也要求每个句子在新行上开始.
有没有一种方法,例如,通过明智的重新定义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.
Run Code Online (Sandbox Code Playgroud)
这是一个包含三个句子的单个段落,每个句子都在一个单独的行上开始,即使前一行的第一个单词有空间.目前,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.
Run Code Online (Sandbox Code Playgroud)
这是我想要避免的.
更新:在句子和段落中
我看到我的问题有点不清楚,因为我使用术语"段落"来指代Emacs所谓的段落以及最终作为我使用的任何处理器的输出中的连续文本块(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.
Run Code Online (Sandbox Code Playgroud)
然后将点移动到以"每次通过"开头的行并按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.
Run Code Online (Sandbox Code Playgroud)
请注意,最后一句不受影响.
paragraph-start告诉我们寻找任何以大写字母开头的行怎么样:
"\f\\|[ ]*$\\|^[A-Z]"
Run Code Online (Sandbox Code Playgroud)
请注意,新部分是\\^[A-Z]
这应该适用于大多数情况,您只需要注意极少数情况,其中句子中间有一个大写字母,并且该句子恰好足够长,可以在中间句子单词之前中断。
编辑:您可能也想考虑缩进:
"\f\\|[ ]*$\\|^[ ]*[A-Z]"
Run Code Online (Sandbox Code Playgroud)
方括号之间的空间包含一个空格和一个制表符。
编辑:您需要关闭case-fold-search此功能才能工作,否则在匹配中无法区分大写和小写字母!
编辑:如果您想仅关闭此功能的大小写折叠搜索,请将以下内容绑定到M-q(您可以根据需要在本地或全局执行此操作)。
(defun my-fill-paragraph ()
(interactive)
(let ((case-fold-search nil))
(fill-paragraph)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
668 次 |
| 最近记录: |