From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Stewart Newsgroups: gmane.emacs.help Subject: Re: Strangle problem with batch mode. Date: Fri, 13 Feb 2009 14:53:59 +0800 Message-ID: <87wsbuomig.fsf@debian.domain> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1234508170 11461 80.91.229.12 (13 Feb 2009 06:56:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Feb 2009 06:56:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 13 07:57:25 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LXrzF-0004pz-Iy for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Feb 2009 07:57:22 +0100 Original-Received: from localhost ([127.0.0.1]:34664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXrxv-0000Vo-MS for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Feb 2009 01:55:59 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LXrxR-0000VC-W7 for help-gnu-emacs@gnu.org; Fri, 13 Feb 2009 01:55:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LXrxP-0000SY-5B for help-gnu-emacs@gnu.org; Fri, 13 Feb 2009 01:55:28 -0500 Original-Received: from [199.232.76.173] (port=54788 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXrxO-0000SV-WF for help-gnu-emacs@gnu.org; Fri, 13 Feb 2009 01:55:27 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:33853 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LXrxO-0002XS-Bc for help-gnu-emacs@gnu.org; Fri, 13 Feb 2009 01:55:26 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LXrxJ-0008WQ-NC for help-gnu-emacs@gnu.org; Fri, 13 Feb 2009 06:55:21 +0000 Original-Received: from 222.212.141.196 ([222.212.141.196]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Feb 2009 06:55:21 +0000 Original-Received: from lazycat.manatee by 222.212.141.196 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Feb 2009 06:55:21 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 158 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 222.212.141.196 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:E2TqVKxGVVmItyj9ewDpUi6a93k= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:62101 Archived-At: 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 writes: > On Feb 11, 1:11 am, Andy Stewart 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/ > > β˜„