From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: can I fill-paragraph some org data from the command line?
Date: Wed, 12 Mar 2014 16:44:37 +0100 [thread overview]
Message-ID: <m27g7z5sm2.fsf@polytechnique.org> (raw)
In-Reply-To: <87vbvjxxhl.fsf@bzg.ath.cx> (Bastien's message of "Wed, 12 Mar 2014 16:11:50 +0100")
Bastien <bzg@gnu.org> writes:
> Hi Alan,
>
> Alan Schmitt <alan.schmitt@polytechnique.org> 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
next prev parent reply other threads:[~2014-03-12 15:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 12:25 can I fill-paragraph some org data from the command line? Alan Schmitt
2014-03-12 15:11 ` Bastien
2014-03-12 15:44 ` Alan Schmitt [this message]
2014-03-12 16:11 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m27g7z5sm2.fsf@polytechnique.org \
--to=alan.schmitt@polytechnique.org \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).