From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gerald Wildgruber Subject: Re: org-forward-paragraph doesn't work programatically (called from Lisp) Date: Mon, 8 Oct 2018 07:32:02 +0200 Message-ID: <874ldxovfx.fsf@tu-berlin.de> References: <878t394rwr.fsf@tu-berlin.de> <87tvlxo8m6.fsf@nicolasgoaziou.fr> <87bm854i4k.fsf@tu-berlin.de> <87zhvps61b.fsf@kyleam.com> Reply-To: wildgruber@tu-berlin.de Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9O9K-0007Yp-M8 for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 01:32:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9O9H-0003ek-Fv for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 01:32:10 -0400 Received: from exchange.tu-berlin.de ([130.149.7.70]:19906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9O9H-0003e5-62 for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 01:32:07 -0400 In-Reply-To: <87zhvps61b.fsf@kyleam.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Kyle Meyer Cc: i@nickey.ru, emacs-orgmode@gnu.org, Nicolas Goaziou On Mo, Okt 08 2018, Kyle Meyer 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