emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-forward-paragraph doesn't work programatically (called from


From: Gerald Wildgruber
Subject: Re: [O] org-forward-paragraph doesn't work programatically (called from Lisp)
Date: Mon, 8 Oct 2018 07:32:02 +0200
User-agent: mu4e 1.1.0; emacs 27.0.50

On Mo, Okt 08 2018, Kyle Meyer <address@hidden> 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



reply via email to

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