From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: Problem quoting expression to be eval'ed by emacsclient Date: Wed, 30 Oct 2013 10:59:24 +0100 Organization: Sebastien Vauban Message-ID: <86li1b84g3.fsf@somewhere.org> References: <86y55kcrpc.fsf@somewhere.org> <87a9i02wu4.fsf@gmail.com> <86wql3tzwf.fsf@somewhere.org> <86mwlxplvb.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1383127218 24615 80.91.229.3 (30 Oct 2013 10:00:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Oct 2013 10:00:18 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Wed Oct 30 11:00:22 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VbSZX-0007KA-S2 for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Oct 2013 11:00:20 +0100 Original-Received: from localhost ([::1]:51314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbSZX-00041Q-Ca for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Oct 2013 06:00:19 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 192 Injection-Info: mx05.eternal-september.org; posting-host="402b34550bd938aa98825778083dce0e"; logging-data="12057"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX18p+1LONqQtkCEsnK/vLoca" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:iZ+B1p+1M0iHhPzMgnnzb64eEaI= sha1:k9GjuBoS9yXdieIuze81VsGLeBs= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:201997 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:94268 Archived-At: Eli Zaretskii wrote: >> From: "Sebastien Vauban" >> Date: Fri, 25 Oct 2013 14:37:28 +0200 >> >>>> The above tests I made are from a Cygwin Zsh session. >>> >>> And emacsclient was a Cygwin build or a native build? If the latter, your >>> problems could be due to this mix. (Your example works for me from cmd and >>> even from MSYS Bash.) >> >> That does indeed makes a difference: >> >> --8<---------------cut here---------------start------------->8--- >> $ emacsclient -e "(message \"hello\")" >> >> *ERROR*: End of file during parsing >> --8<---------------cut here---------------end--------------->8--- >> >> --8<---------------cut here---------------start------------->8--- >> $ /usr/bin/emacsclient -e "(message \"hello\")" >> /usr/bin/emacsclient: can't find socket; have you started the server? >> To start the server in Emacs, type "M-x server-start". >> "hello" >> --8<---------------cut here---------------end--------------->8--- > > I'm confused: didn't you say that /usr/bin is a Cygwin directory? Yes, it is. > If so, /usr/bin/emacsclient is a Cygwin build of emacsclient, right? Right. > Then what kind of emacsclient is in ~/bin? That was answered later in my post; ~/bin/emacsclient is the following script: --8<---------------cut here---------------start------------->8--- "C:/Program Files (x86)/emacs-trunk/bin/emacsclient" $@ --8<---------------cut here---------------end--------------->8--- That's (mostly) a way to bypass the Cygwin emacsclient, as ~/bin is before /usr/bin in my PATH environment variable: --8<---------------cut here---------------start------------->8--- /cygdrive/d/Users/sva/bin /cygdrive/d/Users/sva/winbin ... /usr/bin ... /cygdrive/c/Windows/system32 /cygdrive/c/Windows ... --8<---------------cut here---------------end--------------->8--- IOW, a way to be able to instruct which "real" emacsclient program I want to invoke when I type emacsclient in a shell, without the need to play with the PATH environment variable. >> However, that still leaves me with the following problem: >> >> How can I work in a correct shell on Windows (read: not `cmd.exe'), and >> edit in my graphical Emacs w32? > > My best advice is to avoid that combination entirely. It's just too > fragile and replete of subtle "issues". > > Let me turn the table and ask why do you need to invoke emacsclient > from the shell command line? Why not simply visit the file from the > running Emacs? (You do have an Emacs session running at all times, > right?) emacsclient is mainly for letting other programs ask Emacs to > edit a file. Since the w32 Emacs does not support multiple tty > devices in the same session, even invoking "emacsclient -t" bu hand > doesn't make sense when the server is the w32 Emacs. So I wonder why > do you use this at all. You're right asking such questions about the "why". It sometimes can be very enlightening. So, here, in my case, I almost only use `emacsclient' from "sendpatch", a shell script (I wrote) which automates the sending of a diff per email, for other colleagues to review and see what we commit in our SVN server. High-level, what sendpatch does is the following: 1. it makes a patch file with the output of "svn diff", 2. asks for an email subject, 3. launches the preferred EDITOR of the user to let him write a more complete commit message, 4. commits the diff in SVN, and 5. sends the "review" on a mailing list. In my case, EDITOR is `emacsclient'. For other colleagues, it can be `vi' or some such. That script is written in Bash; it heavily relies on standard Unix commands such as `cut', `grep', `head', `awk', etc. > Another pertinent question is: why not use the Cygwin build of Emacs? > It does support GUI sessions, and can even be built with the w32 > graphics as its "toolkit". (... searching for more info about this...) You're talking of the Cygwin package emacs-w32, right? I wasn't aware of it. I will give it a try... I thought that the graphical Cygwin Emacs was only a X-version (installed via the Cygwin package emacs-X11, IIUC). > If you use a Cygwin Emacs and emacsclient from the Cygwin shell, I don't > expect you to have any problems with quoting. > > But if, for some reason, you must use this crazy mix, then I suggest > to at least switch to the MSYS Bash. It is friendlier to native > programs than Cygwin shells, although you will have problems there as > well. But I'd loose Zsh, right? OK, honestly, apart using `M-q' (to type another command in the middle of a long command) and `vared' (to interactively a edit variable), I don't really use special Zsh features either. >> - an Emacs server must be contacted by an `emacsclient' of the same release > > This is not really accurate. It's just that the format of the server > file changed between Emacs 23 and 24, so you cannot mix client and > server that are on different sides of that schism. Thanks for the precision. >> - Cygwin (/usr/bin) is second in my PATH, after ~/bin > > Why do you need Cygwin executables on your PATH? You mean from PATH as seen in a CMD shell? Or from a Bash shell? I need the Cygwin executables them all the time in my Bash sessions. And I need the Cygwin executables from Emacs as well (for the `M-x find-grep-dired' or `M-x rgrep' commands, among others, which I use quite extensively -- `rgrep', at least). And, there, I need them to be before the default Windows executable, because of `find' (which also exist in c:\Windows\system32). Though, it's certainly possible to `setq' a couple (or a lot?) of vars to avoid adding C:/cygwin/bin to the PATH. Is it that you're talking about? > And what kind of programs are in ~/bin? > >> I currently have a small `~/bin/emacsclient' script (one-liner) which allows me >> to set the full path to the right `emacsclient' without having to fiddle with >> the PATH environment variable (as that requires me to quit my shell, and start >> a new one): >> >> --8<---------------cut here---------------start------------->8--- >> "C:/Program Files (x86)/emacs-trunk/bin/emacsclient" $@ >> --8<---------------cut here---------------end--------------->8--- >> >> This is a hack. > > I don't see anything wrong with such a script. But it only works > around the PATH problem, it does nothing to alleviate the subtle > incompatibilities between native Windows executables and Cygwin/MSYS > executables. Rigth. And these are subtle incompatibilities about which I was unaware up to a couple of days ago... >> Indeed, I'd like to be able to launch whichever Emacs version >> (clicking on one of the many versions I have on my Windows desktop), and that >> launching `emacsclient' in the shell would work in all contexts. > > See above: I don't understand why you are invoking emacsclient in the > first place. I hope you now do. > As for the v23 vs v24 emacsclient issue, you could have emacsclient23 > and emacsclient24 (scripts, aliases, whatever) to DTRT for each one. Yes, but the question arises from the fact that `sendpatch' has no way to detect (does it?) which Emacs server version is currently running, so which `emacsclient' it has to call. Thanks for your help! Best regards, Seb -- Sebastien Vauban