emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Lieterate Programming for configuration settings
@ 2012-03-05  8:09 Vladimir Lomov
  2012-03-05 14:58 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Lomov @ 2012-03-05  8:09 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

--------------------------------- 8< ---------------------------------

#+TITLE: Literate Programming for configuration settings
#+AUTHOR: Vladimir Lomov
#+OPTIONS: toc:nil

* Literate Programming

I'm trying to use the Literate Programming to describe my set up of
Openbox and my workflow with Linux.

The main problem is with Openbox. I set up convenient (for me)
keybindings, like "W-x f k" to launch Krusader file manager, and now I
want to describe all my keybindings.

I see this as follow: from one source I get Org table (keybind and
description) and xml code (to be included into ~rc.xml~ using noweb).

At first, I thought about table in org file with three columns:

| Keybind | Code | Description |
|---------+------+-------------|

but I don't know how to exclude second column in html export and how
to generate xml code excluding the third column.

So I decided to use plain txt files with the same information.

My question is: how to get table in html export and xml file with
code?

I wrote two shell scripts, first gives org table from txt file, the
second generates xml code from the same txt file, but can't figure out
how to use them with org.

(My next step would be to put both: plain txt file content and shell
script code into one org file, if my idea would work.)

** Example

Below is example of plain text file. I don't need ~example.txt~
except for shell script to generate org table and xml code, if it is
possible to get both without extracting text file it would be great.

#+name: example.txt
#+begin_src text :exports none :tangle example.txt
"Alt-F2"	'<action name="execute"><command>gmrun</command></action>'	"Run gmrun, very useful tool"
"Alt-F4"	'<action name="Close"/>'	"Close application window"
"Alt-F9"	'<action name="Iconify"/>'	"Iconify to task bar"
"Alt-Tab"	'<action name="NextWindow"/>'	"Switch focus to next window"
"Alt-S-Tab"	'<action name="PreviousWindow"/>'	"Switch focus to previous window"
"Alt-space"	'<action><menu>client-menu</menu></action>'	"Show application window menu"
#+end_src

This shell script used standalone gives correct org table. I also
don't need it except it generates org table.

#+name: txt2org-table
#+begin_src sh :exports none
#!/bin/bash

###
# Read a txt file and write to stdout it as Org table.
###

_data="$1"

###
# Each line has three fields: keystroke, xml code and description. For table the 1 and 3 are needed.
###

echo "|  Keybind   |     Description      |"
echo "+------------+----------------------|"
while IFS='	' read -r kb code descr
do
  [[ ${kb} = \#* ]] && continue
  echo "| ${kb//\"/~} | ${descr//\"} |"
done < "${_data}"
echo "+------------+----------------------|"

exit 0
#+end_src

** My real goal

Ideally I want to have a table (like <<example.txt>>) in org file, when
I export org file to html there must be table with "Keybind" and
"Description" and the same org file should generate ~rc.xml~ (I assume
it is possible to insert results of script run in place of <<NOWEB>>).

---
Thanks in advance, Vladimir Lomov

P.S. Sorry if I description were to obscure.

P.P.S. Side note: why then 'tangled' example.txt the first line is empty one?

-- 
<kceee^> I hate users
<knghtbrd> you sound like a sysadmin already!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lieterate Programming for configuration settings
  2012-03-05  8:09 Lieterate Programming for configuration settings Vladimir Lomov
@ 2012-03-05 14:58 ` Eric Schulte
  2012-03-06 23:57   ` Vladimir Lomov
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2012-03-05 14:58 UTC (permalink / raw)
  To: Vladimir Lomov; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

Hi Vladimir,

[...]
>
> At first, I thought about table in org file with three columns:
>
> | Keybind | Code | Description |
> |---------+------+-------------|
>
> but I don't know how to exclude second column in html export and how
> to generate xml code excluding the third column.
>

See the attached example Org-mode file, it does what you describe above.

>
> P.P.S. Side note: why then 'tangled' example.txt the first line is empty one?

Set ":padline no" on the tangled block to change this behavior (as in
the attached example).

Best,


[-- Attachment #2: different-export-and-tangle.org --]
[-- Type: test/x-org, Size: 1043 bytes --]

[-- Attachment #3: Type: text/plain, Size: 47 bytes --]


-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lieterate Programming for configuration settings
  2012-03-05 14:58 ` Eric Schulte
@ 2012-03-06 23:57   ` Vladimir Lomov
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Lomov @ 2012-03-06 23:57 UTC (permalink / raw)
  To: emacs-orgmode

Hello,
** Eric Schulte [2012-03-05 07:58:59 -0700]:

> Hi Vladimir,

> [...]

>> At first, I thought about table in org file with three columns:

>> | Keybind | Code | Description |
>> |---------+------+-------------|

>> but I don't know how to exclude second column in html export and how
>> to generate xml code excluding the third column.


> See the attached example Org-mode file, it does what you describe above.

Thanks!

>> P.P.S. Side note: why then 'tangled' example.txt the first line is empty one?

> Set ":padline no" on the tangled block to change this behavior (as in
> the attached example).

And again, thanks!

I tried your example and it works as I expect, so I'll try to adopt my
files and report result.

> Best,

---
WBR, Vladimir Lomov


-- 
The reason ESP, for example, is not considered a viable topic in contemoprary
psychology is simply that its investigation has not proven fruitful...After
more than 70 years of study, there still does not exist one example of an ESP
phenomenon that is replicable under controlled conditions.  This simple but
basic scientific criterion has not been met despite dozens of studies conducted
over many decades...It is for this reason alone that the topic is now of little
interest to psychology...In short, there is no demonstrated phenomenon that
needs explanation.
-- Keith E. Stanovich, "How to Think Straight About Psychology", pp. 160-161

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-06 23:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-05  8:09 Lieterate Programming for configuration settings Vladimir Lomov
2012-03-05 14:58 ` Eric Schulte
2012-03-06 23:57   ` Vladimir Lomov

Code repositories for project(s) associated with this 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).