emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] emacs regex work done within literate org-mode?


From: Lawrence Bottorff
Subject: [O] emacs regex work done within literate org-mode?
Date: Thu, 17 Apr 2014 14:53:10 -0500

A while back I declared war against what I call "tunneling" i.e., the typical programmer practice of just working along on something without making any sort of notes or comments . . . and that day's "Werdegang" as they say in German (steps, procedure, process?) being only as good as your memory of it. I see org mode as capable of is beating tunneling by actually writing a story of your day's work inside an org-mode file.

For example, I'm working on a database project where I'd like to do lots of emacs regex to get a file of comma delimited lines turned into sql INSERT-ready statements. Here's what the VALUES of my INSERT look like:

(UPPER (SUBSTRING(MD5(RAND()) FROM 1 FOR 6)), ,'P',1)

the first part up until ...FOR 6)) is just a six-place hex id generator (mysql syntax) for the record, then comes an empty field, then 'P' etc. So I'm looking to shove a chunk of text from my comma delimited file into the empty field. e.g.,

(...FROM 1 FOR 6)),'new thing 1','P',1)

where 'new thing 1' came from a line in the comma delim file. Right, so I can do this with Emacs' regex in a one-off tunneling sort of way, but how could I do this inside an org-mode file? I'm guessing I would need to use elisp (perl, lisp, etc) in a literate way, i.e., my org-mode file would have code sections and results sections. But could the results of running literate code then be fed into the next section of literate code? I need to run code on data, get results, run more code on that -- all while interactively composing my org-mode file. Is this possible?

Basically, I'm looking for something better than the typical Emacs REPL session where you have the option of simply saving the entire session's REPL buffer. But I don't want it to be so cumbersome that I'm writing a tutorial, either -- even though that's what I'm sort of doing. The dream would be that a whole day's work could be contained in org-mode files -- both the code and the description of what's going on and how things came (in)to be(ing).

LB

reply via email to

[Prev in Thread] Current Thread [Next in Thread]