Lisp HUG Maillist Archive

programmatically closing editor window

I have a graphical app that opens text editor windows to edit text.

What is the preferred way to write a defcommand that will call my save routine 
then close (destroy) the one window from which the command was 
keystroke-invoked?

I've tried:

[1]

(editor:defcommand "Save Text Atom" (p) (declare (ignore p))
     (let ((intf (gethash (editor:current-buffer) *buffer-to-intf*)))
       (when intf
         (save-contents nil intf)
         (capi:destroy (get-top-interface intf)))))   <<<< 

[2]
(editor:defcommand "Save Text Atom" (p) (declare (ignore p))
     (let ((intf (gethash (editor:current-buffer) *buffer-to-intf*)))
       (when intf
         (save-contents nil intf)
         (editor:delete-window-command))))  <<<<<<

Version [1] works sometimes, but after a few calls, leaves a hung editor 
window which cannot be closed by any means (other than shutting LWL down).  
[This seems to imply that I've caused a race condition by mistreating LWL].

Version [2] leaves an empty editor window behind (at least on LWL) then brings 
to the front any other editor window (like my lisp text editor), obscuring 
the graphical app (annoying).

If I attach "save-command" to the :destroy-callback of the edit window, I get 
the desired behaviour, except that the UI gesture is clumsy (move hands from 
keyboard to mouse) - I want to mimic that behaviour from a single keystroke.

[What I really want is an in-place text-edit widget, but I don't believe that 
that exists, so I'm using a pop-up, pop-down editor].

thanx
pt


Re: programmatically closing editor window

On Aug 19, 2004, at 10:25 AM, tarvydas wrote:

> (editor:defcommand "Save Text Atom" (p) (declare (ignore p))
>      (let ((intf (gethash (editor:current-buffer) *buffer-to-intf*)))
>        (when intf
>          (save-contents nil intf)
>          (capi:destroy (get-top-interface intf)))))   <<<<


You might try having your command only call destroy and then do your 
save operation in the destroy-callback of the interface. I think you 
will have lots of problems if you try to destroy the editors 
surrounding interface in the middle of a command.

John DeSoi, Ph.D.


Re: programmatically closing editor window

Unable to parse email body. Email id is 2736

Updated at: 2020-12-10 08:55 UTC