home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / me34src.zip / me3 / mutt / builtin / delbuf.mut < prev    next >
Text File  |  1995-01-14  |  1KB  |  40 lines

  1.    ;; delbuf.mut : Dispose of a buffer, by name.
  2.    ;; Default is current buffer.
  3.    ;; If a window is displaying the buffer to be deleted, delete that
  4.    ;;   window.
  5.    ;; C Durland        Public Domain
  6.  
  7. (include me.mh)
  8.  
  9. (defun
  10.   delete-buffer
  11.   {
  12.     (string name)(int j n buf-id)
  13.  
  14.     (name (complete CC_BUF "Delete buffer: "))
  15.     (if (== name "") (buf-id (current-buffer))    ;; use the default 
  16.       (if (== -2 (buf-id (attached-buffer name)))
  17.     { (msg '"' name '" is not a buffer.')(done) }))
  18.  
  19.         ;; Ask before we delete a modified buffer we care about
  20.     (if (and
  21.           (== BFModified    ;; Check to see if we care about this buffer
  22.           (bit-and (buffer-flags buf-id) (bit-or BFModified BFNoCare)))
  23.           (not (yesno (buffer-name buf-id) " has changed.  Delete anyway")))
  24.        (done))            ;; They don't want to delete it
  25.  
  26.     (if (arg-flag)
  27.       {
  28.         ;; remove all windows displaying buffer to be deleted
  29.         ;; (unless its the only one left).
  30.     (n 0)
  31.     (while (and (< n (windows))(> (windows) 1))
  32.     {
  33.       (if (== buf-id (attached-buffer n)) { (free-window n) (continue) } )
  34.       (+= n 1)
  35.     })
  36.       })
  37.     (free-buffer buf-id)            ;; Kiss that sucka goodbye
  38.   }
  39. )
  40.