2009-09-11

emacs lisp function to copy dir and all sub dir

perm url with updates http://xahlee.org/emacs/modernization_elsip_copy_dir.html

Emacs Lisp Suggestion: A Function For Copying and Deleting Whole Dir

Xah Lee, 2009-09-11

It appears to me, this is a good suggestion.

There lacks a function to copy and delete directories recursively.

in the elisp manual, the closest is: (info "(elisp)Create/Delete Dirs")

it would be good to have a function that copy a whole dir, and another for deleting whole dir.

Emacs does implement them in dired, or in eshell, apparently, but it's not easy to use them.

many scripting langs provide such functions, and is very convenient.

for deleting dir, perhaps this can be implemented:

(delete-directory dirname &optional recursive)

for copying dir, perhaps it can be modeled on copy-file:

(copy-file oldname newname &optional ok-if-exists time)

these should be perhaps few hours to implement for elisp developers, perhaps by just pulling existing implementation from dired or eshell.

Once implemented, they'd be standard functions in elisp manual. They would be great convience for average elisp coders.

As a personal example, i needed to both copy dir recursively and also delete whole dir, in my use of elisp as a text processing lang. So far i've been just calling shell. e.g.

(shell-command (concat "cp -R " fromDir " " toDir))
(shell-command (concat "find " destDir " -type d -name \"xx*\" -exec rm -R {} \\;"))

my script worked well in the past 2 years, but replying on unix shell has many complications. For example, recently i need my script to work on Windows. With Windows, there's many complications, e.g. which unix shell you use cygwin, msys, their config, their path env var config in emacs, both are inter-related to which emacs distribution one is using (e.g. what shell runs when you do M-x shell). Then, recently in one emacs distro i'm trying out eshell (in hope that it perhaps more cross-platform than M-x shell or Lennart emacsW23's shell, cmd-shell, msys-shell), but discovered that eshell chocks on this standard bash syntax:

find -name "*el" -exec rm {} \;

(reported in bug #4406. Doesn't work when called as shell-command neither)

In short, something trivial turns out to be 5 or more hours to trying to get it work.

emacs + elisp is a great text processing lang, and one big advantage is that it is cross platform. So, all things considered, i think the suggestion in this report is a very good one, in particular its ratio of impact/ease-to-implement is relatively high.

if i eventually got a solution from looking into dired or eshell for copying/deleting dir, i'll update this report with code for draft implementation.

Thanks.

PS: this essay is reported to FSF as bug#4408.

Lyrics Appreciation: Damn! (YoungBloodZ)

perm url with updates: http://xahlee.org/Periodic_dosage_dir/sanga_pemci/damn.html

Damn! (Youngbloodz)

Xah Lee, 2009-09-11

Damn! (song) by YoungBloodZ.

A fantastic black gangster pop rap. Smooth rapping, soothing beat, and a lyrics that's a satisfying fire grammarians to chew.

Title: Damn
Lyrics:
Music:
Singer: Sean Paul, Lil Jon, J-Bo
「• Sean Paul = Sean Paul and J-Bo are rap duo, forming the band YoungBloodZ. Lil Jon is a guest singer in this song.」
「• dem hoes = them whores.」
「• Eastside Boyz = seems to be a band or album associated with Lil Jon. Not sure what eastside boys refers to originally. Possibly East Coast blacks.」
「• Attic Crew = The Attic may refer to Eddie's Attic, a music club in Decatur, Georgia.」
"Damn!"(feat. Lil' Jon)
[Intro]
OK, OK, OK
This Sean Paul, Lil Jon. J-Bo, Youngbloodz
You already know how we do it homeboy
It's A-Town (105 Road for dem hoes)
It's A-Town (east side for dem hoes), Attic Crew you already know
Lil John, Eastside Boyz and yo boy Sean Paul let me tell ya like dis here boy(lets go)
「• in the month of February = ?」
「• display = ? what does this sentence refer to?」
「• K's in = ?」
「• fo = for.」
「• fo sho = for show.」
「• wit = with.」
「• no Cris = ?」
「• cold billy = ?」
「• Toe-tag = A tag tied to toe, for purposes of identifying corpses. Toe tag
「• bounce like rubber = probably means dropping dead.」
[Sean Paul]
They callin' me to come back to the streets, Sean P. a.k.a Sharp Crease
Said it was necessary, these sucka niggaz out here very scary
They comin whole they livin' in the month of February
OK then put a sissy nigga on display then
Kick in tha door and have my folk dem bring dem K's in
I'm still Attic A-double T-I-C
It ain't a hoe out there fo real who don't know 'bout me
Bitch I'm fo sho wit it don't make me pop that trunk to the 'Lac
Bitch I will go get it and I ain't selfish I will let you and your hoe feel it
Won't catch me sippin' on no Cris and got a cold billy
It's Youngbloodz A-Town malt liquor sippin', comin' straight from the gutter
Toe-tag a motherfucker, leave 'em under a cover
Lil John he drop the beat that make ya bounce like rubber
Sean Paul he tote the heat to make ya mug then slug ya yeah
[Hook: Lil' Jon]
If you don't give a damn, we don't give a fuck
If you don't give a damn, we don't give a fuck
If you don't give a damn, we don't give a fuck
If you don't give a damn, we don't give a fuck
Don't start no shit, it won't be no shit
Don't start no shit, it won't be no shit
Don't start no shit, it won't be no shit
Don't start no shit, it won't be no shit
「• fly suits = ?」
「• gators = alligator skin shoes」
「• slizzard = ?」
「• Chevy = Chevolet, a brand of car popular with Blacks.」
「• crunk = A style of music that originated from southern hip hop in the early 1990s, like this song. The word origin may be crazy+drunk. Crunk
[J-Bo]
I post up get to it, drink hand in hand
They call me Mr. Herringbone cuz that's my right hand man
Old school straight foolish like no other indeed
With Lil John it's Youngbloodz they crunk as can be
Attic Crew 105 that's if you lookin to rumble
Cock back bust aim now I done got yo number
In the club you gone feel it when it drop this summer
Like rain we gone pour and hit you hard like thunder
Cuz in the Dirty we dem boys that drank you under the table
Where dem niggaz pimp hoes in fly suits and gators
In my Chevy so super I'm the one to call
Just dial 1-800-430 slash ALCOHOL
And dawg I'm not the one that you really just wanna clown
I'm cool in my way, but shit still I shut 'em down
And piss on them haters J-Bo he cuts a fool
In the cut 'bout slizzard somewhere that's how we do
[Sean Paul]
Out of town hard heads get swiss cheesed up
And you gon' need more than stitches to patch that leak up
Chump like me up my mouth TB'd up
With the plush leather guts steady grippin' the butt
Oh you fo sho with it, then pull yo pistol
Show a nigga you ain't hoe with it
And I ain't selfish I will let you and your folk feel it
Talkin' big boy shit
Me muggin' like a motherfucker my hand on my dick
「• potna = partner.」
「• lock and load = A military command to put a weapon's safety catch on, and load it with ammunition.」
「• South = The group is from Atlanta, Georgia. Georgia is one of the 7 or so states, that's most populated with blacks, all in the south east of US. See: Race Distribution in the USA.」
「• 85 = Must be Interstate 985.」
[J-Bo]
Cuz at a grip we keep it jumpin' like it ain't nuttin' new
We started off with Shake Em Off so look potna oh guess who
It's them boys from the bottom who took you down 85
And hit you with that U-Way so ROOKIE don't be surprised
We buckin' blowin' killa and sippin' on something good
I'm peepin' out the scenery and wishin' a nigga would
In case it just might pop I'm 'bout ready to lock and load
To take you thru the South to show you how we throw dem bows

Listen to the song. In particular, listen for accent, dig the slang, and chew on the culture.

The Amercian blacks accent typically drop consonants. In particular, in their lyrics, they emphasize it by changing the spelling. For example, in this particular song, we have:

fo = for
with = wit
s = z
whore = hoe
this = dis
them = dem
partner = potna

2009-09-07

Math Notations, Computer Languages, and the “Form” in Formalism

perm url with updates Math Notations, Computer Languages, and the “Form” in Formalism

Math Notations, Computer Languages, and the “Form” in Formalism

On Sep 5, 7:41 am, slawekk <skoko...@yahoo.com> wrote:

Isabelle's presentation layer is well integrated with LaTeX and you can use math notation in (presentation of) proofs.

my previous post was quickly written and didn't clearly bring about my point.

The point is, that formalism in mathematics, consistency of math notation issues (for human), math notation language systems (TeX, Mathematica, MathML), and calculational proof movement (a la Edsger Dijkstra), and computer algebra systems, and theorem proving systems, and computer language syntax, all of the above, should be unified into one single entity, and is today very much doable, in fact much of it is happening in disparate communities, but as far as i know i do not think there's any literature that expresses the idea that they should all be rolled into one.

Let me address this a bit quickly without trying to write some coherent essay.

few things to note:

Theorem proving systems and computer algebra systems as unified tool is very much a need and is already happening. (e.g. there's a project i forgot the name now that tries to make Mathematica into a theorem proving system a la ocaml)

Theorem proving systems (isabell, hol, coq etc, “proof assistants” or “automated proof systems”) and mathematics foundation by formalism should be unified. This active research the past 30 or more years, and is the explicit goal of the various theorem proving systems.

Math notation consistency issues for human communication, as the calculational proof movement by Dijkstra, and also Stephen Wolfram criticism of traditional notation and Mathematica's StandardForm, is actually one single issue. They should be know as one single issue, instead of Calculational Proof movement happening only in math pedagogy community and Mathematica in its own community.

Math notation issues and computer language syntax and logic notation syntax is also largely the same issue. Computer languages, or all computer languages, should move towards a formalized syntax system. I don't think there's much literature on this aspect (in comparison to other issues i mentioned in this essay). Most of today's computer languages's syntax are ad hoc, with no foundation, no consistency, no formal approach. e.g. especially bad ones are Ocaml, and all C-like langs such as C, C++, Java. Shell langs are also good examples of extremely ad hoc: e.g. bash, perl, PowerShell. There are langs that are more based on a consistent syntax system that are more or less can be reduced to a formal approach. Of those i know includes Mathematica, XML (and lots derivatives e.g. MathML) and lisps also. Other langs i don't know much but whose syntax i think are also close to a formal system are: APL, tcl.

My use of the phrase “syntax with formal foundation” or “syntax system” is a bit fuzzy and needs more thinking and explanation... but basically, the idea is that computer language's syntax can be formalize in the same way we trying to formalize mathematics (albeit the problem is much simpler), so that the syntax and grammar can be reduced to few very simple formal rules in parsing it, is consistent, easy to understand. Mathematica and XML are excellent examples. (note here that such syntax system does not imply they look simple. Mathematica is a example.)

the following 2 articles helps in explaining this:

Systems for displaying math, such as TeX, Mathematica, MathML, should be unified as part of the computer language's syntax. The point is that we should not have a lang just to generate the display of math notations such as done by TeX or MathML or Microsoft equation editor or other tools. Rather, it should be part of the general language for doing math. (e.g. any computer algebra system or theorem proving system)

A good example that already have done this since ~1997 is Mathematica.

Practically speaking, this means, when you code in a language (say, Ocaml), you don't just write code, but you can dynamically, interactively, have your code display math 2D notations, and the info about formating the notation is part of the computer language, it's just that your IDE or specialized editor understand your language and can format it to render 2D notations on the fly (e.g. HTML is such a lang).

If you know Mathematica, then you understand this. Otherwise, think of HTML/XML, which is a lang for formatting purposes without computational ability, yet today there are XML based general purpose computer languages. This language is a example of several issues in this essay. i.e. it's syntax is formalized syntax system, it's is a general purpose computer language, and it has semantics for 2D notations or arbitrary formatting/rendering such as headers.


As a example of current situation in contrast of the above idea: suppose you doing some proof using OCaml derived theorem prover. Sometimes you need to do computer algebra, so you need to call Mathematica or Maple as supplement. Then often you need to display the result in math notation. So you'll need to call/output TeX or MathML. Then Dijkstra objects that your traditional math notation is so inconsistent, ambiguous, misleading, ad hoc, and does not help or correspond to the actual mathematical content behind them. So, you need to invent or re-write your notation to something proposed by the Calculational Proofs movement or Stephen Wolfram's (proprietary) Mathematica's StandardForm, that is not ambiguous.

I think what inspired me to arrive at this idea is mostly my experiences with Mathematica, and my interest in math formalism and logicism as foundation, and my interest in technologies such as computer algebra systems and display systems such as MathML and TeX, and the intricate issues of relation between math notations and mathematics.

This may sounds like pitching Mathematica, but as far as i know it is closest as the best example in unifying all these issues. It is a has a simple syntax system (i.e. the lang's syntax & grammar is not ad hoc). It is a general computer language. It is a computer algebra system (e.g. can solve math equations, etc.). The language also functions as a math notation display system (e.g. like TeX or MathML). It has a notation (StandardForm) that is compatible with the calculational proof movement.

What it lacks is functioning as a theorem proving system.

I'm singling out Mathematica because it is a system i know well and happened to be the most fitting example in this thesis. Note however, Mathematica is roughly the sole idea of Stephen Wolfram, and its syntax/grammar, is not the only approach. It just happens to be the lang that today has unified many of the issues in this essay (as far as i know). It is relatively easy to design alternative syntax.

Many approaches to this unified language/syntax/notation/mathematics system are possible. Different communities mentioned above are trying to unify or advance different aspects. (e.g. as another example i haven't mentioned above, there's a project in LaTeX that tries to make its syntax understand the semantics of math notations, as opposed to sequence of structurally meaningless symbols that renders to meaningless display... Lots other examples in different tools really)

I'll have to refine this essay for coherency and more concrete examples, perhaps with screen shots from different tools, syntax examples in different languages, rendered output in different tools, notation comparison from different schools, philosophies in formalism or logicism or computer proofing systems from different mathematicians, pertinent quotations and excerpts from various literatures, and more academic references and industrial publications... but i hope this idea is conveyed reasonably.