unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Fill all comments in a buffer?
Date: Tue, 03 Oct 2017 05:58:38 +0200	[thread overview]
Message-ID: <86zi98sx01.fsf@zoho.com> (raw)
In-Reply-To: 9df19993-ab92-cb92-bd83-97ed68d4317d@nottheoilrig.com

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 ()
  (interactive)
  (goto-char (point-min))
  (while (search-forward-regexp "^;;" (point-max) t) ; NOERROR
    (let ((start (point)))
      (fill-comment-paragraph) )))

-- 
underground experts united
http://user.it.uu.se/~embe8573




  reply	other threads:[~2017-10-03  3:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02 21:32 Fill all comments in a buffer? Jack Bates
2017-10-03  3:58 ` Emanuel Berg [this message]
     [not found] ` <mailman.676.1507003137.27995.help-gnu-emacs@gnu.org>
2017-10-03  4:12   ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2017-10-03  2:52 Jack Bates

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86zi98sx01.fsf@zoho.com \
    --to=moasen@zoho.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).