From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giorgos Keramidas Newsgroups: gmane.emacs.help Subject: Re: How to open a file in sh-mode Date: Thu, 14 Aug 2008 16:27:24 +0300 Message-ID: <87myjfvi9v.fsf@kobe.laptop> References: <38b2ab8a0808140053g6261aeafmd74692199cea07eb@mail.gmail.com> <200808141016.12117.henrikau@stud.ntnu.no> <38b2ab8a0808140203s53c339f3k70d5887d42a4de2f@mail.gmail.com> <200808141203.22315.henrikau@stud.ntnu.no> <874p5nwzri.fsf@kobe.laptop> <38b2ab8a0808140601p3f524769oe0fdb80c6db60bb@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1218720623 9163 80.91.229.12 (14 Aug 2008 13:30:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Aug 2008 13:30:23 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Francis Moreau" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 14 15:31:14 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 1KTcuv-0006hZ-IQ for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2008 15:31:05 +0200 Original-Received: from localhost ([127.0.0.1]:39888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTcty-00065g-WE for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2008 09:30:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTcsI-0005Pj-PX for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 09:28:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTcsE-0005OB-9f for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 09:28:22 -0400 Original-Received: from [199.232.76.173] (port=46215 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTcsE-0005O6-0J for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 09:28:18 -0400 Original-Received: from igloo.linux.gr ([62.1.205.36]:39962) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KTcsB-0005op-RF for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 09:28:17 -0400 Original-Received: from kobe.laptop (adsl11-42.kln.forthnet.gr [77.49.138.42]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id m7EDRQ8n008580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 14 Aug 2008 16:27:33 +0300 Original-Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m7EDRQAE075795; Thu, 14 Aug 2008 16:27:26 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Original-Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m7EDROG6075630; Thu, 14 Aug 2008 16:27:24 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) In-Reply-To: <38b2ab8a0808140601p3f524769oe0fdb80c6db60bb@mail.gmail.com> (Francis Moreau's message of "Thu, 14 Aug 2008 15:01:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) X-MailScanner-ID: m7EDRQ8n008580 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.826, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.57, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 1) 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:56617 Archived-At: On Thu, 14 Aug 2008 15:01:02 +0200, "Francis Moreau" wrote: > On Thu, Aug 14, 2008 at 2:24 PM, Giorgos Keramidas > wrote: >> >> You can probably write a short wrapper script that is used as $FCEDIT to >> run the equivalent of: >> >> emacs --eval "(setq-default default-major-mode 'sh-mode)" file1 file2 ... >> > > Hmm I don't why I need a wrapper script in that case, do you have an idea ? > > If I try without the wrapper I get: > > $ export FCEDIT="emacs -nw --eval \"(setq-default default-major-mode > 'sh-mode)\"" > $ fc > > > > ("emacs" "--eval" "\"(setq-default" "default-major-mode" "'sh-mode)\"" > "/tmp/bash-fc-247955888988243") See how the command-line arguments have been split in multiple places by the shell that evaluated $FCEDIT? That's why I suggested a wrapper script. To avoid all the obnoxiously stupid things expansion of $FCEDIT would do, and make sure that there is only *one* level of quoting you would have to use. The parenthesized list quoted above shows that Emacs tried to --eval the expression "\"(setq-default", which isn't a complete Lisp s-exp (and this is what Emacs is trying to say with the error message). Using a shell wrapper makes expansion of the --eval argument much more predictable here, so I tend to prefer that: $ cat > /tmp/fcedit.sh #!/bin/sh emacs --eval "(setq-default default-major-mode 'sh-mode)" "$@" ^D $ chmod 0755 /tmp/fcedit.sh $ export FCEDIT='/tmp/fcedit.sh -nw' $ fc I have a few of these wrappers in my `~/bin' directory, to help me fire up Emacs with a variety of options, i.e.: ~/bin/emacs-no-gui This runs `emacs -nw "$@"'. ~/bin/utf-emacs This sets up LANG, and LC_ALL, clears every other LC_XXX locale variable, and then fires up Emacs in `utf-8 mode'. and so on. I really hate having to fight with backslashes to get everything right in tons of nested quotes, quoted quotes and quoted-quoted quotes ad infinitum, so that's why I like throwing a wrapper here and there :)