[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fill all comments in a buffer?

From: Emanuel Berg
Subject: Re: Fill all comments in a buffer?
Date: Tue, 03 Oct 2017 05:58:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Jack Bates wrote:

> Is there a way to fill (reflow) all comments
> in a buffer? Similar to how I can spellcheck
> all comments with
> ispell-comments-and-strings?
> I can go to each comment and type M-q -- I'd
> like to do it all at once.

Is that a good idea? It happens that people
have code blocs commented out. That code will
be screwed if filled.

Can't you do it manually? If you can't (too
much), probably you have too long files!

Anyway, try this.

Change the "^;;" to the syntax of your
language(s) or get it from Emacs (careful!).
Beware one line comments, like this

    i++; // increase i by 1

should not be filled, so stick to the ^ is what
I'd (not) do :)

(defun fill-all-comments ()
  (goto-char (point-min))
  (while (search-forward-regexp "^;;" (point-max) t) ; NOERROR
    (let ((start (point)))
      (fill-comment-paragraph) )))

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]