From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: formido Newsgroups: gmane.emacs.help Subject: Re: Bash Script Editing Mode? Date: Thu, 7 Aug 2008 14:59:34 -0700 (PDT) Organization: http://groups.google.com Message-ID: <82dfe063-1db1-4f7b-bb99-e552a1900acd@a2g2000prm.googlegroups.com> References: <361d08d2-b456-49c9-a578-53d1aaaf0b0f@a8g2000prf.googlegroups.com> <87hc9w1q0n.fsf@hubble.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1218148865 2156 80.91.229.12 (7 Aug 2008 22:41:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Aug 2008 22:41:05 +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 Aug 08 00:41:55 2008 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 1KREB7-0007rl-CG for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Aug 2008 00:41:53 +0200 Original-Received: from localhost ([127.0.0.1]:53009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KREAB-0005Ie-8t for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Aug 2008 18:40:55 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a2g2000prm.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 70 Original-NNTP-Posting-Host: 66.125.32.93 Original-X-Trace: posting.google.com 1218146375 9966 127.0.0.1 (7 Aug 2008 21:59:35 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 7 Aug 2008 21:59:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a2g2000prm.googlegroups.com; posting-host=66.125.32.93; posting-account=ivEBWwoAAAAvVw947tp2U-HBcoAwWEMu User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:160917 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:56260 Archived-At: On Aug 7, 2:20=A0pm, p...@informatimago.com (Pascal J. Bourguignon) wrote: > formido writes: > > There's a shell mode, but it has a prompt and doesn't help you > > incrementally create a shell script as efficiently as it could, unless > > I'm missing something. Is there any shell script mode that works more > > like the elisp, python, or erlang repls, where you can execute your > > choice of several lines at once and you can go back and edit and > > execute the lines in situ? If I write a bash function, editing and > > reloading the function is a painful process. I'm looking for something > > a little bit like the Mac's BBEdit shell worksheets (only better). > > First, try to get your terminology straight. Heh. I've noticed that no matter with what care one designs his query, a novice will invariably run afoul of the idioms or conventions of the new culture... > > I considered altering the usual shell mode, but it would take more > > than slight edits, so I'm hoping something's already out there. For > > example, one should be able to go back to a function, tweak it, and > > reload with a minimum of keyboard fuss. > > Well, if you consider the shell mode, there's an easy way to get what > you want: =A0just edit your commands, one by one, and type RET to try > them. =A0When you're happy with the result, type: history RET and > copy-and-paste all the commands to a shell script buffer, add some > minor edits, including a #!/bin/bash on the first line, and voil=E0. This does not work very well with loops and functions and is more cumbersome than necessary besides, avoiding which is the whole point of learning Emacs. > But really, I would rather start from the shell-script-mode. > Once you have implemented a pair of functions forward-shell-expression > and backward-shell-expression, you can easily implement a function > such as eval-last-shell-expression: > > (defun eval-last-shell-expression (point) > =A0 (interactiev "P") > =A0 (let ((start (progn (backward-shell-expression) (point))) > =A0 =A0 =A0 =A0 (end =A0 (progn (forward-shell-expression) =A0(point)))) > =A0 =A0 (comint-send-string (inferior-shell-proc) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (buffer-substring start e= nd)) > =A0 =A0 (comint-send-string (inferior-shell-proc) "\n"))) > > There remains only to bind these commands to C-M-f, C-M-b and C-x C-e. Yes, I think this and shell-script-mode should put me well on my way. > But if you're as lazy as me, perhaps the best option would be to use > scsh. =A0You get a shell, but it's really a scheme, and there is already > all you need to edit scheme scripts, and C-x C-e already works. That does look really cool. I only hesitate because obviously regular shells are installed everywhere. This is probably not as great an advantage as it seems in my mind, though. > -- > __Pascal Bourguignon__ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.= informatimago.com/ > Michael