From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: can I fill-paragraph some org data from the command line? Date: Wed, 12 Mar 2014 16:44:37 +0100 Message-ID: References: <87vbvjxxhl.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNlKv-00082q-Cg for emacs-orgmode@gnu.org; Wed, 12 Mar 2014 11:44:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNlKo-0003jk-4L for emacs-orgmode@gnu.org; Wed, 12 Mar 2014 11:44:53 -0400 In-Reply-To: <87vbvjxxhl.fsf@bzg.ath.cx> (Bastien's message of "Wed, 12 Mar 2014 16:11:50 +0100") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode Bastien writes: > Hi Alan, > > Alan Schmitt writes: > >> Do you have tools or an approach using emacs (as a command line tool) to >> suggest? > > I would call emacs in batch mode, applying some Elisp code to fill > each element. See `org-forward-element' and `org-fill-paragraph'. Thanks a lot for the suggestion, it works. I did not use `org-forward-element' as it does not iterate on sub-items. I simply do a `forward-line' to go done. Here is the code, if it's helpful to others. --8<---------------cut here---------------start------------->8--- #!/usr/local/bin/emacs --script ;;-*- mode: emacs-lisp;-*- ;; Found at http://superuser.com/a/487329/155265 from question ;; https://superuser.com/questions/31404/how-to-make-emacs-read-buffer-from-stdin-on-start (require 'org) (with-temp-buffer (progn ; read the file in the temporary buffer ; do not add a \n at the end (condition-case nil (let ((line (read-from-minibuffer ""))) (insert line) (while (setq line (read-from-minibuffer "")) (insert "\n") (insert line))) (error nil)) ; do what you want here (goto-char (point-min)) (while (< (point) (point-max)) (org-fill-paragraph) (forward-line)) (princ (buffer-string)))) --8<---------------cut here---------------end--------------->8--- Thanks again, Alan