emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: 'Mash <mashdot@toshine.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: A tidy file maketh a tidy mind?
Date: Tue, 14 Aug 2012 07:10:17 -0600	[thread overview]
Message-ID: <874no57gtn.fsf@gmx.com> (raw)
In-Reply-To: 20120813115601.21602lsob8q1dpwk@webmail.tuffmail.net

'Mash <mashdot@toshine.net> writes:

> Morning,
> I just want to know if there is there exists a 'tidy' module/command
> that can be run on a file to tidy it?
> I often find myself going back and adding extra line breaks and
> padding, and wondering if there exists something that can do this for
> me?

While this doesn't exist currently, it should be fairly easy to
implement a set of rules which operate over the parsed file
representation generated by org-element.  This may be used to convert an
Org-mode buffer into an elisp list, manipulate the list, and then insert
the results as text back into a new buffer.

The code could look something like the following

    ;; -*- emacs-lisp -*-
    (let ((buf (org-element-parse-buffer))) ;; convert current buffer to ELisp
      (dolist (rule cleanup-rules) ;; run cleanup transformations on the buffer
        (setq buf (funcall rule buf)))
      (delete-region (point-min) (point-max)) ;; replace the buffer contents
      (insert (org-element-interpret-data buf))) ;; with the cleaned results

The only catch would be deciding what to add to the cleanup-rules.

Also, since Org-mode is plain text, I bet a couple of lines of sed or
perl could get you most of the way to a clean buffer.


Eric Schulte

  parent reply	other threads:[~2012-08-14 13:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01 23:21 Introducing Octopress Exporter Tom Alexander
2012-08-02  9:45 ` Aurélien Aptel
2012-08-02 13:44   ` Tom Alexander
2012-08-02 14:37   ` Jambunathan K
2012-08-06 22:28   ` Neil Smithline
2012-08-07  2:48     ` Neil Smithline
2012-08-07  9:52       ` The Quantified Shower (was: Introducing Octopress Exporter) Bastien
2012-08-07 12:32         ` The Quantified Shower Christopher J. White
2012-08-09 10:17           ` Aurélien Aptel
2012-08-07 13:07         ` The Quantified Shower (was: Introducing Octopress Exporter) Nick Dokos
2012-08-07 13:13           ` Nick Dokos
2012-08-07 17:27             ` The Quantified Shower Bastien
2012-08-07 20:39               ` brian powell
2012-08-08 12:46             ` Karl Voit
2012-08-08 17:30           ` Jambunathan K
2012-08-10  7:50             ` Bastien
2012-08-13 10:56               ` A tidy file maketh a tidy mind? 'Mash
2012-08-14  7:46                 ` Bastien
2012-08-14 13:10                 ` Eric Schulte [this message]
2012-08-14 13:55                   ` 'Mash (Thomas Herbert)
2012-08-14 21:50                   ` Bastien
2012-08-07 13:08         ` The Quantified Shower (was: Introducing Octopress Exporter) Myles English
2012-08-03  7:15 ` Introducing Octopress Exporter 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:

  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=874no57gtn.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mashdot@toshine.net \


* 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


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).