gpt4 book ai didi

emacs - 有没有办法让 `fill-paragraph` 在句末停止?

转载 作者:行者123 更新时间:2023-12-04 15:47:41 26 4
gpt4 key购买 nike

有时希望将段落中的每个句子放在单独的行上。例如,这使得区分大文本文档变得更容易,因为一个句子的变化不会影响整个段落。一些标记系统(例如 *roff)还要求每个句子都从新行开始。

有没有办法,例如明智地重新定义paragraph-separateparagraph-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)的输出中最终作为连续文本 block 的内容ETC。)。澄清,
  • 我需要将句子放在一起,它们之间没有任何空行; 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.

    然后将点移动到以“In each pass”开头的行并按 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.

    请注意,最后一句未触及。

    最佳答案

    怎么样告诉paragraph-start查找以大写字母开头的任何行:

    "\f\\|[     ]*$\\|^[A-Z]"

    请注意,新部分是 \\^[A-Z]
    这应该适用于大多数情况,您只需要注意极少数情况下您的句子中间有一个大写字母,并且该句子恰好足够长,可以在该句子中间单词之前中断。

    编辑:您可能也想考虑缩进:
    "\f\\|[     ]*$\\|^[    ]*[A-Z]"

    方括号之间的空格包含一个空格和一个制表符。

    编辑:您需要关闭 case-fold-search为此,否则在匹配中不区分大写和小写字母!

    编辑:如果您只想关闭此功能的 case-fold-search,请将以下内容绑定(bind)到 M-q (您可以根据需要在本地或全局范围内执行此操作)。
    (defun my-fill-paragraph ()
    (interactive)
    (let ((case-fold-search nil))
    (fill-paragraph)))

    关于emacs - 有没有办法让 `fill-paragraph` 在句末停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7554324/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com