all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacs as a service
@ 2008-08-29  6:42 Rustom Mody
  2008-08-29  9:46 ` Nikolaj Schumacher
  0 siblings, 1 reply; 20+ messages in thread
From: Rustom Mody @ 2008-08-29  6:42 UTC (permalink / raw
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

I want to start emacs as a service (This is under windows)
The emacs-y side is easy (server-start)
But I want to do it also from the windows perspective.
This involves:
-- starting emacs as a service (using Sc perhaps??)
-- emacs should not (by default) show in a tab on the desktop
-- C-x C-c should close a frame not emacs
-- it should be possible for emacs to be running without there being any
frame

Anyone done somethng like this?

[-- Attachment #2: Type: text/html, Size: 574 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
       [not found] <mailman.17859.1219992155.18990.help-gnu-emacs@gnu.org>
@ 2008-08-29  6:52 ` Torsten Mueller
  2008-08-29 15:06 ` Chet
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 20+ messages in thread
From: Torsten Mueller @ 2008-08-29  6:52 UTC (permalink / raw
  To: help-gnu-emacs

"Rustom Mody" <rustompmody@gmail.com> schrieb:

> I want to start emacs as a service (This is under windows)
> The emacs-y side is easy (server-start)
> But I want to do it also from the windows perspective.
> This involves:
> -- starting emacs as a service (using Sc perhaps??)

Have you ever seen a Windows service from inside? A Windows service is
a completely different application than an .exe file, more DLL-like.
Running Emacs as a Windows service would require code changes.

> -- emacs should not (by default) show in a tab on the desktop

What is a "tab on the desktop"?

> -- C-x C-c should close a frame not emacs

A Windows service normally does not react on keys at all.

I think what you mean is something line the emacs client/server
concept.

T.M.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-08-29  6:42 emacs as a service Rustom Mody
@ 2008-08-29  9:46 ` Nikolaj Schumacher
  2008-08-29 11:41   ` Rustom Mody
       [not found]   ` <mailman.17876.1220010121.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 20+ messages in thread
From: Nikolaj Schumacher @ 2008-08-29  9:46 UTC (permalink / raw
  To: Rustom Mody; +Cc: help-gnu-emacs

"Rustom Mody" <rustompmody@gmail.com> wrote:

> -- starting emacs as a service (using Sc perhaps??)
> -- emacs should not (by default) show in a tab on the desktop
> -- C-x C-c should close a frame not emacs
> -- it should be possible for emacs to be running without there being any
> frame

I think Emacs 23 will work for you:

*** Emacs now supports using both X displays and ttys in one session.
With an Emacs server active (M-x server-start), `emacsclient -t'
creates a tty frame connected to the running emacs server.  You can
use any number of different ttys.  `emacsclient -c' creates a new X11
frame on the current $DISPLAY (or a tty frame if $DISPLAY is not set).

regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-08-29  9:46 ` Nikolaj Schumacher
@ 2008-08-29 11:41   ` Rustom Mody
  2008-08-29 13:41     ` Nikolaj Schumacher
       [not found]   ` <mailman.17876.1220010121.18990.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 20+ messages in thread
From: Rustom Mody @ 2008-08-29 11:41 UTC (permalink / raw
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1724 bytes --]

On Fri, Aug 29, 2008 at 3:16 PM, Nikolaj Schumacher <me@nschum.de> wrote:

> "Rustom Mody" <rustompmody@gmail.com> wrote:
>
> > -- starting emacs as a service (using Sc perhaps??)
> > -- emacs should not (by default) show in a tab on the desktop
> > -- C-x C-c should close a frame not emacs
> > -- it should be possible for emacs to be running without there being any
> > frame
>
> I think Emacs 23 will work for you:
>
> *** Emacs now supports using both X displays and ttys in one session.
> With an Emacs server active (M-x server-start), `emacsclient -t'
> creates a tty frame connected to the running emacs server.  You can
> use any number of different ttys.  `emacsclient -c' creates a new X11
> frame on the current $DISPLAY (or a tty frame if $DISPLAY is not set).
>
> regards,
> Nikolaj Schumacher
>


X11?? I am on Windows!

Torsten Mueller wrote:

> What is a "tab on the desktop"?

Sorry I should have said 'taskbar' (Im not very windows-savvy :-) )

  -- C-x C-c should close a frame not emacs


> A Windows service normally does not react on keys at all.

It does not need to.  The server would be invoked by the client.
All that is normally done by emacs would be done by the emacs (running as)
server.


> I think what you mean is something like the emacs client/server concept.


Yeah I know. I started by saying that the emacs side is easy: (server-start)
which of course makes sense only if it is connected to by emacsclient(s).

The whole question was about integrating this -- emacs client-server model
-- into the windows service framework (which I know nothing about as is
perhaps evident).
If as you say that it requires deep changes to the structure of emacs
sources I guess I just drop the idea!

[-- Attachment #2: Type: text/html, Size: 2862 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
       [not found]   ` <mailman.17876.1220010121.18990.help-gnu-emacs@gnu.org>
@ 2008-08-29 13:05     ` Torsten Mueller
  0 siblings, 0 replies; 20+ messages in thread
From: Torsten Mueller @ 2008-08-29 13:05 UTC (permalink / raw
  To: help-gnu-emacs

"Rustom Mody" <rustompmody@gmail.com> schrieb:

> If as you say that it requires deep changes to the structure of
> emacs sources I guess I just drop the idea!

Not deep. But changes. And tests.

T.M.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-08-29 11:41   ` Rustom Mody
@ 2008-08-29 13:41     ` Nikolaj Schumacher
  2008-08-29 14:40       ` Eli Zaretskii
                         ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Nikolaj Schumacher @ 2008-08-29 13:41 UTC (permalink / raw
  To: Rustom Mody; +Cc: help-gnu-emacs

"Rustom Mody" <rustompmody@gmail.com> wrote:

>> I think Emacs 23 will work for you:
>>
>> *** Emacs now supports using both X displays and ttys in one session.
>
> X11?? I am on Windows!

Well, Windows is not the native platform for Emacs, as such descriptions
might not always cater towards it.

I don't know if this feature is currently working in Windows (it is
still under development), but it's rather safe to assume it will
eventually.

There is no other way to do what you want, otherwise support wouldn't
have to be added. ;)


regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-08-29 13:41     ` Nikolaj Schumacher
@ 2008-08-29 14:40       ` Eli Zaretskii
  2008-08-29 16:40         ` Nikolaj Schumacher
  2008-08-30 10:53       ` Rustom Mody
       [not found]       ` <mailman.17988.1220093630.18990.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2008-08-29 14:40 UTC (permalink / raw
  To: help-gnu-emacs

> From: Nikolaj Schumacher <me@nschum.de>
> Date: Fri, 29 Aug 2008 15:41:42 +0200
> Cc: help-gnu-emacs@gnu.org
> 
> >> *** Emacs now supports using both X displays and ttys in one session.
> >
> > X11?? I am on Windows!
> 
> Well, Windows is not the native platform for Emacs, as such descriptions
> might not always cater towards it.
> 
> I don't know if this feature is currently working in Windows (it is
> still under development), but it's rather safe to assume it will
> eventually.

Actually, it's rather doubtful that multi-tty will ever be supported
on Windows, because it relies on behavior whose Windows equivalent is
almost completely undocumented.  So unless some expert comes on board
who knows the internals of the Windows console, the hope for having
this feature on Windows is null and void.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
       [not found] <mailman.17859.1219992155.18990.help-gnu-emacs@gnu.org>
  2008-08-29  6:52 ` Torsten Mueller
@ 2008-08-29 15:06 ` Chet
  2008-08-29 16:04 ` Ken Goldman
  2008-08-29 16:24 ` Dan Espen
  3 siblings, 0 replies; 20+ messages in thread
From: Chet @ 2008-08-29 15:06 UTC (permalink / raw
  To: help-gnu-emacs

"Rustom Mody" <rustompmody@gmail.com> writes:

> I want to start emacs as a service (This is under windows)
> The emacs-y side is easy (server-start)
> But I want to do it also from the windows perspective.
> This involves:
> -- starting emacs as a service (using Sc perhaps??)
> -- emacs should not (by default) show in a tab on the desktop
> -- C-x C-c should close a frame not emacs
> -- it should be possible for emacs to be running without there being any frame
>  
> Anyone done somethng like this?

Actually it looks like what is needed is the ability to minimize emacs frames
to the system tray. A web search found many applications that claim to be
able to minimize *any* window to the system tray. I tried one such and it
completely ignored emacs frames, so obviously there is something missing that I
will try to find out. But has anybody been successful with such "window
managers" on w32?

Chetan


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
       [not found] <mailman.17859.1219992155.18990.help-gnu-emacs@gnu.org>
  2008-08-29  6:52 ` Torsten Mueller
  2008-08-29 15:06 ` Chet
@ 2008-08-29 16:04 ` Ken Goldman
  2008-08-29 16:24 ` Dan Espen
  3 siblings, 0 replies; 20+ messages in thread
From: Ken Goldman @ 2008-08-29 16:04 UTC (permalink / raw
  To: help-gnu-emacs

Rustom Mody wrote:
> I want to start emacs as a service (This is under windows)
> The emacs-y side is easy (server-start)
> But I want to do it also from the windows perspective.
> This involves:
> -- starting emacs as a service (using Sc perhaps??)
> -- emacs should not (by default) show in a tab on the desktop
> -- C-x C-c should close a frame not emacs

I can answer this piece:

(global-set-key "\C-x\C-c"	'delete-frame)

> -- it should be possible for emacs to be running without there being any 
> frame
>  
> Anyone done something like this?


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
       [not found] <mailman.17859.1219992155.18990.help-gnu-emacs@gnu.org>
                   ` (2 preceding siblings ...)
  2008-08-29 16:04 ` Ken Goldman
@ 2008-08-29 16:24 ` Dan Espen
  3 siblings, 0 replies; 20+ messages in thread
From: Dan Espen @ 2008-08-29 16:24 UTC (permalink / raw
  To: help-gnu-emacs

"Rustom Mody" <rustompmody@gmail.com> writes:

>    I want to start emacs as a service (This is under windows)
>    The emacs-y side is easy (server-start)
>    But I want to do it also from the windows perspective.
>    This involves:
>    -- starting emacs as a service (using Sc perhaps??)
>    -- emacs should not (by default) show in a tab on the desktop

Since I don't "do Windows", I'm not sure what it takes to be
a windows service.

>    -- C-x C-c should close a frame not emacs

As someone else said, rebind the key to delete frame.

>    -- it should be possible for emacs to be running without there being
>    any frame

XEmacs has a command line argument "-unmapped" to accomplish
that.  It doesn't seem to work for my version of emacs,
but maybe someone could add that to emacs.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-08-29 14:40       ` Eli Zaretskii
@ 2008-08-29 16:40         ` Nikolaj Schumacher
  0 siblings, 0 replies; 20+ messages in thread
From: Nikolaj Schumacher @ 2008-08-29 16:40 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> wrote:

> Actually, it's rather doubtful that multi-tty will ever be supported
> on Windows

I apologize then.  I did a search on this.  I guess the success messages
I've found were just about it not crashing anymore...

regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-08-29 13:41     ` Nikolaj Schumacher
  2008-08-29 14:40       ` Eli Zaretskii
@ 2008-08-30 10:53       ` Rustom Mody
       [not found]       ` <mailman.17988.1220093630.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 20+ messages in thread
From: Rustom Mody @ 2008-08-30 10:53 UTC (permalink / raw
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

Ken Goldman said:

> I can answer this piece:
> (global-set-key "\C-x\C-c"    'delete-frame)

Have you tried this with a single existing frame? Does not allow it for
me...

[-- Attachment #2: Type: text/html, Size: 253 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
       [not found]       ` <mailman.17988.1220093630.18990.help-gnu-emacs@gnu.org>
@ 2008-09-02 18:00         ` Ken Goldman
  2008-09-02 18:34           ` Richard G Riley
  0 siblings, 1 reply; 20+ messages in thread
From: Ken Goldman @ 2008-09-02 18:00 UTC (permalink / raw
  To: help-gnu-emacs

Rustom Mody wrote:
> Ken Goldman said:
> 
>> I can answer this piece: (global-set-key "\C-x\C-c"
>> 'delete-frame)
> 
> Have you tried this with a single existing frame? Does not allow it
> for me...

That's a feature.  :-)

When I run emacs as a server, I often start many frames as I double 
click various files.  At times, I want to clean up by deleting these 
frames.  But I don't want to delete the very last frame (would that kill 
the server?).

The use model for emacs as a server is that you start it once at log in 
and let it run forever.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-09-02 18:00         ` Ken Goldman
@ 2008-09-02 18:34           ` Richard G Riley
  2008-09-02 18:42             ` Pascal J. Bourguignon
  0 siblings, 1 reply; 20+ messages in thread
From: Richard G Riley @ 2008-09-02 18:34 UTC (permalink / raw
  To: help-gnu-emacs

Ken Goldman <kgold@watson.ibm.com> writes:

> Rustom Mody wrote:
>> Ken Goldman said:
>>
>>> I can answer this piece: (global-set-key "\C-x\C-c"
>>> 'delete-frame)
>>
>> Have you tried this with a single existing frame? Does not allow it
>> for me...
>
> That's a feature.  :-)
>
> When I run emacs as a server, I often start many frames as I double
> click various files.  At times, I want to clean up by deleting these
> frames.  But I don't want to delete the very last frame (would that
> kill the server?).
>
> The use model for emacs as a server is that you start it once at log
> in and let it run forever.
>

Must the server have a physical display though? Can emacs client connect
and generate its own frame and display? e.g so I dont accidentally close
the "server" when tidying up I would like the "server" to by invisible.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2008-09-02 18:34           ` Richard G Riley
@ 2008-09-02 18:42             ` Pascal J. Bourguignon
  0 siblings, 0 replies; 20+ messages in thread
From: Pascal J. Bourguignon @ 2008-09-02 18:42 UTC (permalink / raw
  To: help-gnu-emacs

Richard G Riley <rileyrgdev@gmail.com> writes:

> Ken Goldman <kgold@watson.ibm.com> writes:
>
>> Rustom Mody wrote:
>>> Ken Goldman said:
>>>
>>>> I can answer this piece: (global-set-key "\C-x\C-c"
>>>> 'delete-frame)
>>>
>>> Have you tried this with a single existing frame? Does not allow it
>>> for me...
>>
>> That's a feature.  :-)
>>
>> When I run emacs as a server, I often start many frames as I double
>> click various files.  At times, I want to clean up by deleting these
>> frames.  But I don't want to delete the very last frame (would that
>> kill the server?).
>>
>> The use model for emacs as a server is that you start it once at log
>> in and let it run forever.
>>
>
> Must the server have a physical display though? Can emacs client connect
> and generate its own frame and display? e.g so I dont accidentally close
> the "server" when tidying up I would like the "server" to by invisible.

One can use the multitty branch of emacs (or perhaps I'm late and it's
already merged somewhere?). Then you can launch emacs in detachtty or
screen, and still make frames on X displays.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* emacs as a service
@ 2009-03-08 13:52 rustom
  2009-03-08 14:08 ` Marc Tfardy
  2009-03-08 20:39 ` B. T. Raven
  0 siblings, 2 replies; 20+ messages in thread
From: rustom @ 2009-03-08 13:52 UTC (permalink / raw
  To: help-gnu-emacs; +Cc: Scott Turner

This is about tweaking emacs to run (somewhat like) a service.
Environment is emacs22 on win-XP.

I describing my current configuration with questions here and there in
the hope that some (better) solutions will come out.

Normally emacs runs with 1 or more windows (frames in emacsspeak)
multiple emacs processes have no relation wilth each other.

So in sort the typical setup is:
0 or more emacses each having 1 or more frame.

By a server setup I mean the following (which may not be proper usage
from the os service point of view)
0 or 1 emacs having 0 or more frames.

So first thing I did
--------------
; from http://www.emacswiki.org/cgi-bin/wiki/RupertSwarbrick#toc1
 (defun buffer-used-elsewhere-p (&optional buf)
   "Returns true if more than one window is attached to BUF in all
 frames. If buf is nil or not supplied, search
 for (CURRENT-BUFFER)."
   (unless buf (setq buf (current-buffer)))
   (< 1 (length (get-buffer-window-list buf nil t))))

 (defun delete-frame-ex ()
   "Delete frame as normal, unless we're on the last frame, in
   which case, exit emacs as we would normally do"
   (interactive)
   (if (eq (selected-frame) (next-frame (selected-frame) 0))
       ;; This is the last frame
       (save-buffers-kill-emacs)
    ;; There's more!
     (unless (buffer-used-elsewhere-p) (kill-buffer nil))
     (delete-frame)))

(global-set-key "\C-x\C-c" 'delete-frame-ex)
-----------------

This basically makes C-x C-c kill frames rather than kill emacs except
for the last one in which case it kills emacs.

Then recently got some solutions from Scott Turner that prompted me to
try again:

I changed the line
       (save-buffers-kill-emacs)
above to
       (make-frame-invisible (car (frame-list)) t)
which makes the last frame behavior consistent with the others (and
emacs unkillable unless one uses explicit M-x kill-emacs).  Basically
emacs disappears rather than dying.

Q: Obviously the (car (frame-list)) thingy is clumsy. Any better way?
Also I want to bind the X on the window top right to function delete-
frame-ex
rather than the default save-buffer-kill-emacs. How to do that?

To move to a more client-server oriented model.
The default emacs program that runs is to be replaced by this vbs
script
------------
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)
-------------
Q: Whats the diff between emacs and runemacs?
Q: The for loop is ugly but my windows/vbs is out of depth here

This script basically does a 4=2x2 way check:
Is emacs server running or not?
Is the script called with an argument or not?
And the default bindings for emacs-ish files (in my case .txt, .org)
is bound to this script in the registry.

If someone can offer HKEY magic to automate this that'd be nice.

Now one fragile aspect of this is that if 2 emacsservers run well the
system is borked!  How is the (server-start) to be enclosed in a
(if server-not-started-p ...) ?

And one (entirely windowsy) related question:
How to catch the system login, logout, shutdown etc events?
Once I can get some script to give me some control for this I can use
emacsclient to do appropriate actions.

Thanks (if you read so far!)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2009-03-08 13:52 rustom
@ 2009-03-08 14:08 ` Marc Tfardy
  2009-03-08 20:39 ` B. T. Raven
  1 sibling, 0 replies; 20+ messages in thread
From: Marc Tfardy @ 2009-03-08 14:08 UTC (permalink / raw
  To: help-gnu-emacs

rustom schrieb:
 > This is about tweaking emacs to run (somewhat like) a service.
 > Environment is emacs22 on win-XP.
 >
 > I describing my current configuration with questions here and there in
 > the hope that some (better) solutions will come out.
[...]

Maybe you should read about "Emacs dameon"? This is a featrue of Emacs
23. You start Emacs with "emacs --daemon" but no frame appear on screen.


Reagrds
Marc




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2009-03-08 13:52 rustom
  2009-03-08 14:08 ` Marc Tfardy
@ 2009-03-08 20:39 ` B. T. Raven
  2009-03-09 11:42   ` rustom
  1 sibling, 1 reply; 20+ messages in thread
From: B. T. Raven @ 2009-03-08 20:39 UTC (permalink / raw
  To: help-gnu-emacs

rustom wrote:
> This is about tweaking emacs to run (somewhat like) a service.
> Environment is emacs22 on win-XP.
> 
> I describing my current configuration with questions here and there in
> the hope that some (better) solutions will come out.
> 
> Normally emacs runs with 1 or more windows (frames in emacsspeak)
> multiple emacs processes have no relation wilth each other.
> 
> So in sort the typical setup is:
> 0 or more emacses each having 1 or more frame.
> 
> By a server setup I mean the following (which may not be proper usage
> from the os service point of view)
> 0 or 1 emacs having 0 or more frames.
> 
> So first thing I did
> --------------
> ; from http://www.emacswiki.org/cgi-bin/wiki/RupertSwarbrick#toc1
>  (defun buffer-used-elsewhere-p (&optional buf)
>    "Returns true if more than one window is attached to BUF in all
>  frames. If buf is nil or not supplied, search
>  for (CURRENT-BUFFER)."
>    (unless buf (setq buf (current-buffer)))
>    (< 1 (length (get-buffer-window-list buf nil t))))
> 
>  (defun delete-frame-ex ()
>    "Delete frame as normal, unless we're on the last frame, in
>    which case, exit emacs as we would normally do"
>    (interactive)
>    (if (eq (selected-frame) (next-frame (selected-frame) 0))
>        ;; This is the last frame
>        (save-buffers-kill-emacs)
>     ;; There's more!
>      (unless (buffer-used-elsewhere-p) (kill-buffer nil))
>      (delete-frame)))
> 
> (global-set-key "\C-x\C-c" 'delete-frame-ex)
> -----------------
> 
> This basically makes C-x C-c kill frames rather than kill emacs except
> for the last one in which case it kills emacs.
> 
> Then recently got some solutions from Scott Turner that prompted me to
> try again:
> 
> I changed the line
>        (save-buffers-kill-emacs)
> above to
>        (make-frame-invisible (car (frame-list)) t)
> which makes the last frame behavior consistent with the others (and
> emacs unkillable unless one uses explicit M-x kill-emacs).  Basically
> emacs disappears rather than dying.
> 
> Q: Obviously the (car (frame-list)) thingy is clumsy. Any better way?
> Also I want to bind the X on the window top right to function delete-
> frame-ex
> rather than the default save-buffer-kill-emacs. How to do that?
> 
> To move to a more client-server oriented model.
> The default emacs program that runs is to be replaced by this vbs
> script
> ------------
> 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)
> -------------
> Q: Whats the diff between emacs and runemacs?

I think that runemacs is just a wrapper used to suppress the appearance 
of the command window. It is after all only 217kB in size.

> Q: The for loop is ugly but my windows/vbs is out of depth here
> 
> This script basically does a 4=2x2 way check:
> Is emacs server running or not?
> Is the script called with an argument or not?
> And the default bindings for emacs-ish files (in my case .txt, .org)
> is bound to this script in the registry.
> 
> If someone can offer HKEY magic to automate this that'd be nice.

I'm not sure I understand your problem or how it differs from just 
putting emacsclientw in the Windows Registry. You don't need VB to do that:

(server-start)
goes in .emacs (Emacs version 22.1)

ALTERNATE_EDITOR=C:\emacs\bin\runemacs.exe
goes in environment

in HKCR hive
*/shell/open/command
default c:\emacs\bin\emacsclientw.exe -n "%1"

Applications/emacsclientw.exe/shell/open/command
default c:\emacs\bin\emacsclientw.exe -n "%1"

I think that these will propagate to the HKLM hive on startup but beware 
of manual registry surgery. At one point, when I clicked on files 
associated with Emacs in Windows Explorer, all that would happen was 
that the runemacs.exe binary would load into an emacs buffer, a 
consummation not devoutly to be wished for. Also, it's safest to make 
associations from WE with Tools>Folder Options>File Types rather than in 
the registry but you may need ./ (also in HKCR) set to something like 
ft000003, ft000002, or ft000001 for click-opening extensionless files 
(e.g. readme). I think these are automatically generated user file types 
but I can't find any documentation on them. Again beware; some system 
files don't have extensions , even parts of the registry itself.
See:
http://www.emacswiki.org/emacs/EmacsClient#toc6

> 
> Now one fragile aspect of this is that if 2 emacsservers run well the
> system is borked!  How is the (server-start) to be enclosed in a
> (if server-not-started-p ...) ?

Is that... run well or run, well.... ;-)
> 
> And one (entirely windowsy) related question:
> How to catch the system login, logout, shutdown etc events?
> Once I can get some script to give me some control for this I can use
> emacsclient to do appropriate actions.

I am totally out of my depth here. Don't MSwin processes with pending 
open files warn about needed actions in case of logout or shutdown?

> 
> Thanks (if you read so far!)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2009-03-08 20:39 ` B. T. Raven
@ 2009-03-09 11:42   ` rustom
  2009-03-09 22:01     ` Chris McMahan
  0 siblings, 1 reply; 20+ messages in thread
From: rustom @ 2009-03-09 11:42 UTC (permalink / raw
  To: help-gnu-emacs

On Mar 9, 1:39 am, "B. T. Raven" <ni...@nihilo.net> wrote:
> ALTERNATE_EDITOR=C:\emacs\bin\runemacs.exe
> goes in environment
This ALTERNATE_EDITOR thing almost works but for some reason it wants
to say Connect: No error (talk of rules and exceptions :-) and then
connects.
and so for that (that message) it puts up a DOS (cmd) window which is
a pain.
I prefer .vbs to .bat mainly because of this.
>
> in HKCR hive
> */shell/open/command
> default c:\emacs\bin\emacsclientw.exe -n "%1"
>
> Applications/emacsclientw.exe/shell/open/command
> default c:\emacs\bin\emacsclientw.exe -n "%1"
>
> I think that these will propagate to the HKLM hive on startup but beware
> of manual registry surgery. At one point, when I clicked on files
> associated with Emacs in Windows Explorer, all that would happen was
> that the runemacs.exe binary would load into an emacs buffer, a
> consummation not devoutly to be wished for. Also, it's safest to make
> associations from WE with Tools>Folder Options>File Types rather than in
> the registry but you may need ./ (also in HKCR) set to something like
> ft000003, ft000002, or ft000001 for click-opening extensionless files
> (e.g. readme). I think these are automatically generated user file types
> but I can't find any documentation on them. Again beware; some system
> files don't have extensions , even parts of the registry itself.
> See:http://www.emacswiki.org/emacs/EmacsClient#toc6
>
>
>
> > Now one fragile aspect of this is that if 2 emacsservers run well the
> > system is borked!  How is the (server-start) to be enclosed in a
> > (if server-not-started-p ...) ?
>
> Is that... run well or run, well.... ;-)
:D
>
>
>
> > And one (entirely windowsy) related question:
> > How to catch the system login, logout, shutdown etc events?
> > Once I can get some script to give me some control for this I can use
> > emacsclient to do appropriate actions.
>
> I am totally out of my depth here. Don't MSwin processes with pending
> open files warn about needed actions in case of logout or shutdown?

I guess they do; but I want control before that. In particular before
shutdown I want to do some actions, before lock computer some others
after logging in some others etc.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: emacs as a service
  2009-03-09 11:42   ` rustom
@ 2009-03-09 22:01     ` Chris McMahan
  0 siblings, 0 replies; 20+ messages in thread
From: Chris McMahan @ 2009-03-09 22:01 UTC (permalink / raw
  To: help-gnu-emacs

Using Windows XP and Emacs 23.0.90.1, I always launch emacs from a shell
window (rxvt running tcsh in my case) in which I've set the following
relevant envrionment variables in my .tcshrc:

setenv EDITOR "emacsclient --alternate-editor runemacs"
setenv ALTERNATE_EDITOR "runemacs"

My path also includes the emacs/bin directory...

The --alternate-editor switch is probably redundant, but that's what it
took to get it working for me.

- Chris

rustom <rustompmody@gmail.com> writes:

> On Mar 9, 1:39 am, "B. T. Raven" <ni...@nihilo.net> wrote:
>> ALTERNATE_EDITOR=C:\emacs\bin\runemacs.exe
>> goes in environment
> This ALTERNATE_EDITOR thing almost works but for some reason it wants
> to say Connect: No error (talk of rules and exceptions :-) and then
> connects.
> and so for that (that message) it puts up a DOS (cmd) window which is
> a pain.
> I prefer .vbs to .bat mainly because of this.
>>
>> in HKCR hive
>> */shell/open/command
>> default c:\emacs\bin\emacsclientw.exe -n "%1"
>>
>> Applications/emacsclientw.exe/shell/open/command
>> default c:\emacs\bin\emacsclientw.exe -n "%1"
>>
>> I think that these will propagate to the HKLM hive on startup but beware
>> of manual registry surgery. At one point, when I clicked on files
>> associated with Emacs in Windows Explorer, all that would happen was
>> that the runemacs.exe binary would load into an emacs buffer, a
>> consummation not devoutly to be wished for. Also, it's safest to make
>> associations from WE with Tools>Folder Options>File Types rather than in
>> the registry but you may need ./ (also in HKCR) set to something like
>> ft000003, ft000002, or ft000001 for click-opening extensionless files
>> (e.g. readme). I think these are automatically generated user file types
>> but I can't find any documentation on them. Again beware; some system
>> files don't have extensions , even parts of the registry itself.
>> See:http://www.emacswiki.org/emacs/EmacsClient#toc6
>>
>>
>>
>> > Now one fragile aspect of this is that if 2 emacsservers run well the
>> > system is borked!  How is the (server-start) to be enclosed in a
>> > (if server-not-started-p ...) ?
>>
>> Is that... run well or run, well.... ;-)
> :D
>>
>>
>>
>> > And one (entirely windowsy) related question:
>> > How to catch the system login, logout, shutdown etc events?
>> > Once I can get some script to give me some control for this I can use
>> > emacsclient to do appropriate actions.
>>
>> I am totally out of my depth here. Don't MSwin processes with pending
>> open files warn about needed actions in case of logout or shutdown?
>
> I guess they do; but I want control before that. In particular before
> shutdown I want to do some actions, before lock computer some others
> after logging in some others etc.

-- 
     (.   .)
  =ooO=(_)=Ooo=====================================
  Chris McMahan | first_initiallastname@one.dot.net
  =================================================


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-03-09 22:01 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29  6:42 emacs as a service Rustom Mody
2008-08-29  9:46 ` Nikolaj Schumacher
2008-08-29 11:41   ` Rustom Mody
2008-08-29 13:41     ` Nikolaj Schumacher
2008-08-29 14:40       ` Eli Zaretskii
2008-08-29 16:40         ` Nikolaj Schumacher
2008-08-30 10:53       ` Rustom Mody
     [not found]       ` <mailman.17988.1220093630.18990.help-gnu-emacs@gnu.org>
2008-09-02 18:00         ` Ken Goldman
2008-09-02 18:34           ` Richard G Riley
2008-09-02 18:42             ` Pascal J. Bourguignon
     [not found]   ` <mailman.17876.1220010121.18990.help-gnu-emacs@gnu.org>
2008-08-29 13:05     ` Torsten Mueller
     [not found] <mailman.17859.1219992155.18990.help-gnu-emacs@gnu.org>
2008-08-29  6:52 ` Torsten Mueller
2008-08-29 15:06 ` Chet
2008-08-29 16:04 ` Ken Goldman
2008-08-29 16:24 ` Dan Espen
  -- strict thread matches above, loose matches on Subject: below --
2009-03-08 13:52 rustom
2009-03-08 14:08 ` Marc Tfardy
2009-03-08 20:39 ` B. T. Raven
2009-03-09 11:42   ` rustom
2009-03-09 22:01     ` Chris McMahan

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.