From: "Rustom Mody" <rustompmody@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: emacsclient commandline
Date: Thu, 21 Aug 2008 11:20:17 +0530 [thread overview]
Message-ID: <f46c52560808202250m6dccbf78n31a60a4bc8d0e28e@mail.gmail.com> (raw)
In-Reply-To: <48AC3970.6050303@gmail.com>
On Wed, Aug 20, 2008 at 9:04 PM, Lennart Borgman (gmail)
<lennart.borgman@gmail.com> 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
next prev parent reply other threads:[~2008-08-21 5:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 14:49 emacsclient commandline Rustom Mody
2008-08-20 15:34 ` Lennart Borgman (gmail)
2008-08-21 5:50 ` Rustom Mody [this message]
[not found] <mailman.17151.1219243748.18990.help-gnu-emacs@gnu.org>
2008-09-11 17:45 ` Oleksandr Gavenko
2008-09-12 13:18 ` rustom
2008-09-12 17:37 ` Oleksandr Gavenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f46c52560808202250m6dccbf78n31a60a4bc8d0e28e@mail.gmail.com \
--to=rustompmody@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).