From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Rustom Mody" Newsgroups: gmane.emacs.help Subject: Re: emacsclient commandline Date: Thu, 21 Aug 2008 11:20:17 +0530 Message-ID: References: <48AC3970.6050303@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1219297865 27908 80.91.229.12 (21 Aug 2008 05:51:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Aug 2008 05:51: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 Thu Aug 21 07:51:57 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 1KW35L-00075x-MT for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 07:51:51 +0200 Original-Received: from localhost ([127.0.0.1]:32835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KW34O-0006tQ-59 for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 01:50:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KW33w-0006sj-0X for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 01:50:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KW33s-0006rX-4b for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 01:50:23 -0400 Original-Received: from [199.232.76.173] (port=42051 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KW33r-0006rH-AQ for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 01:50:19 -0400 Original-Received: from rv-out-0708.google.com ([209.85.198.246]:52796) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KW33q-000769-Kr for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 01:50:18 -0400 Original-Received: by rv-out-0708.google.com with SMTP id k29so775675rvb.6 for ; Wed, 20 Aug 2008 22:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=oJms3bWxAjU321wsMWSKCVklIwxLb9DSQt5Byaw7W8k=; b=s9j+YJ4P+K6W4g9HSwyLjZAxYxSl/KGgbrlS/pGFv7ew9eV+9t3Az6s/dHfy4BKSN9 p578XqHEpgFheTwl6XqVd4Ziz76pcMZjSCkglUP7ja8JMxL8n/PWV4qhTiSCUx4r98kr S3xsYZ869DBgQUiBi2B+tKkdqy2YOs1OsynGU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=tjJXu5OMukPr5Y7LgPKy6zBKTCYpAvy6ol4r6GtXvSZqY/XLRo++mYmofH98MZkKCu Ozoa1uO1miEhHfV4lkh5ct9F+plXcXGjroGN0pRPIYDBwTCsVbAqst6apnPQ9mXwGVvx 84H3tqnuOcGcgtD0ADb0BHAtUjXeL1Teseutk= Original-Received: by 10.141.42.10 with SMTP id u10mr518854rvj.292.1219297817775; Wed, 20 Aug 2008 22:50:17 -0700 (PDT) Original-Received: by 10.141.178.18 with HTTP; Wed, 20 Aug 2008 22:50:17 -0700 (PDT) In-Reply-To: <48AC3970.6050303@gmail.com> Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) 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:56838 Archived-At: On Wed, Aug 20, 2008 at 9:04 PM, Lennart Borgman (gmail) wrote: > Rustom Mody wrote: >> Another minor point: >> When emacsclient is used with the -a option and there is no server >> running it pops up a window saying ERROR No error !! >> I guess this is an error (in emacsclient) :-) >> >> Starting from the vbs file on the emacswiki Ive constructed my own >> launch-emacs as below but I dont like the loop and the sql and all the >> heavy stuff, hence this attempt. >> >> My launch-emacs-client.vbs > > There is some stuff on EmacsWiki about this. > As I said I got this from there: http://www.emacswiki.org/cgi-bin/wiki/EmacsClient#toc6 But I dont like this code. There are a number of reasons (it is hip to dislike vb not being one of them) a) emacsclient already has a mechanism builtin (via the alternate editor) to do the equivalent of if emacs-server running then do X else do Y b) It uses a for loop going through all the processes whereas it should stop when it finds an emacs running c) It does nothing useful when it is called without an argument. So I wrote the below code. It corrects (c) by spelling out 4 explicit cases: -- Argument (file) given and emacs-server running -- Arg given and server not running -- No arg and server running -- No arg and no server My code below corrects c. My question was for correcting a. If that is done b gets solved automatically else if anyone knows how to solve b that is fine (though that is really a vbs/wscript question not an emacs/elisp one) Heres my current code. Below that the code on emacswiki ---------------------------------- Set objShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") Dim isRunning isRunning = False For Each objItem in colItems If InStr(objItem.CommandLine, "emacs.exe") Then isRunning = True End If Next parent = fso.GetParentFolderName(WScript.ScriptFullName) If WScript.Arguments.Count = 1 Then If isRunning Then callString = parent & "/emacsclientw.exe -n """ & WScript.Arguments(0) & """" Else callString = parent & "/runemacs.exe """ & WScript.Arguments(0) & """" End If Else If isRunning Then callString = parent & "/emacsclientw.exe -n -e ""(raise-frame)""" else callString = parent & "/runemacs.exe" End If End if objShell.Run(callString) ------------------------- emacswiki code ------------------------ Set objShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") If WScript.Arguments.Count = 1 Then strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") Dim isRunning isRunning = False For Each objItem in colItems If InStr(objItem.CommandLine, "emacs.exe") Then isRunning = True End If Next If isRunning Then objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/emacsclientw.exe -n """ & WScript.Arguments(0) & """") Else objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/runemacs.exe """ & WScript.Arguments(0) & """") End If Else objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/runemacs.exe") End If