* emacsclient commandline
@ 2008-08-20 14:49 Rustom Mody
2008-08-20 15:34 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 6+ messages in thread
From: Rustom Mody @ 2008-08-20 14:49 UTC (permalink / raw
To: help-gnu-emacs
I am trying to construct a command line such that:
if emacs is running the client asks the server to raise-frame else it
calls runemacs.
The command line Ive given is:
$ emacsclient -a runemacs -e "(raise-frame)"
But this opens a file (or buffer) called '(raise-frame)' !!
Of course just
$ emacsclient -e "(raise-frame)"
raises the emacs frame alright but fails for the case of no server.
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
------------------------
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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: emacsclient commandline
2008-08-20 14:49 Rustom Mody
@ 2008-08-20 15:34 ` Lennart Borgman (gmail)
2008-08-21 5:50 ` Rustom Mody
0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman (gmail) @ 2008-08-20 15:34 UTC (permalink / raw
To: Rustom Mody; +Cc: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: emacsclient commandline
2008-08-20 15:34 ` Lennart Borgman (gmail)
@ 2008-08-21 5:50 ` Rustom Mody
0 siblings, 0 replies; 6+ messages in thread
From: Rustom Mody @ 2008-08-21 5:50 UTC (permalink / raw
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: emacsclient commandline
[not found] <mailman.17151.1219243748.18990.help-gnu-emacs@gnu.org>
@ 2008-09-11 17:45 ` Oleksandr Gavenko
2008-09-12 13:18 ` rustom
0 siblings, 1 reply; 6+ messages in thread
From: Oleksandr Gavenko @ 2008-09-11 17:45 UTC (permalink / raw
To: help-gnu-emacs
Rustom Mody wrote:
> I am trying to construct a command line such that:
>
> if emacs is running the client asks the server to raise-frame else it
> calls runemacs.
>
> The command line Ive given is:
> $ emacsclient -a runemacs -e "(raise-frame)"
>
> But this opens a file (or buffer) called '(raise-frame)' !!
>
> Of course just
> $ emacsclient -e "(raise-frame)"
>
> raises the emacs frame alright but fails for the case of no server.
>
> 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
> ------------------------
> 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)
>
>
On Windows I wrote e.bat. Usually at Total Commander or Far file manager
I find file by cursor, type e<space><CTRL+Enter> and emacs popup with
opened file (if it already not opened I get error and quickly type
<Enter>). As for me `--no-wait' very useful not needed type C-x # and I
can come back to the opened file later typing C-x b.
@echo off
REM Copyright (C) 2008 by Oleksandr Gavenko <gavenko_a@gmail.com>
REM View file in emacs buffer using emacsclientw.
REM If emacs not already running, run it.
REM Put this file (e.bat) in your PATH.
REM Name `e' because `edit'.
if "%1" == "-h" goto usage
if "%1" == "-help" goto usage
if "%1" == "--help" goto usage
%HOME%\..\bin\emacs\bin\emacsclientw.exe -a emacs -n "%*"
goto EOF
:usage
@echo Win emacs run script.
@echo Usage
@echo e [-h^|--help] ^<edit-files^>
:EOF
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: emacsclient commandline
2008-09-11 17:45 ` emacsclient commandline Oleksandr Gavenko
@ 2008-09-12 13:18 ` rustom
2008-09-12 17:37 ` Oleksandr Gavenko
0 siblings, 1 reply; 6+ messages in thread
From: rustom @ 2008-09-12 13:18 UTC (permalink / raw
To: help-gnu-emacs
On Sep 11, 10:45 pm, Oleksandr Gavenko <gaven...@gmail.com> wrote:
> Rustom Mody wrote:
> > I am trying to construct a command line such that:
>
> > if emacs is running the client asks the server to raise-frame else it
> > calls runemacs.
>
> > The command line Ive given is:
> > $ emacsclient -a runemacs -e "(raise-frame)"
>
> > But this opens a file (or buffer) called '(raise-frame)' !!
>
> > Of course just
> > $ emacsclient -e "(raise-frame)"
>
> > raises the emacs frame alright but fails for the case of no server.
>
> > 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
> > ------------------------
> > 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)
>
> On Windows I wrote e.bat. Usually at Total Commander or Far file manager
> I find file by cursor, type e<space><CTRL+Enter> and emacs popup with
> opened file (if it already not opened I get error and quickly type
> <Enter>). As for me `--no-wait' very useful not needed type C-x # and I
> can come back to the opened file later typing C-x b.
>
> @echo off
> REM Copyright (C) 2008 by Oleksandr Gavenko <gavenk...@gmail.com>
>
> REM View file in emacs buffer using emacsclientw.
> REM If emacs not already running, run it.
> REM Put this file (e.bat) in your PATH.
> REM Name `e' because `edit'.
>
> if "%1" == "-h" goto usage
> if "%1" == "-help" goto usage
> if "%1" == "--help" goto usage
>
> %HOME%\..\bin\emacs\bin\emacsclientw.exe -a emacs -n "%*"
> goto EOF
>
> :usage
> @echo Win emacs run script.
> @echo Usage
> @echo e [-h^|--help] ^<edit-files^>
>
> :EOF
The emacs-wiki code is better because it does not 'error'
And my code is better because it does something useful in all 4 cases:
(with and without file argument; with and without emacs server
running)
My question was basically about some way of making the VBS code more
efficient and shorter.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: emacsclient commandline
2008-09-12 13:18 ` rustom
@ 2008-09-12 17:37 ` Oleksandr Gavenko
0 siblings, 0 replies; 6+ messages in thread
From: Oleksandr Gavenko @ 2008-09-12 17:37 UTC (permalink / raw
To: help-gnu-emacs
rustom wrote:
> The emacs-wiki code is better because it does not 'error'
> And my code is better because it does something useful in all 4 cases:
> (with and without file argument; with and without emacs server
> running)
>
> My question was basically about some way of making the VBS code more
> efficient and shorter.
Yea, I forget what you wont. Understanding emacsclient I start from
emacs-wiki, but I newbie in VB and do not wont learn complex technology,
so stay at bat file.
VB scripting supporting in all Windows OSes?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-12 17:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.17151.1219243748.18990.help-gnu-emacs@gnu.org>
2008-09-11 17:45 ` emacsclient commandline Oleksandr Gavenko
2008-09-12 13:18 ` rustom
2008-09-12 17:37 ` Oleksandr Gavenko
2008-08-20 14:49 Rustom Mody
2008-08-20 15:34 ` Lennart Borgman (gmail)
2008-08-21 5:50 ` Rustom Mody
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.