0

The search-forward function takes four arguments:

(search-forward "target-string"
                limit-of-search
                what-to-do-if-search-fails
                repeat-count)

The second argument (limit-of-search) bounds the search. it is specified as a position in the buffer. In this case, the search can go to the end of the buffer, so no bound is set and the second argument is nil.

How to set it to just search until the end of the current paragraph?

Drew
  • 75,699
  • 9
  • 109
  • 225

1 Answers1

1

Although it seems not be officially documented, we find from this thread that thing-at-point can be used with paragraph.

Therefore, you can simply use (cdr (bounds-of-thing-at-point 'paragraph)).

For example:

(while (search-forward ". "
                       (cdr (bounds-of-thing-at-point 'paragraph))
                       t)
  (delete-backward-char 1)
  (insert "\n\n"))
dalanicolai
  • 6,108
  • 7
  • 23