On Mo, Okt 08 2018, Kyle Meyer <k...@kyleam.com> wrote:
> 2) Your code doesn't account for hidden text in the buffer. You could > call `(org-show-all)'. > > I suspect #2 is why you're not seeing the results you expect. Wow, thanks a lot Kylie, this was it! I never thought of having to unfold the Org mode entries in a buffer when opening in a non interactive way. 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 "~/lorem.org")) (with-current-buffer (find-file-noselect f) (org-show-all) (while (not (eobp)) ;; (mark-whole-buffer) (fill-paragraph) (org-forward-paragraph)) (save-buffer)))) 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) (org-show-all) (while (not (eobp)) (fill-paragraph) (org-forward-paragraph)) (save-buffer)))) 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 now. Thanks again Gerald. -- Sent with mu4e