[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to do a massive unfill paragraph operation over several hundred
From: |
Noam Postavsky |
Subject: |
Re: How to do a massive unfill paragraph operation over several hundred files? |
Date: |
Wed, 3 Oct 2018 19:52:52 -0400 |
On Wed, 3 Oct 2018 at 06:11, Gerald Wildgruber <wildgruber@tu-berlin.de> wrote:
> (dolist (f argv)
> (with-current-buffer (find-file-noselect f)
> (mark-whole-buffer)
> (unfill-paragraph t)
> (org-forward-paragraph)
> (save-buffer)))
>
> It turns out that this works just on the FIRST paragraph of the file! Only
> this one is edited. The script does not move to the next paragraph.
Right, I guess the mark-whole-buffer thing doesn't have the intended
effect because it relies on transient-mark-mode, which is probably
tied up with the command loop.
> So, what works well in a kbd macro (moving point forward to next paragraph
> via org-forward-paragraph) does not in this script.
It makes sense that the paragraph movement doesn't work, because you
only call it once per file, so you unfill the 1st paragraph, move to
the 2nd, and then leave.
> Main problem seems to be: how to iterate through ALL paragraphs of the buffer
> programmatically, applying "fill-paragraph" each time anew.
Perhaps this?
(let ((fill-column most-positive-fixnum))
(dolist (f (directory-files-recursively
"dir/with/my/files/" (rx (or ".tex" ".org") eos)))
(with-current-buffer (find-file-noselect f)
(while (not (eobp))
(fill-paragraph)
(org-forward-paragraph))
(save-buffer))))
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Emanuel Berg, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Robert Pluim, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/02
- Re: How to do a massive unfill paragraph operation over several hundred files?, Noam Postavsky, 2018/10/02
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/03
- Re: How to do a massive unfill paragraph operation over several hundred files?,
Noam Postavsky <=
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/08
- Message not available
- Re: How to do a massive unfill paragraph operation over several hundred files?, Emanuel Berg, 2018/10/03
- Message not available
- Re: How to do a massive unfill paragraph operation over several hundred files?, Emanuel Berg, 2018/10/02
Message not available