* Strangle problem with batch mode.
@ 2009-02-11 9:11 Andy Stewart
0 siblings, 0 replies; 3+ messages in thread
From: Andy Stewart @ 2009-02-11 9:11 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I write elisp-format.el for format elisp file.
File at http://www.emacswiki.org/cgi-bin/emacs/elisp-format.el
Detail describe at http://www.emacswiki.org/cgi-bin/emacs/ElispFormat
In elisp-format.el, have a command "elisp-format-directory" can format
elisp files under specify directory.
Example, eval (elisp-format-directory "~/elisp/") can format all elisp
files under "~/elisp/".
But when i use command
emacs -batch -l ~/MyEmacs/Site-Lisp/Packages/LazyCatSelf/elisp-format.el --eval="(progn (require 'elisp-format) (elisp-format-directory \"~/elisp/\"))"
it can't work.
I don't know why `batch' mode can't work.
Any idea?
Thanks!
-- Andy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Strangle problem with batch mode.
[not found] <mailman.421.1234343723.31690.help-gnu-emacs@gnu.org>
@ 2009-02-12 19:05 ` Xah Lee
2009-02-13 6:53 ` Andy Stewart
0 siblings, 1 reply; 3+ messages in thread
From: Xah Lee @ 2009-02-12 19:05 UTC (permalink / raw)
To: help-gnu-emacs
On Feb 11, 1:11 am, Andy Stewart <lazycat.mana...@gmail.com> wrote:
> Hi all,
>
> I write elisp-format.el for format elisp file.
> File athttp://www.emacswiki.org/cgi-bin/emacs/elisp-format.el
> Detail describe athttp://www.emacswiki.org/cgi-bin/emacs/ElispFormat
>
> In elisp-format.el, have a command "elisp-format-directory" can format
> elisp files under specify directory.
>
> Example, eval (elisp-format-directory "~/elisp/") can format all elisp
> files under "~/elisp/".
>
> But when i use command
>
> emacs -batch -l ~/MyEmacs/Site-Lisp/Packages/LazyCatSelf/elisp-format.el --eval="(progn (require 'elisp-format) (elisp-format-directory \"~/elisp/\"))"
>
> it can't work.
>
> I don't know why `batch' mode can't work.
>
> Any idea?
>
> Thanks!
>
> -- Andy
Btw, i promised Andy a thank you money of $15, and promised to pay him
$50 if this code is practically usable. If anyone could pitch in some
ammount, even $5, will be great!
Let me explain why i think this is very important.
Today, coders, in about any language, format his code manually, on a
line-by-line basis. Although how many indentation is taken care of in
most editors, however, it is still manual process on every line.
For example, in perl, when i type
for (my $var = 0; $var < 5; $var++) {
then i have to press return, at that point. Then, depending on the
editor, i might have to press Tab. Sure, there are template systems
that takes care of the whole “for” loop, but on the whole, programers
are essentially manually formatting each and every line of code.
With today's hardware speed and much software advancement, much of
these labor can be done by machine. A coder, should be able to press a
button, then the current semantic unit of the lang will be
automatically formatted to his preference settings. Press another
button, the whole file is auto formatted to his liking. Similarly,
calling a function can auto-format entire dir of source code. This
feature can be builtin in the editor.
occasionally you'll see such a tool available in one lang or another,
but in general, programers are still manually doing formatting line by
line, in just about all editors.
The above depicts the vision. (^_^)
for now, we can start with lisp source code, with emacs. Lisp source
code has a very simple lexical grammar, and emacs is quite powerful in
text processing. So, i imagined, it is not too difficult to have a
auto-formatter in emacs for elisp code. For example, suppose i am
going to write a function
(defun previous-user-buffer ()
"Switch to the next user buffer in cyclic order."
(interactive)
(previous-buffer)
(let ((i 0))
(while (and (string-match "^*" (buffer-name))
(< i 10))
(setq i (1+ i))
(previous-buffer))))
I don't have to press return, tab, in every step. I can simply type
them straight, and when the line gets too long or when i want to, i
press a button, it gets broken into multiple lines at proper places
with proper number of tabs. This is similar to how editing in word
processor progressed. (in the 1980s, writer has to press return when
cursor reaches the right margin. But since 1990s, auto-wrap is there.)
If programer wants, he can set the auto wrap to be automatic, much
like emacs automatic option for fill-region.
Note that this feature, in whole perfection, is buildin in the
Mathematica language's editor (aka Frontend) since 1997. It not only
does one-dimentional pure text source code formatting, but deals with
source code that renders into 2D typeset mathematics in real time, all
on the fly, as you edit.
back to elisp with emacs... as a first step, we are aiming for these
goals:
A: provide a format-buffer functions, so that it will reformat all the
code in the current buffer. (Andy alread did this superbly, with
version that format current block, region, buffer, file, dir.)
B: the result of reformat-buffer must remain 100% valid of the same
behavior. For example, i can run reformat-buffer on all existing elisp
files bundled with emacs, save them, compile them, and expect emacs to
restart fine. Note: This must be achived 100%.
C: About how exactly it formats, see a sample here:
http://xahlee.org/emacs/lisp_formatter.html
The exact detail of formatting is not very important. The important
thing is that the code will be able to correctly scan the lexical
grammar of the code (as in B above). The exact formatting can be later
tweaked to perfection, with customizable variables. It is ok if the
code will format badly for say 5% of source code input. This still
beats programer manually format every singe line.
D: the speed should be practically usable. Say, 1000 lines of code for
under no more that 5 sec on a mid range PC today.
Once this works, i think it shouldn't be hard to make it work in
common lisp, scheme lisp, clojure, newlisp.
With today's tech, i think this is very doable with emacs. Andy
already did a superb job, but there are still small problems to be
fixed. Please try the code.
If you can pitch in $5, please email me and Andy. That's be super!
Thank you very much,
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Strangle problem with batch mode.
2009-02-12 19:05 ` Xah Lee
@ 2009-02-13 6:53 ` Andy Stewart
0 siblings, 0 replies; 3+ messages in thread
From: Andy Stewart @ 2009-02-13 6:53 UTC (permalink / raw)
To: help-gnu-emacs
Hi Xah,
Now elisp-format.el can work with 98% code.
I have test 1014 elisp files that build-in GNU Emacs 23.
Have some speical case i haven't consider.
I will fix it.
Now the update process is *slow*, because i'm really too busy.
I won't spend many time to test and fix it, because elisp-format.el is
not necessary to me.
I will fix it more faster if someone can pay for my time.
And the code is under GPL 3, so anyone can modified it and release new
version.
And elisp-format.el need test widely before it perfect.
Any patch are welcome!
Enjoy!
-- Andy
Xah Lee <xahlee@gmail.com> writes:
> On Feb 11, 1:11 am, Andy Stewart <lazycat.mana...@gmail.com> wrote:
>> Hi all,
>>
>> I write elisp-format.el for format elisp file.
>> File athttp://www.emacswiki.org/cgi-bin/emacs/elisp-format.el
>> Detail describe athttp://www.emacswiki.org/cgi-bin/emacs/ElispFormat
>>
>> In elisp-format.el, have a command "elisp-format-directory" can format
>> elisp files under specify directory.
>>
>> Example, eval (elisp-format-directory "~/elisp/") can format all elisp
>> files under "~/elisp/".
>>
>> But when i use command
>>
>> emacs -batch -l ~/MyEmacs/Site-Lisp/Packages/LazyCatSelf/elisp-format.el --eval="(progn (require
> elisp-format) (elisp-format-directory \"~/elisp/\"))"
>>
>> it can't work.
>>
>> I don't know why `batch' mode can't work.
>>
>> Any idea?
>>
>> Thanks!
>>
>> -- Andy
>
> Btw, i promised Andy a thank you money of $15, and promised to pay him
> $50 if this code is practically usable. If anyone could pitch in some
> ammount, even $5, will be great!
>
> Let me explain why i think this is very important.
>
> Today, coders, in about any language, format his code manually, on a
> line-by-line basis. Although how many indentation is taken care of in
> most editors, however, it is still manual process on every line.
>
> For example, in perl, when i type
>
> for (my $var = 0; $var < 5; $var++) {
>
> then i have to press return, at that point. Then, depending on the
> editor, i might have to press Tab. Sure, there are template systems
> that takes care of the whole “for” loop, but on the whole, programers
> are essentially manually formatting each and every line of code.
>
> With today's hardware speed and much software advancement, much of
> these labor can be done by machine. A coder, should be able to press a
> button, then the current semantic unit of the lang will be
> automatically formatted to his preference settings. Press another
> button, the whole file is auto formatted to his liking. Similarly,
> calling a function can auto-format entire dir of source code. This
> feature can be builtin in the editor.
>
> occasionally you'll see such a tool available in one lang or another,
> but in general, programers are still manually doing formatting line by
> line, in just about all editors.
>
> The above depicts the vision. (^_^)
>
> for now, we can start with lisp source code, with emacs. Lisp source
> code has a very simple lexical grammar, and emacs is quite powerful in
> text processing. So, i imagined, it is not too difficult to have a
> auto-formatter in emacs for elisp code. For example, suppose i am
> going to write a function
>
> (defun previous-user-buffer ()
> "Switch to the next user buffer in cyclic order."
> (interactive)
> (previous-buffer)
> (let ((i 0))
> (while (and (string-match "^*" (buffer-name))
> (< i 10))
> (setq i (1+ i))
> (previous-buffer))))
>
> I don't have to press return, tab, in every step. I can simply type
> them straight, and when the line gets too long or when i want to, i
> press a button, it gets broken into multiple lines at proper places
> with proper number of tabs. This is similar to how editing in word
> processor progressed. (in the 1980s, writer has to press return when
> cursor reaches the right margin. But since 1990s, auto-wrap is there.)
> If programer wants, he can set the auto wrap to be automatic, much
> like emacs automatic option for fill-region.
>
> Note that this feature, in whole perfection, is buildin in the
> Mathematica language's editor (aka Frontend) since 1997. It not only
> does one-dimentional pure text source code formatting, but deals with
> source code that renders into 2D typeset mathematics in real time, all
> on the fly, as you edit.
>
> back to elisp with emacs... as a first step, we are aiming for these
> goals:
>
> A: provide a format-buffer functions, so that it will reformat all the
> code in the current buffer. (Andy alread did this superbly, with
> version that format current block, region, buffer, file, dir.)
>
> B: the result of reformat-buffer must remain 100% valid of the same
> behavior. For example, i can run reformat-buffer on all existing elisp
> files bundled with emacs, save them, compile them, and expect emacs to
> restart fine. Note: This must be achived 100%.
>
> C: About how exactly it formats, see a sample here:
> http://xahlee.org/emacs/lisp_formatter.html
> The exact detail of formatting is not very important. The important
> thing is that the code will be able to correctly scan the lexical
> grammar of the code (as in B above). The exact formatting can be later
> tweaked to perfection, with customizable variables. It is ok if the
> code will format badly for say 5% of source code input. This still
> beats programer manually format every singe line.
>
> D: the speed should be practically usable. Say, 1000 lines of code for
> under no more that 5 sec on a mid range PC today.
>
> Once this works, i think it shouldn't be hard to make it work in
> common lisp, scheme lisp, clojure, newlisp.
>
> With today's tech, i think this is very doable with emacs. Andy
> already did a superb job, but there are still small problems to be
> fixed. Please try the code.
>
> If you can pitch in $5, please email me and Andy. That's be super!
>
> Thank you very much,
>
> Xah
> ∑ http://xahlee.org/
>
> ☄
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-13 6:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11 9:11 Strangle problem with batch mode Andy Stewart
[not found] <mailman.421.1234343723.31690.help-gnu-emacs@gnu.org>
2009-02-12 19:05 ` Xah Lee
2009-02-13 6:53 ` Andy Stewart
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).