(linenum→info "unix/slp.c:2238")

emacs/22.1/src/buffer.c

    1: /* Buffer manipulation primitives for GNU Emacs.
    2:    Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994,
    3:                  1995, 1997, 1998, 1999, 2000, 2001, 2002,
    4:                  2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    5: 
    6: This file is part of GNU Emacs.
    7: 
    8: GNU Emacs is free software; you can redistribute it and/or modify
    9: it under the terms of the GNU General Public License as published by
   10: the Free Software Foundation; either version 2, or (at your option)
   11: any later version.
   12: 
   13: GNU Emacs is distributed in the hope that it will be useful,
   14: but WITHOUT ANY WARRANTY; without even the implied warranty of
   15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16: GNU General Public License for more details.
   17: 
   18: You should have received a copy of the GNU General Public License
   19: along with GNU Emacs; see the file COPYING.  If not, write to
   20: the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   21: Boston, MA 02110-1301, USA.  */
   22: 
   23: #include <config.h>
   24: 
   25: #include <sys/types.h>
   26: #include <sys/stat.h>
   27: #include <sys/param.h>
   28: #include <errno.h>
   29: #include <stdio.h>
   30: 
   31: #ifndef USE_CRT_DLL
   32: extern int errno;
   33: #endif
   34: 
   35: 
   36: #ifdef HAVE_UNISTD_H
   37: #include <unistd.h>
   38: #endif
   39: 
   40: #include "lisp.h"
   41: #include "intervals.h"
   42: #include "window.h"
   43: #include "commands.h"
   44: #include "buffer.h"
   45: #include "charset.h"
   46: #include "region-cache.h"
   47: #include "indent.h"
   48: #include "blockinput.h"
   49: #include "keyboard.h"
   50: #include "keymap.h"
   51: #include "frame.h"
   52: 
   53: struct buffer *current_buffer;          /* the current buffer */
   54: 
   55: /* First buffer in chain of all buffers (in reverse order of creation).
   56:    Threaded through ->next.  */
   57: 
   58: struct buffer *all_buffers;
   59: 
   60: /* This structure holds the default values of the buffer-local variables
   61:    defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
   62:    The default value occupies the same slot in this structure
   63:    as an individual buffer's value occupies in that buffer.
   64:    Setting the default value also goes through the alist of buffers
   65:    and stores into each buffer that does not say it has a local value.  */
   66: 
   67: DECL_ALIGN (struct buffer, buffer_defaults);
   68: 
   69: /* A Lisp_Object pointer to the above, used for staticpro */
   70: 
   71: static Lisp_Object Vbuffer_defaults;
   72: 
   73: /* This structure marks which slots in a buffer have corresponding
   74:    default values in buffer_defaults.
   75:    Each such slot has a nonzero value in this structure.
   76:    The value has only one nonzero bit.
   77: 
   78:    When a buffer has its own local value for a slot,
   79:    the entry for that slot (found in the same slot in this structure)
   80:    is turned on in the buffer's local_flags array.
   81: 
   82:    If a slot in this structure is -1, then even though there may
   83:    be a DEFVAR_PER_BUFFER for the slot, there is no default value for it;
   84:    and the corresponding slot in buffer_defaults is not used.
   85: 
   86:    If a slot is -2, then there is no DEFVAR_PER_BUFFER for it,
   87:    but there is a default value which is copied into each buffer.
   88: 
   89:    If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
   90:    zero, that is a bug */
   91: 
   92: struct buffer buffer_local_flags;
   93: 
   94: /* This structure holds the names of symbols whose values may be
   95:    buffer-local.  It is indexed and accessed in the same way as the above. */
   96: 
   97: DECL_ALIGN (struct buffer, buffer_local_symbols);
   98: 
   99: /* A Lisp_Object pointer to the above, used for staticpro */
  100: static Lisp_Object Vbuffer_local_symbols;
  101: 
  102: /* This structure holds the required types for the values in the
  103:    buffer-local slots.  If a slot contains Qnil, then the
  104:    corresponding buffer slot may contain a value of any type.  If a
  105:    slot contains an integer, then prospective values' tags must be
  106:    equal to that integer (except nil is always allowed).
  107:    When a tag does not match, the function
  108:    buffer_slot_type_mismatch will signal an error.
  109: 
  110:    If a slot here contains -1, the corresponding variable is read-only.  */
  111: struct buffer buffer_local_types;
  112: 
  113: /* Flags indicating which built-in buffer-local variables
  114:    are permanent locals.  */
  115: static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
  116: 
  117: /* Number of per-buffer variables used.  */
  118: 
  119: int last_per_buffer_idx;
  120: 
  121: Lisp_Object Fset_buffer ();
  122: void set_buffer_internal ();
  123: void set_buffer_internal_1 ();
  124: static void call_overlay_mod_hooks ();
  125: static void swap_out_buffer_local_variables ();
  126: static void reset_buffer_local_variables ();
  127: 
  128: /* Alist of all buffer names vs the buffers. */
  129: /* This used to be a variable, but is no longer,
  130:  to prevent lossage due to user rplac'ing this alist or its elements.  */
  131: Lisp_Object Vbuffer_alist;
  132: 
  133: /* Functions to call before and after each text change. */
  134: Lisp_Object Vbefore_change_functions;
  135: Lisp_Object Vafter_change_functions;
  136: 
  137: Lisp_Object Vtransient_mark_mode;
  138: 
  139: /* t means ignore all read-only text properties.
  140:    A list means ignore such a property if its value is a member of the list.
  141:    Any non-nil value means ignore buffer-read-only.  */
  142: Lisp_Object Vinhibit_read_only;
  143: 
  144: /* List of functions to call that can query about killing a buffer.
  145:    If any of these functions returns nil, we don't kill it.  */
  146: Lisp_Object Vkill_buffer_query_functions;
  147: Lisp_Object Qkill_buffer_query_functions;
  148: 
  149: /* Hook run before changing a major mode.  */
  150: Lisp_Object Vchange_major_mode_hook, Qchange_major_mode_hook;
  151: 
  152: /* List of functions to call before changing an unmodified buffer.  */
  153: Lisp_Object Vfirst_change_hook;
  154: 
  155: Lisp_Object Qfirst_change_hook;
  156: Lisp_Object Qbefore_change_functions;
  157: Lisp_Object Qafter_change_functions;
  158: Lisp_Object Qucs_set_table_for_input;
  159: 
  160: /* If nonzero, all modification hooks are suppressed.  */
  161: int inhibit_modification_hooks;
  162: 
  163: Lisp_Object Qfundamental_mode, Qmode_class, Qpermanent_local;
  164: 
  165: Lisp_Object Qprotected_field;
  166: 
  167: Lisp_Object QSFundamental;      /* A string "Fundamental" */
  168: 
  169: Lisp_Object Qkill_buffer_hook;
  170: 
  171: Lisp_Object Qget_file_buffer;
  172: 
  173: Lisp_Object Qoverlayp;
  174: 
  175: Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string;
  176: 
  177: Lisp_Object Qmodification_hooks;
  178: Lisp_Object Qinsert_in_front_hooks;
  179: Lisp_Object Qinsert_behind_hooks;
  180: 
  181: static void alloc_buffer_text P_ ((struct buffer *, size_t));
  182: static void free_buffer_text P_ ((struct buffer *b));
  183: static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *));
  184: static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT));
  185: static Lisp_Object buffer_lisp_local_variables P_ ((struct buffer *));
  186: 
  187: 
  188: /* For debugging; temporary.  See set_buffer_internal.  */
  189: /* Lisp_Object Qlisp_mode, Vcheck_symbol; */
  190: 
  191: void
  192: nsberror (spec)
  193:      Lisp_Object spec;
  194: {
  195:   if (STRINGP (spec))
  196:     error ("No buffer named %s", SDATA (spec));
  197:   error ("Invalid buffer argument");
  198: }
  199: ^L
  200: DEFUN ("buffer-live-p", Fbuffer_live_p, Sbuffer_live_p, 1, 1, 0,
  201:        doc: /* Return non-nil if OBJECT is a buffer which has not been killed.
  202: Value is nil if OBJECT is not a buffer or if it has been killed.  */)
  203:      (object)
  204:      Lisp_Object object;
  205: {
  206:   return ((BUFFERP (object) && ! NILP (XBUFFER (object)->name))
  207:           ? Qt : Qnil);
  208: }
  209: 
  210: DEFUN ("buffer-list", Fbuffer_list, Sbuffer_list, 0, 1, 0,
  211:        doc: /* Return a list of all existing live buffers.
  212: If the optional arg FRAME is a frame, we return the buffer list
  213: in the proper order for that frame: the buffers in FRAME's `buffer-list'
  214: frame parameter come first, followed by the rest of the buffers.  */)
  215:      (frame)
  216:      Lisp_Object frame;
  217: {
  218:   Lisp_Object framelist, general;
  219:   general = Fmapcar (Qcdr, Vbuffer_alist);
  220: 
  221:   if (FRAMEP (frame))
  222:     {
  223:       Lisp_Object tail;
  224: 
  225:       CHECK_FRAME (frame);
  226: 
  227:       framelist = Fcopy_sequence (XFRAME (frame)->buffer_list);
  228: 
  229:       /* Remove from GENERAL any buffer that duplicates one in FRAMELIST.  */
  230:       tail = framelist;
  231:       while (! NILP (tail))
  232:         {
  233:           general = Fdelq (XCAR (tail), general);
  234:           tail = XCDR (tail);
  235:         }
  236:       return nconc2 (framelist, general);
  237:     }
  238: 
  239:   return general;
  240: }
  241: 
  242: /* Like Fassoc, but use Fstring_equal to compare
  243:    (which ignores text properties),
  244:    and don't ever QUIT.  */
  245: 
  246: static Lisp_Object
  247: assoc_ignore_text_properties (key, list)
  248:      register Lisp_Object key;
  249:      Lisp_Object list;
  250: {
  251:   register Lisp_Object tail;
  252:   for (tail = list; CONSP (tail); tail = XCDR (tail))
  253:     {
  254:       register Lisp_Object elt, tem;
  255:       elt = XCAR (tail);
  256:       tem = Fstring_equal (Fcar (elt), key);
  257:       if (!NILP (tem))
  258:         return elt;
  259:     }
  260:   return Qnil;
  261: }
  262: 
  263: DEFUN ("get-buffer", Fget_buffer, Sget_buffer, 1, 1, 0,
  264:        doc: /* Return the buffer named NAME (a string).
  265: If there is no live buffer named NAME, return nil.
  266: NAME may also be a buffer; if so, the value is that buffer.  */)
  267:      (name)
  268:      register Lisp_Object name;
  269: {
  270:   if (BUFFERP (name))
  271:     return name;
  272:   CHECK_STRING (name);
  273: 
  274:   return Fcdr (assoc_ignore_text_properties (name, Vbuffer_alist));
  275: }
  276: 
  277: DEFUN ("get-file-buffer", Fget_file_buffer, Sget_file_buffer, 1, 1, 0,
  278:        doc: /* Return the buffer visiting file FILENAME (a string).
  279: The buffer's `buffer-file-name' must match exactly the expansion of FILENAME.
  280: If there is no such live buffer, return nil.
  281: See also `find-buffer-visiting'.  */)
  282:      (filename)
  283:      register Lisp_Object filename;
  284: {
  285:   register Lisp_Object tail, buf, tem;
  286:   Lisp_Object handler;
  287: 
  288:   CHECK_STRING (filename);
  289:   filename = Fexpand_file_name (filename, Qnil);
  290: 
  291:   /* If the file name has special constructs in it,
  292:      call the corresponding file handler.  */
  293:   handler = Ffind_file_name_handler (filename, Qget_file_buffer);
  294:   if (!NILP (handler))
  295:     return call2 (handler, Qget_file_buffer, filename);
  296: 
  297:   for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
  298:     {
  299:       buf = Fcdr (XCAR (tail));
  300:       if (!BUFFERP (buf)) continue;
  301:       if (!STRINGP (XBUFFER (buf)->filename)) continue;
  302:       tem = Fstring_equal (XBUFFER (buf)->filename, filename);
  303:       if (!NILP (tem))
  304:         return buf;
  305:     }
  306:   return Qnil;
  307: }
  308: 
  309: Lisp_Object
  310: get_truename_buffer (filename)
  311:      register Lisp_Object filename;
  312: {
  313:   register Lisp_Object tail, buf, tem;
  314: 
  315:   for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
  316:     {
  317:       buf = Fcdr (XCAR (tail));
  318:       if (!BUFFERP (buf)) continue;
  319:       if (!STRINGP (XBUFFER (buf)->file_truename)) continue;
  320:       tem = Fstring_equal (XBUFFER (buf)->file_truename, filename);
  321:       if (!NILP (tem))
  322:         return buf;
  323:     }
  324:   return Qnil;
  325: }
  326: 
  327: /* Incremented for each buffer created, to assign the buffer number. */
  328: int buffer_count;
  329: 
  330: DEFUN ("get-buffer-create", Fget_buffer_create, Sget_buffer_create, 1, 1, 0,
  331:        doc: /* Return the buffer named NAME, or create such a buffer and return it.
  332: A new buffer is created if there is no live buffer named NAME.
  333: If NAME starts with a space, the new buffer does not keep undo information.
  334: If NAME is a buffer instead of a string, then it is the value returned.
  335: The value is never nil.  */)
  336:      (name)
  337:      register Lisp_Object name;
  338: {
  339:   register Lisp_Object buf;
  340:   register struct buffer *b;
  341: 
  342:   buf = Fget_buffer (name);
  343:   if (!NILP (buf))
  344:     return buf;
  345: 
  346:   if (SCHARS (name) == 0)
  347:     error ("Empty string for buffer name is not allowed");
  348: 
  349:   b = (struct buffer *) allocate_buffer ();
  350: 
  351:   b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
  352: 
  353:   /* An ordinary buffer uses its own struct buffer_text.  */
  354:   b->text = &b->own_text;
  355:   b->base_buffer = 0;
  356: 
  357:   BUF_GAP_SIZE (b) = 20;
  358:   BLOCK_INPUT;
  359:   /* We allocate extra 1-byte at the tail and keep it always '\0' for
  360:      anchoring a search.  */
  361:   alloc_buffer_text (b, BUF_GAP_SIZE (b) + 1);
  362:   UNBLOCK_INPUT;
  363:   if (! BUF_BEG_ADDR (b))
  364:     buffer_memory_full ();
  365: 
  366:   BUF_PT (b) = BEG;
  367:   BUF_GPT (b) = BEG;
  368:   BUF_BEGV (b) = BEG;
  369:   BUF_ZV (b) = BEG;
  370:   BUF_Z (b) = BEG;
  371:   BUF_PT_BYTE (b) = BEG_BYTE;
  372:   BUF_GPT_BYTE (b) = BEG_BYTE;
  373:   BUF_BEGV_BYTE (b) = BEG_BYTE;
  374:   BUF_ZV_BYTE (b) = BEG_BYTE;
  375:   BUF_Z_BYTE (b) = BEG_BYTE;
  376:   BUF_MODIFF (b) = 1;
  377:   BUF_CHARS_MODIFF (b) = 1;
  378:   BUF_OVERLAY_MODIFF (b) = 1;
  379:   BUF_SAVE_MODIFF (b) = 1;
  380:   BUF_INTERVALS (b) = 0;
  381:   BUF_UNCHANGED_MODIFIED (b) = 1;
  382:   BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
  383:   BUF_END_UNCHANGED (b) = 0;
  384:   BUF_BEG_UNCHANGED (b) = 0;
  385:   *(BUF_GPT_ADDR (b)) = *(BUF_Z_ADDR (b)) = 0; /* Put an anchor '\0'.  */
  386: 
  387:   b->newline_cache = 0;
  388:   b->width_run_cache = 0;
  389:   b->width_table = Qnil;
  390:   b->prevent_redisplay_optimizations_p = 1;
  391: 
  392:   /* Put this on the chain of all buffers including killed ones.  */
  393:   b->next = all_buffers;
  394:   all_buffers = b;
  395: 
  396:   /* An ordinary buffer normally doesn't need markers
  397:      to handle BEGV and ZV.  */
  398:   b->pt_marker = Qnil;
  399:   b->begv_marker = Qnil;
  400:   b->zv_marker = Qnil;
  401: 
  402:   name = Fcopy_sequence (name);
  403:   STRING_SET_INTERVALS (name, NULL_INTERVAL);
  404:   b->name = name;
  405: 
  406:   if (SREF (name, 0) != ' ')
  407:     b->undo_list = Qnil;
  408:   else
  409:     b->undo_list = Qt;
  410: 
  411:   reset_buffer (b);
  412:   reset_buffer_local_variables (b, 1);
  413: 
  414:   b->mark = Fmake_marker ();
  415:   BUF_MARKERS (b) = NULL;
  416:   b->name = name;
  417: 
  418:   /* Put this in the alist of all live buffers.  */
  419:   XSETBUFFER (buf, b);
  420:   Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
  421: 
  422:   /* An error in calling the function here (should someone redefine it)
  423:      can lead to infinite regress until you run out of stack.  rms
  424:      says that's not worth protecting against.  */
  425:   if (!NILP (Ffboundp (Qucs_set_table_for_input)))
  426:     /* buf is on buffer-alist, so no gcpro.  */
  427:     call1 (Qucs_set_table_for_input, buf);
  428: 
  429:   return buf;
  430: }
  431: 
  432: 
  433: /* Return a list of overlays which is a copy of the overlay list
  434:    LIST, but for buffer B.  */
  435: 
  436: static struct Lisp_Overlay *
  437: copy_overlays (b, list)
  438:      struct buffer *b;
  439:      struct Lisp_Overlay *list;
  440: {
  441:   Lisp_Object buffer;
  442:   struct Lisp_Overlay *result = NULL, *tail = NULL;
  443: 
  444:   XSETBUFFER (buffer, b);
  445: 
  446:   for (; list; list = list->next)
  447:     {
  448:       Lisp_Object overlay, start, end, old_overlay;
  449:       EMACS_INT charpos;
  450: 
  451:       XSETMISC (old_overlay, list);
  452:       charpos = marker_position (OVERLAY_START (old_overlay));
  453:       start = Fmake_marker ();
  454:       Fset_marker (start, make_number (charpos), buffer);
  455:       XMARKER (start)->insertion_type
  456:         = XMARKER (OVERLAY_START (old_overlay))->insertion_type;
  457: 
  458:       charpos = marker_position (OVERLAY_END (old_overlay));
  459:       end = Fmake_marker ();
  460:       Fset_marker (end, make_number (charpos), buffer);
  461:       XMARKER (end)->insertion_type
  462:         = XMARKER (OVERLAY_END (old_overlay))->insertion_type;
  463: 
  464:       overlay = allocate_misc ();
  465:       XMISCTYPE (overlay) = Lisp_Misc_Overlay;
  466:       OVERLAY_START (overlay) = start;
  467:       OVERLAY_END (overlay) = end;
  468:       OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));
  469:       XOVERLAY (overlay)->next = NULL;
  470: 
  471:       if (tail)
  472:         tail = tail->next = XOVERLAY (overlay);
  473:       else
  474:         result = tail = XOVERLAY (overlay);
  475:     }
  476: 
  477:   return result;
  478: }
  479: 
  480: 
  481: /* Clone per-buffer values of buffer FROM.
  482: 
  483:    Buffer TO gets the same per-buffer values as FROM, with the
  484:    following exceptions: (1) TO's name is left untouched, (2) markers
  485:    are copied and made to refer to TO, and (3) overlay lists are
  486:    copied.  */
  487: 
  488: static void
  489: clone_per_buffer_values (from, to)
  490:      struct buffer *from, *to;
  491: {
  492:   Lisp_Object to_buffer;
  493:   int offset;
  494: 
  495:   XSETBUFFER (to_buffer, to);
  496: 
  497:   for (offset = PER_BUFFER_VAR_OFFSET (name) + sizeof (Lisp_Object);
  498:        offset < sizeof *to;
  499:        offset += sizeof (Lisp_Object))
  500:     {
  501:       Lisp_Object obj;
  502: 
  503:       obj = PER_BUFFER_VALUE (from, offset);
  504:       if (MARKERP (obj))
  505:         {
  506:           struct Lisp_Marker *m = XMARKER (obj);
  507:           obj = Fmake_marker ();
  508:           XMARKER (obj)->insertion_type = m->insertion_type;
  509:           set_marker_both (obj, to_buffer, m->charpos, m->bytepos);
  510:         }
  511: 
  512:       PER_BUFFER_VALUE (to, offset) = obj;
  513:     }
  514: 
  515:   bcopy (from->local_flags, to->local_flags, sizeof to->local_flags);
  516: 
  517:   to->overlays_before = copy_overlays (to, from->overlays_before);
  518:   to->overlays_after = copy_overlays (to, from->overlays_after);
  519: 
  520:   /* Get (a copy of) the alist of Lisp-level local variables of FROM
  521:      and install that in TO.  */
  522:   to->local_var_alist = buffer_lisp_local_variables (from);
  523: }
  524: 
  525: DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer,
  526:        2, 3,
  527:        "bMake indirect buffer (to buffer): \nBName of indirect buffer: ",
  528:        doc: /* Create and return an indirect buffer for buffer BASE-BUFFER, named NAME.
  529: BASE-BUFFER should be a live buffer, or the name of an existing buffer.
  530: NAME should be a string which is not the name of an existing buffer.
  531: Optional argument CLONE non-nil means preserve BASE-BUFFER's state,
  532: such as major and minor modes, in the indirect buffer.
  533: CLONE nil means the indirect buffer's state is reset to default values.  */)
  534:      (base_buffer, name, clone)
  535:      Lisp_Object base_buffer, name, clone;
  536: {
  537:   Lisp_Object buf, tem;
  538:   struct buffer *b;
  539: 
  540:   CHECK_STRING (name);
  541:   buf = Fget_buffer (name);
  542:   if (!NILP (buf))
  543:     error ("Buffer name `%s' is in use", SDATA (name));
  544: 
  545:   tem = base_buffer;
  546:   base_buffer = Fget_buffer (base_buffer);
  547:   if (NILP (base_buffer))
  548:     error ("No such buffer: `%s'", SDATA (tem));
  549:   if (NILP (XBUFFER (base_buffer)->name))
  550:     error ("Base buffer has been killed");
  551: 
  552:   if (SCHARS (name) == 0)
  553:     error ("Empty string for buffer name is not allowed");
  554: 
  555:   b = (struct buffer *) allocate_buffer ();
  556:   b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
  557: 
  558:   if (XBUFFER (base_buffer)->base_buffer)
  559:     b->base_buffer = XBUFFER (base_buffer)->base_buffer;
  560:   else
  561:     b->base_buffer = XBUFFER (base_buffer);
  562: 
  563:   /* Use the base buffer's text object.  */
  564:   b->text = b->base_buffer->text;
  565: 
  566:   BUF_BEGV (b) = BUF_BEGV (b->base_buffer);
  567:   BUF_ZV (b) = BUF_ZV (b->base_buffer);
  568:   BUF_PT (b) = BUF_PT (b->base_buffer);
  569:   BUF_BEGV_BYTE (b) = BUF_BEGV_BYTE (b->base_buffer);
  570:   BUF_ZV_BYTE (b) = BUF_ZV_BYTE (b->base_buffer);
  571:   BUF_PT_BYTE (b) = BUF_PT_BYTE (b->base_buffer);
  572: 
  573:   b->newline_cache = 0;
  574:   b->width_run_cache = 0;
  575:   b->width_table = Qnil;
  576: 
  577:   /* Put this on the chain of all buffers including killed ones.  */
  578:   b->next = all_buffers;
  579:   all_buffers = b;
  580: 
  581:   name = Fcopy_sequence (name);
  582:   STRING_SET_INTERVALS (name, NULL_INTERVAL);
  583:   b->name = name;
  584: 
  585:   reset_buffer (b);
  586:   reset_buffer_local_variables (b, 1);
  587: 
  588:   /* Put this in the alist of all live buffers.  */
  589:   XSETBUFFER (buf, b);
  590:   Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
  591: 
  592:   b->mark = Fmake_marker ();
  593:   b->name = name;
  594: 
  595:   /* The multibyte status belongs to the base buffer.  */
  596:   b->enable_multibyte_characters = b->base_buffer->enable_multibyte_characters;
  597: 
  598: