[Top][All Lists]

[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: Gerald Wildgruber
Subject: Re: How to do a massive unfill paragraph operation over several hundred files?
Date: Mon, 8 Oct 2018 07:42:52 +0200
User-agent: mu4e 1.1.0; emacs 27.0.50

On Do, Okt 04 2018, Noam Postavsky <> wrote:

>> 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))))

Thanks Noam, this almost did it! but I couldn't see through a last problem, it 
sometimes worked, sometimes didn't. Here's the solution someone from the emacs 
Org mode mailing list pointed me to:

I had to UNFOLD the entries before working on them, even programmatically, via 

I do this now from a lisp buffer and both functions work exactly as expected:

single file:

(let ((fill-column most-positive-fixnum))
  (dolist (f (list "~/"))
    (with-current-buffer (find-file-noselect f)
      (while (not (eobp))

recursively through dir tree:

(let ((fill-column most-positive-fixnum))
  (dolist (f (directory-files-recursively
              "/dirs/with/org/files/" (rx (or ".org" ".outl") eos)))
    (with-current-buffer (find-file-noselect f)
      (while (not (eobp))

That's great; I'm glad it works now from within emacs itself (and not via sed, 
awk or tr as I tried before), harnessing all the knowledge the editor has of 
its own constructs, especially with some of the more complicated list and 
enumeration structures, -- all of them are correctly unfilled. This is solved 

Thanks again to everyone who contributed!


Sent with mu4e

reply via email to

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