Re: how to kill an editor buffer after the interface using it goes away?
I noticed the same thing. I think this should qualify as a bug, I don't
see any good reason why the editor pane buffer shows up in the file
editor buffer list in the first place. I see some system tools use
editor panes, and their buffers don't show up in the buffer list. I
think the same should be true for editor-pane instances.
When I try your code in LWM 5.1.1 I actually get an error:
NIL is not of type EDITOR::WINDOW when accessing slot EDITOR::TEXT-PANE.
Which makes me think the destroy-callback is called too late, at a time
when the editor cannot process commands anymore because its window is
already destroyed.
What I did and it seemed to work was to just remove the buffer from the
editor:*buffer-list* variable.
Octav
Larry Clapp wrote:
> In examples/capi/editor/editor-pane.lisp, it creates an interface that
> uses an editor-pane. When you close the interface, the buffer sticks
> around in the buffer list. How do you kill the buffer (from within
> the code)? This is what I've tried, and it doesn't work:
>
> (capi:define-interface editor-pane-test ()
> ()
> (:panes
> (editor-pane
> capi:editor-pane
> :text *editor-text*
> :echo-area-pane echo-area
> :visible-min-width '(character 80)
> :visible-min-height '(character 15)
> :reader editor-pane-of)
> (buttons
> capi:push-button-panel
> :items '("Beginning Of Buffer" "End Of Buffer" "Kill Line" "Undo")
> :callback-type :data
> :selection-callback #'(lambda (command)
> (capi:call-editor editor-pane command)))
> (echo-area capi:echo-area-pane :max-height t))
> (:default-initargs
> :title "Editor Pane Test"))
>
> (defun test-editor-pane ()
> (capi:display
> (make-instance 'editor-pane-test
> :destroy-callback (lambda (interface)
> (capi:apply-in-pane-process
> interface
> (lambda ()
> (capi:call-editor (editor-pane-of interface)
> "Kill Buffer")))))))
>
> As near as I can tell you can put anything at all in place of "Kill
> Buffer" -- I tried "Kill Bill Part 2" and it ran without error, though
> obviously still didn't kill the buffer.
>
> I don't read assembler that well, but I *think* that call-editor
> returns immediately if a pane is inactive, and doesn't look at its
> second argument.
>
> ... So I'd written this much and I poked at it some more, and it turns
> out that calling editor:kill-buffer-command directly appears to work:
>
> (defun test-editor-pane ()
> (capi:display
> (make-instance 'editor-pane-test
> :destroy-callback (lambda (interface)
> (capi:apply-in-pane-process
> interface
> (lambda ()
> (editor:kill-buffer-command
> t
> (editor:buffer-name
> (capi:editor-pane-buffer
> (editor-pane-of interface))))))))))
>
> However, I'm concerned that perhaps something is amiss with the editor
> context -- current buffer, current this-that-the-other.
>
> Can anyone comment on either call-editor not working, or on whether
> calling kill-buffer-command directly is safe?
>
> (I also note in passing that the documented function
> editor:buffers-name does not appear in my image, but
> editor:buffer-name does, and returns a buffer's name.)
>
> -- Larry
>
>
>