user178047
user178047

Reputation: 1324

emacs fill-paragraph to consider only the current line and below?

Assume my cursor is at _

 This is line 1.
_This is line 2. 
 This is line 3.

If I use fill-paragraph (meta-q), emacs transforms the text like this.

 This is line 1.  This is line 2.  This is line 3.

But instead I expect this.

 This is line 1.
 This is line 2.  This is line 3.

Currently I have to insert additional blank line before line 2

 This is line 1.

_This is line 2. 
 This is line 3.

and then invoke fill-paragraph, but it's not very convenient.

Thanks

Upvotes: 1

Views: 81

Answers (2)

Sean
Sean

Reputation: 29772

Seems like a good candidate for advice:

(defadvice fill-paragraph (around start-filling-at-current-line activate)
  (save-restriction
    (narrow-to-region (line-beginning-position) (point-max))
    ad-do-it))

Upvotes: 1

gongzhitaao
gongzhitaao

Reputation: 6682

Or a simple function if you like

(defun fill-following-paragraph ()
  "Do fill-region from the current line to the end of the
buffer"
  (interactive)
  (fill-region (line-beginning-position) (point-max)))

Upvotes: 1

Related Questions