[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] A tidy file maketh a tidy mind?
From: |
Eric Schulte |
Subject: |
Re: [O] A tidy file maketh a tidy mind? |
Date: |
Tue, 14 Aug 2012 07:10:17 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) |
'Mash <address@hidden> 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.
Best,
--
Eric Schulte
http://cs.unm.edu/~eschulte
- Re: [O] The Quantified Shower (was: Introducing Octopress Exporter), (continued)
- Re: [O] The Quantified Shower (was: Introducing Octopress Exporter), Myles English, 2012/08/07
- Re: [O] The Quantified Shower (was: Introducing Octopress Exporter), Nick Dokos, 2012/08/07
- Re: [O] The Quantified Shower (was: Introducing Octopress Exporter), Nick Dokos, 2012/08/07
- Re: [O] The Quantified Shower, Bastien, 2012/08/07
- Re: [O] The Quantified Shower, brian powell, 2012/08/07
- Re: [O] The Quantified Shower, Karl Voit, 2012/08/08
- Re: [O] The Quantified Shower, Jambunathan K, 2012/08/08
- Re: [O] The Quantified Shower, Bastien, 2012/08/10
- [O] A tidy file maketh a tidy mind?, 'Mash, 2012/08/13
- Re: [O] A tidy file maketh a tidy mind?, Bastien, 2012/08/14
- Re: [O] A tidy file maketh a tidy mind?,
Eric Schulte <=
- Re: [O] A tidy file maketh a tidy mind?, 'Mash (Thomas Herbert), 2012/08/14
- Re: [O] A tidy file maketh a tidy mind?, Bastien, 2012/08/14
Re: [O] Introducing Octopress Exporter, Bastien, 2012/08/03