emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "'Mash (Thomas Herbert)" <mashdot@toshine.net>
To: Eric Schulte <eric.schulte@gmx.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: A tidy file maketh a tidy mind?
Date: Tue, 14 Aug 2012 14:55:48 +0100	[thread overview]
Message-ID: <20120814135547.GC11746@grace.toshine.net> (raw)
In-Reply-To: <874no57gtn.fsf@gmx.com>

On 2012-08-14 07:10-0600, Eric Schulte wrote:
> '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.

Thanks, I need to spend some time to look at rules. But my most
common clean-up is really just adding some spacing/padding for
example. Would be handy to implement in a save-hook along with org-sort.

--- cluttered ---
* Lorem ipsum dolor sit amet


** TODO consectetuer adipiscing elit
   Sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
   aliquam erat volutpat.
   SCHEDULED: <2012-08-09 Thu 20:30>
** TODO  quis nostrud exerci tation ullamcorper
   SCHEDULED: <2012-08-08 Wed 10:30>
   Nam liber tempor cum soluta nobis eleifend option congue nihil
   imperdiet doming id quod mazim placerat facer possim assum.
** TODO Ut wisi enim ad minim veniam...

--- tidier ---
* Lorem ipsum dolor sit amet
** TODO  quis nostrud exerci tation ullamcorper
   SCHEDULED: <2012-08-08 Wed 10:30>
   Nam liber tempor cum soluta nobis eleifend option congue nihil
   imperdiet doming id quod mazim placerat facer possim assum.

** TODO consectetuer adipiscing elit
   SCHEDULED: <2012-08-09 Thu 20:30>
   Sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
   aliquam erat volutpat.

** TODO Ut wisi enim ad minim veniam...

  reply	other threads:[~2012-08-14 13:56 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
2012-08-14 13:55                   ` 'Mash (Thomas Herbert) [this message]
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:
  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=20120814135547.GC11746@grace.toshine.net \
    --to=mashdot@toshine.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \
    /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).