xwem-devel
[Top] [All Lists]

Re: macro help please -- `with-xwem-frame'

From: Zajcev Evgeny <lg@xxxxxxxx>
Subject: Re: macro help please -- `with-xwem-frame'
Date: Mon, 03 Oct 2005 16:00:17 +0400
User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux)
Hmm, yandex.ru seems to be banned on xwem.org 8-D

Steve Youngs <steve@xxxxxxxx> writes:

> This is close to what I'm looking for, but not quite there...
>
> (defmacro with-xwem-frame (frame &rest body)
>   "Execute BODY in xwem FRAME.
>
> XWEM makes FRAME the current frame, executes each form in BODY under a
> `progn' and then returns back to the originally focused frame."
>   `(when (xwem-frame-p ,frame)
>      (xwem-select-frame ,frame)
>      (progn
>        ,@body
>        (xwem-magic-to-go-back-to-frame-before-we-called-this-macro))))

It should look like:

  (defmacro xwem-with-current-frame (frame &rest body)
    `(let ((sv-frame (xwem-frame-selected)))
       (xwem-unwind-protect
           (progn
             (xwem-select-frame ,frame)
             ,@body)
         (xwem-select-frame sv-frame))))
  (put 'xwem-with-current-frame 'lisp-indent-function 'defun)

However take a note that if you will do something like:

  (xwem-with-current-frame my-cool-frame
     (xwem-execute-program "xterm")  ; or (make-frame) for example
    )

it won't do the job you are expecting it to do, i.e.  it won't start
xterm or xemacs frame  in your cool frame.  Why?  Because at the time
when xterm/xemacs is ready to Map its X window - your cool frame might
be non-selected, because `xwem-with-current-frame' already passed ..

however, there is absolutely cool(hehe) function exists -
`xwem-execute-program-expecting' which will do the job if you dont
pass non-nil NON-BLOCK parameter.

I recommend you to use next construction in order to run client in
current window of particular xwem frame:

  (xwem-execute-program-expecting "xterm" nil
    (list 'expect-win (xwem-win-id (xwem-frame-selwin my-cool-frame))) t)

However, of course you can use

  (xwem-with-current-frame my-cool-frame
    (xwem-execute-program-expecting "xterm"))

if you preffer -- but such form will block waiting xterm to map its
window (or timeout after some time) ..

>
> Ultimately, what I'd like to be able to do with this is to completely
> automate my start up.  Starting clients in specific frames (as long as
> they don't exist already).
>
> Combining things like `xwem-desktop-{save,load}', and xwem-agent is
> great.  But it doesn't do a total job.  For example, all of the
> SXEmacs frames that I have don't get restarted from the agent.  Also
> the agent is no good from a "cold" start (ie running startx from the
> console)... it only comes into its own once X is already up.
>
> I also want to keep that macro as general as possible, because I'm
> sure it'd be very useful for other things apart from starting
> clients in specific frames. :-)
>
>
> -- 
> |---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
> |                        In space,                         |
> |             No one can hear you rip a stinky             |
> |---------------------------------------<steve@xxxxxxxx>---|

-- 
lg

<Prev in Thread] Current Thread [Next in Thread>