home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / cpm / emacs / emacssrc.lzh / killbuf.c < prev    next >
C/C++ Source or Header  |  1992-03-11  |  1KB  |  52 lines

  1. /*
  2.  * Buffer management.
  3.  * Some of the functions are internal,
  4.  * and some are actually attached to user
  5.  * keys. Like everyone else, they set hints
  6.  * for the display system.
  7.  */
  8. #include    "stdio.h"
  9. #include    "ed.h"
  10.  
  11. /*
  12.  * Dispose of a buffer, by name.
  13.  * Ask for the name. Look it up (don't get too
  14.  * upset if it isn't there at all!). Get quite upset
  15.  * if the buffer is being displayed. Clear the buffer (ask
  16.  * if the buffer has been changed). Then free the header
  17.  * line and the buffer header. Bound to "C-X K".
  18.  */
  19. ovmain( x, f, n)
  20. {
  21.     register BUFFER    *bp;
  22.     register BUFFER    *bp1;
  23.     register BUFFER    *bp2;
  24.     register int    s;
  25.     char        bufn[NBUFN];
  26.  
  27.     if ((s=mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
  28.         return (s);
  29.     if ((bp=bfind(bufn, FALSE, 0)) == NULL)    /* Easy if unknown.    */
  30.         return (TRUE);
  31.     if (bp->b_nwnd != 0) {            /* Error if on screen.    */
  32.         mlwrite("Buffer is being displayed");
  33.         return (FALSE);
  34.     }
  35.     if ((s=bclear(bp)) != TRUE)        /* Blow text away.    */
  36.         return (s);
  37.     free((char *) bp->b_linep);        /* Release header line.    */
  38.     bp1 = NULL;                /* Find the header.    */
  39.     bp2 = bheadp;
  40.     while (bp2 != bp) {
  41.         bp1 = bp2;
  42.         bp2 = bp2->b_bufp;
  43.     }
  44.     bp2 = bp2->b_bufp;            /* Next one in chain.    */
  45.     if (bp1 == NULL)            /* Unlink it.        */
  46.         bheadp = bp2;
  47.     else
  48.         bp1->b_bufp = bp2;
  49.     free((char *) bp);            /* Release buffer block    */
  50.     return (TRUE);
  51. }
  52.