[climacs-devel] Kill buffer function

Lawrence Mitchell wencel at gmail.com
Thu Jan 20 23:11:18 UTC 2005


Hi there,

now that embryonic multi-buffer support is emerging, it would be
nice if one could kill buffers too.

Something like this maybe:

(define-named-command com-kill-buffer ()
  (with-slots (buffers) *application-frame*
    (let ((buffer (buffer (current-window))))
      (when (needs-saving buffer)
        ;; FIXME, needs a yes-or-no-p.
        (com-save-buffer))
    (setf buffers (remove buffer buffers))
    ;; Always need one buffer.
    (when (null buffers)
      (push (make-instance 'climacs-buffer :name "*scratch*")
            buffers))
    (setf (buffer (current-window)) (car buffers)))))

This also means that we need some kind of YES-OR-NO-P function
that shadows CL:YES-OR-NO-P, since that looks for answers on
*QUERY-IO*.

(defun yes-or-no-p (format-string &rest arguments)
  (loop
     (let ((answer (string-downcase
                    (accept 'string :prompt (apply #'format nil format-string
                                                   arguments)))))
       (cond ((string-equal answer "yes")
              (return t))
             ((string-equal answer "no")
              (return nil))
             (t nil)))))

would be a rather unfriendly version.

I can't see anything in CLIM that deals for doing this, but maybe
I'm missing something.

-- 
Lawrence Mitchell <wence at gmx.li>




More information about the climacs-devel mailing list