1

Is there in Emacs an inbuilt function to separate text into sentences?

Eg.,

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

into

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • 1
    Do `C-h f -sentence TAB` and see what functions are available. The common convention is that a sentence is terminated by a period, question mark, exclamation mark, with *two* spaces following. – NickD Mar 22 '22 at 19:05
  • 1
    Note that "separate text into sentences" is not possible in practice unless `sentence-end-double-space` is adhered to in the source text, or the source text is not arbitrary text (which might contain confusable `.` character usage). – phils Mar 23 '22 at 02:45

1 Answers1

1

There's no predefined function to do that. You can easily define one.

Or just use a keyboard macro. Use M-e (forward-sentence) to advance past the sentence end. Then use M-x forward-whitespace to advance past any whitespace. Then use C-q C-j C-q C-j to insert two newline characters.

C-x (
M-e
M-x forward-whitespace
C-q C-j C-q C-j
C-x )

Execute the keyboard macro using C-x e. Use C-u 9999 to run it 9999 times successively.


You can also convert the keyboard macro to a Lisp command, or code that by hand using forward-sentence, forward-whitespace, and (insert "\n\n").

Drew
  • 75,699
  • 9
  • 109
  • 225
  • M-e actually moves the cursor to the end of the paragraph, it won't stop after a full stop (point). Haven't found such function yet (to move to the end of a sentence). – Emmanuel Goldstein Mar 23 '22 at 08:00
  • Is your `M-e` bound to `forward-sentence`? And you can test whether it takes point to the beginning of a paragraph, and if so back it up. – Drew Mar 23 '22 at 14:45
  • It's bound to both org-forrward-sentence and forward-sentence – Emmanuel Goldstein Mar 23 '22 at 16:25