From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23177 invoked by alias); 24 Feb 2015 19:53:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19917 Received: (qmail 10152 invoked from network); 24 Feb 2015 19:52:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=EqydBvtqELITokEf9FHmDY +dlIA=; b=CzsqgbNgfS3fq2eeBJSl7V3Z3corW579o8Xsip+R03Om6I2KTT6rBs 5aNLX+1Hm7051WkZU+IBo/A6aw4F2W1KXo8lEmH50X9kVZA590+LkPR7/pXTyMHT 1lXxGcQXfeJzm41sKOOOeoBP7HDCuXWx6XD8svlqfVz2g2Xm0LmXI= X-Sasl-enc: 4G8EXXcHL6hLAadpkeS+Vf/+0OQOqWShKm28iHb1j3/M 1424807093 Message-ID: <54ECD4B5.709@pobox.com> Date: Tue, 24 Feb 2015 14:44:53 -0500 From: Andrew Janke User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Ray Andrews , Zsh Users Subject: Re: 'run ahead' execution of script References: <54ECCE79.9050809@eastlink.ca> In-Reply-To: <54ECCE79.9050809@eastlink.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Yeah; the geany command's normal behavior isn't really suitable for a CLI-driven editing session like this. You probably do want `geany -i`. Using an editor in a shell sequence like this requires the editor to have blocking behavior on a per file basis. The normal `geany` behavior is incompatible with it; if geany's already running it hands off the file and returns. This basically means you need the `-i` switch to do one process per file. Otherwise the lifetime of the shared geany editor process isn't tied to the individual file you're editing. Waiting on a file to be "closed" would be hard to implement with generality. Editors may not keep a file open or locked the entire time they're editing it; many work on swap files instead and periodically write out to the main file. That state is internal to the editor, and not necessarily exposed on the filesystem. The behavior is probably too editor-specific for zsh to do anything about it; there's no way for zsh to consistently know when an editor is "done" with a file. And you can't just have zsh wait for the existing geany process to exit; it may be working with other files and live beyond the time you spend editing this particular file. IMHO the right approach for this would probably be to extend geany to provide a command that has the "edit a single file and block until it's closed" behavior that command line editor sequences like this require. If you wanted a quick and dirty one, you could write a wrapper script that fired up geany and polled `geany --list-documents` to figure out when you've closed the file. Cheers, Andrew On 2/24/15 2:18 PM, Ray Andrews wrote: > An interesting problem: > > e ) edit $1; echo "Sourcing $1"; source $1; return 0 ;; > > ... that line from a function does just what it seems, edit a file, then > source it. 'edit' has been various editors over time. But I just > tried changing 'edit' to 'geany', and something problematic happens: The > message and the sourcing happen before geany is closed, but *only* if > the editor is already open in another window. zsh > is executing the rest of the line while the editor is still open, as > if it > thinks it should 'multitask' there. It seems logical that it > doesn't close an editor that it didn't open, OTOH there's no point in > sourcing the file before it has been edited. Can this be prevented? > Again, I don't think that zsh should be expected to behave differently, > however some way of forcing it to wait for the file (if not the entire > editor) > to be closed in this situation would be useful. Geany itself > has an '-i' switch that forces a new process, but I'm wondering if zsh > itself can handle that i.e. pause for a process to quit before continuing > even if it didn't start it. I appreciate that this might be impossible-- > a violation of the hierarchy. It's just a point of interest.