/[emacs]/emacs/src/buffer.c
ViewVC logotype

Diff of /emacs/src/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.388 by walters, Sat Jun 8 20:25:31 2002 UTC revision 1.388.2.1 by miles, Fri Apr 4 06:20:56 2003 UTC
# Line 150  Lisp_Object Vinhibit_read_only; Line 150  Lisp_Object Vinhibit_read_only;
150  /* List of functions to call that can query about killing a buffer.  /* List of functions to call that can query about killing a buffer.
151     If any of these functions returns nil, we don't kill it.  */     If any of these functions returns nil, we don't kill it.  */
152  Lisp_Object Vkill_buffer_query_functions;  Lisp_Object Vkill_buffer_query_functions;
153    Lisp_Object Qkill_buffer_query_functions;
154    
155  /* List of functions to call before changing an unmodified buffer.  */  /* List of functions to call before changing an unmodified buffer.  */
156  Lisp_Object Vfirst_change_hook;  Lisp_Object Vfirst_change_hook;
# Line 157  Lisp_Object Vfirst_change_hook; Line 158  Lisp_Object Vfirst_change_hook;
158  Lisp_Object Qfirst_change_hook;  Lisp_Object Qfirst_change_hook;
159  Lisp_Object Qbefore_change_functions;  Lisp_Object Qbefore_change_functions;
160  Lisp_Object Qafter_change_functions;  Lisp_Object Qafter_change_functions;
161    Lisp_Object Qucs_set_table_for_input;
162    
163  /* If nonzero, all modification hooks are suppressed.  */  /* If nonzero, all modification hooks are suppressed.  */
164  int inhibit_modification_hooks;  int inhibit_modification_hooks;
# Line 193  nsberror (spec) Line 195  nsberror (spec)
195       Lisp_Object spec;       Lisp_Object spec;
196  {  {
197    if (STRINGP (spec))    if (STRINGP (spec))
198      error ("No buffer named %s", XSTRING (spec)->data);      error ("No buffer named %s", SDATA (spec));
199    error ("Invalid buffer argument");    error ("Invalid buffer argument");
200  }  }
201    
# Line 209  Value is nil if OBJECT is not a buffer o Line 211  Value is nil if OBJECT is not a buffer o
211    
212  DEFUN ("buffer-list", Fbuffer_list, Sbuffer_list, 0, 1, 0,  DEFUN ("buffer-list", Fbuffer_list, Sbuffer_list, 0, 1, 0,
213         doc: /* Return a list of all existing live buffers.         doc: /* Return a list of all existing live buffers.
214  If the optional arg FRAME is a frame, we return that frame's buffer list.  */)  If the optional arg FRAME is a frame, we return the buffer list
215    in the proper order for that frame: the buffers in FRAME's `buffer-list'
216    frame parameter come first, followed by the rest of the buffers.  */)
217       (frame)       (frame)
218       Lisp_Object frame;       Lisp_Object frame;
219  {  {
# Line 247  assoc_ignore_text_properties (key, list) Line 251  assoc_ignore_text_properties (key, list)
251       Lisp_Object list;       Lisp_Object list;
252  {  {
253    register Lisp_Object tail;    register Lisp_Object tail;
254    for (tail = list; !NILP (tail); tail = Fcdr (tail))    for (tail = list; CONSP (tail); tail = XCDR (tail))
255      {      {
256        register Lisp_Object elt, tem;        register Lisp_Object elt, tem;
257        elt = Fcar (tail);        elt = XCAR (tail);
258        tem = Fstring_equal (Fcar (elt), key);        tem = Fstring_equal (Fcar (elt), key);
259        if (!NILP (tem))        if (!NILP (tem))
260          return elt;          return elt;
# Line 341  The value is never nil.  */) Line 345  The value is never nil.  */)
345    if (!NILP (buf))    if (!NILP (buf))
346      return buf;      return buf;
347    
348    if (XSTRING (name)->size == 0)    if (SCHARS (name) == 0)
349      error ("Empty string for buffer name is not allowed");      error ("Empty string for buffer name is not allowed");
350    
351    b = (struct buffer *) allocate_buffer ();    b = (struct buffer *) allocate_buffer ();
# Line 361  The value is never nil.  */) Line 365  The value is never nil.  */)
365    if (! BUF_BEG_ADDR (b))    if (! BUF_BEG_ADDR (b))
366      buffer_memory_full ();      buffer_memory_full ();
367    
368    BUF_PT (b) = 1;    BUF_PT (b) = BEG;
369    BUF_GPT (b) = 1;    BUF_GPT (b) = BEG;
370    BUF_BEGV (b) = 1;    BUF_BEGV (b) = BEG;
371    BUF_ZV (b) = 1;    BUF_ZV (b) = BEG;
372    BUF_Z (b) = 1;    BUF_Z (b) = BEG;
373    BUF_PT_BYTE (b) = 1;    BUF_PT_BYTE (b) = BEG_BYTE;
374    BUF_GPT_BYTE (b) = 1;    BUF_GPT_BYTE (b) = BEG_BYTE;
375    BUF_BEGV_BYTE (b) = 1;    BUF_BEGV_BYTE (b) = BEG_BYTE;
376    BUF_ZV_BYTE (b) = 1;    BUF_ZV_BYTE (b) = BEG_BYTE;
377    BUF_Z_BYTE (b) = 1;    BUF_Z_BYTE (b) = BEG_BYTE;
378    BUF_MODIFF (b) = 1;    BUF_MODIFF (b) = 1;
379    BUF_OVERLAY_MODIFF (b) = 1;    BUF_OVERLAY_MODIFF (b) = 1;
380    BUF_SAVE_MODIFF (b) = 1;    BUF_SAVE_MODIFF (b) = 1;
# Line 397  The value is never nil.  */) Line 401  The value is never nil.  */)
401    b->zv_marker = Qnil;    b->zv_marker = Qnil;
402    
403    name = Fcopy_sequence (name);    name = Fcopy_sequence (name);
404    XSTRING (name)->intervals = NULL_INTERVAL;    STRING_SET_INTERVALS (name, NULL_INTERVAL);
405    b->name = name;    b->name = name;
406    
407    if (XSTRING (name)->data[0] != ' ')    if (SREF (name, 0) != ' ')
408      b->undo_list = Qnil;      b->undo_list = Qnil;
409    else    else
410      b->undo_list = Qt;      b->undo_list = Qt;
# Line 408  The value is never nil.  */) Line 412  The value is never nil.  */)
412    reset_buffer (b);    reset_buffer (b);
413    reset_buffer_local_variables (b, 1);    reset_buffer_local_variables (b, 1);
414    
415      b->mark = Fmake_marker ();
416      BUF_MARKERS (b) = Qnil;
417      b->name = name;
418    
419    /* Put this in the alist of all live buffers.  */    /* Put this in the alist of all live buffers.  */
420    XSETBUFFER (buf, b);    XSETBUFFER (buf, b);
421    Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));    Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
422    
423    b->mark = Fmake_marker ();    /* Fixme:  Protect against errors, which would trigger infinite
424    BUF_MARKERS (b) = Qnil;       regress?  */
425    b->name = name;    if (!NILP (Ffboundp (Qucs_set_table_for_input)))
426        /* buff is on buffer-alist, so no gcpro */
427        call1 (Qucs_set_table_for_input, buf);
428    
429    return buf;    return buf;
430  }  }
431    
# Line 454  copy_overlays (b, list) Line 465  copy_overlays (b, list)
465        OVERLAY_START (overlay) = start;        OVERLAY_START (overlay) = start;
466        OVERLAY_END (overlay) = end;        OVERLAY_END (overlay) = end;
467        OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));        OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));
468          
469        result = Fcons (overlay, result);        result = Fcons (overlay, result);
470      }      }
471    
472    return Fnreverse (result);    return Fnreverse (result);
473  }  }
474        
475    
476  /* Clone per-buffer values of buffer FROM.  /* Clone per-buffer values of buffer FROM.
477    
# Line 477  clone_per_buffer_values (from, to) Line 488  clone_per_buffer_values (from, to)
488    int offset;    int offset;
489    
490    XSETBUFFER (to_buffer, to);    XSETBUFFER (to_buffer, to);
491      
492    for (offset = PER_BUFFER_VAR_OFFSET (name) + sizeof (Lisp_Object);    for (offset = PER_BUFFER_VAR_OFFSET (name) + sizeof (Lisp_Object);
493         offset < sizeof *to;         offset < sizeof *to;
494         offset += sizeof (Lisp_Object))         offset += sizeof (Lisp_Object))
# Line 497  clone_per_buffer_values (from, to) Line 508  clone_per_buffer_values (from, to)
508      }      }
509    
510    bcopy (from->local_flags, to->local_flags, sizeof to->local_flags);    bcopy (from->local_flags, to->local_flags, sizeof to->local_flags);
511      
512    to->overlays_before = copy_overlays (to, from->overlays_before);    to->overlays_before = copy_overlays (to, from->overlays_before);
513    to->overlays_after = copy_overlays (to, from->overlays_after);    to->overlays_after = copy_overlays (to, from->overlays_after);
514  }  }
# Line 520  CLONE nil means the indirect buffer's st Line 531  CLONE nil means the indirect buffer's st
531    
532    buf = Fget_buffer (name);    buf = Fget_buffer (name);
533    if (!NILP (buf))    if (!NILP (buf))
534      error ("Buffer name `%s' is in use", XSTRING (name)->data);      error ("Buffer name `%s' is in use", SDATA (name));
535    
536    base_buffer = Fget_buffer (base_buffer);    base_buffer = Fget_buffer (base_buffer);
537    if (NILP (base_buffer))    if (NILP (base_buffer))
538      error ("No such buffer: `%s'", XSTRING (name)->data);      error ("No such buffer: `%s'", SDATA (name));
539    
540    if (XSTRING (name)->size == 0)    if (SCHARS (name) == 0)
541      error ("Empty string for buffer name is not allowed");      error ("Empty string for buffer name is not allowed");
542    
543    b = (struct buffer *) allocate_buffer ();    b = (struct buffer *) allocate_buffer ();
# Line 556  CLONE nil means the indirect buffer's st Line 567  CLONE nil means the indirect buffer's st
567    all_buffers = b;    all_buffers = b;
568    
569    name = Fcopy_sequence (name);    name = Fcopy_sequence (name);
570    XSTRING (name)->intervals = NULL_INTERVAL;    STRING_SET_INTERVALS (name, NULL_INTERVAL);
571    b->name = name;    b->name = name;
572    
573    reset_buffer (b);    reset_buffer (b);
# Line 693  reset_buffer_local_variables (b, permane Line 704  reset_buffer_local_variables (b, permane
704    b->buffer_file_type = Qnil;    b->buffer_file_type = Qnil;
705  #endif  #endif
706    
 #if 0  
   b->sort_table = XSTRING (Vascii_sort_table);  
   b->folding_sort_table = XSTRING (Vascii_folding_sort_table);  
 #endif /* 0 */  
   
707    /* Reset all (or most) per-buffer variables to their defaults.  */    /* Reset all (or most) per-buffer variables to their defaults.  */
708    b->local_var_alist = Qnil;    b->local_var_alist = Qnil;
709    for (i = 0; i < last_per_buffer_idx; ++i)    for (i = 0; i < last_per_buffer_idx; ++i)
# Line 811  If BUFFER is not indirect, return nil. Line 817  If BUFFER is not indirect, return nil.
817  }  }
818    
819  DEFUN ("buffer-local-value", Fbuffer_local_value,  DEFUN ("buffer-local-value", Fbuffer_local_value,
820         Sbuffer_local_value, 2, 2, 0,         Sbuffer_local_value, 2, 2, 0,
821         doc: /* Return the value of VARIABLE in BUFFER.         doc: /* Return the value of VARIABLE in BUFFER.
822  If VARIABLE does not have a buffer-local binding in BUFFER, the value  If VARIABLE does not have a buffer-local binding in BUFFER, the value
823  is the default binding of variable. */)  is the default binding of variable. */)
# Line 828  is the default binding of variable. */) Line 834  is the default binding of variable. */)
834    
835    /* Look in local_var_list */    /* Look in local_var_list */
836    result = Fassoc (symbol, buf->local_var_alist);    result = Fassoc (symbol, buf->local_var_alist);
837    if (NILP (result))    if (NILP (result))
838      {      {
839        int offset, idx;        int offset, idx;
840        int found = 0;        int found = 0;
# Line 841  is the default binding of variable. */) Line 847  is the default binding of variable. */)
847          {          {
848            idx = PER_BUFFER_IDX (offset);            idx = PER_BUFFER_IDX (offset);
849            if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))            if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
850                && SYMBOLP (PER_BUFFER_SYMBOL (offset))                && SYMBOLP (PER_BUFFER_SYMBOL (offset))
851                && EQ (PER_BUFFER_SYMBOL (offset), symbol))                && EQ (PER_BUFFER_SYMBOL (offset), symbol))
852              {              {
853                result = PER_BUFFER_VALUE (buf, offset);                result = PER_BUFFER_VALUE (buf, offset);
854                found = 1;                found = 1;
# Line 854  is the default binding of variable. */) Line 860  is the default binding of variable. */)
860          result = Fdefault_value (symbol);          result = Fdefault_value (symbol);
861      }      }
862    else    else
863      result = XCDR (result);      {
864          Lisp_Object valcontents;
865          Lisp_Object current_alist_element;
866    
867          /* What binding is loaded right now?  */
868          valcontents = SYMBOL_VALUE (symbol);
869          current_alist_element
870            = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr);
871    
872          /* The value of the currently loaded binding is not
873             stored in it, but rather in the realvalue slot.
874             Store that value into the binding it belongs to
875             in case that is the one we are about to use.  */
876    
877          Fsetcdr (current_alist_element,
878                   do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue));
879    
880          /* Now get the (perhaps updated) value out of the binding.  */
881          result = XCDR (result);
882        }
883    
884    if (EQ (result, Qunbound))    if (EQ (result, Qunbound))
885      return Fsignal (Qvoid_variable, Fcons (symbol, Qnil));      return Fsignal (Qvoid_variable, Fcons (symbol, Qnil));
# Line 981  A non-nil FLAG means mark the buffer mod Line 1006  A non-nil FLAG means mark the buffer mod
1006  #endif /* CLASH_DETECTION */  #endif /* CLASH_DETECTION */
1007    
1008    SAVE_MODIFF = NILP (flag) ? MODIFF : 0;    SAVE_MODIFF = NILP (flag) ? MODIFF : 0;
1009      
1010    /* Set update_mode_lines only if buffer is displayed in some window.    /* Set update_mode_lines only if buffer is displayed in some window.
1011       Packages like jit-lock or lazy-lock preserve a buffer's modified       Packages like jit-lock or lazy-lock preserve a buffer's modified
1012       state by recording/restoring the state around blocks of code.       state by recording/restoring the state around blocks of code.
# Line 1000  A non-nil FLAG means mark the buffer mod Line 1025  A non-nil FLAG means mark the buffer mod
1025        ++update_mode_lines;        ++update_mode_lines;
1026        current_buffer->prevent_redisplay_optimizations_p = 1;        current_buffer->prevent_redisplay_optimizations_p = 1;
1027      }      }
1028      
1029    return flag;    return flag;
1030  }  }
1031    
# Line 1014  state of the current buffer.  Use with c Line 1039  state of the current buffer.  Use with c
1039  {  {
1040  #ifdef CLASH_DETECTION  #ifdef CLASH_DETECTION
1041    Lisp_Object fn;    Lisp_Object fn;
1042      
1043    /* If buffer becoming modified, lock the file.    /* If buffer becoming modified, lock the file.
1044       If buffer becoming unmodified, unlock the file.  */       If buffer becoming unmodified, unlock the file.  */
1045    
# Line 1029  state of the current buffer.  Use with c Line 1054  state of the current buffer.  Use with c
1054          unlock_file (fn);          unlock_file (fn);
1055      }      }
1056  #endif /* CLASH_DETECTION */  #endif /* CLASH_DETECTION */
1057      
1058    SAVE_MODIFF = NILP (flag) ? MODIFF : 0;    SAVE_MODIFF = NILP (flag) ? MODIFF : 0;
1059    return flag;    return flag;
1060  }  }
# Line 1072  This does not change the name of the vis Line 1097  This does not change the name of the vis
1097    
1098    CHECK_STRING (newname);    CHECK_STRING (newname);
1099    
1100    if (XSTRING (newname)->size == 0)    if (SCHARS (newname) == 0)
1101      error ("Empty string is invalid as a buffer name");      error ("Empty string is invalid as a buffer name");
1102    
1103    tem = Fget_buffer (newname);    tem = Fget_buffer (newname);
# Line 1087  This does not change the name of the vis Line 1112  This does not change the name of the vis
1112        if (!NILP (unique))        if (!NILP (unique))
1113          newname = Fgenerate_new_buffer_name (newname, current_buffer->name);          newname = Fgenerate_new_buffer_name (newname, current_buffer->name);
1114        else        else
1115          error ("Buffer name `%s' is in use", XSTRING (newname)->data);          error ("Buffer name `%s' is in use", SDATA (newname));
1116      }      }
1117    
1118    current_buffer->name = newname;    current_buffer->name = newname;
# Line 1128  If BUFFER is omitted or nil, some intere Line 1153  If BUFFER is omitted or nil, some intere
1153    
1154    /* Consider buffers that have been seen in the selected frame    /* Consider buffers that have been seen in the selected frame
1155       before other buffers.  */       before other buffers.  */
1156        
1157    tem = frame_buffer_list (frame);    tem = frame_buffer_list (frame);
1158    add_ons = Qnil;    add_ons = Qnil;
1159    while (CONSP (tem))    while (CONSP (tem))
# Line 1139  If BUFFER is omitted or nil, some intere Line 1164  If BUFFER is omitted or nil, some intere
1164      }      }
1165    tail = nconc2 (Fnreverse (add_ons), tail);    tail = nconc2 (Fnreverse (add_ons), tail);
1166    
1167    for (; !NILP (tail); tail = Fcdr (tail))    for (; CONSP (tail); tail = XCDR (tail))
1168      {      {
1169        buf = Fcdr (Fcar (tail));        buf = Fcdr (XCAR (tail));
1170        if (EQ (buf, buffer))        if (EQ (buf, buffer))
1171          continue;          continue;
1172        if (XSTRING (XBUFFER (buf)->name)->data[0] == ' ')        if (SREF (XBUFFER (buf)->name, 0) == ' ')
1173          continue;          continue;
1174        /* If the selected frame has a buffer_predicate,        /* If the selected frame has a buffer_predicate,
1175           disregard buffers that don't fit the predicate.  */           disregard buffers that don't fit the predicate.  */
# Line 1269  with SIGHUP.  */) Line 1294  with SIGHUP.  */)
1294        && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))        && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
1295      {      {
1296        GCPRO1 (buf);        GCPRO1 (buf);
1297        tem = do_yes_or_no_p (format1 ("Buffer %s modified; kill anyway? ",        tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
1298                                       XSTRING (b->name)->data));                                       b->name, make_number (0)));
1299        UNGCPRO;        UNGCPRO;
1300        if (NILP (tem))        if (NILP (tem))
1301          return Qnil;          return Qnil;
# Line 1278  with SIGHUP.  */) Line 1303  with SIGHUP.  */)
1303    
1304    /* Run hooks with the buffer to be killed the current buffer.  */    /* Run hooks with the buffer to be killed the current buffer.  */
1305    {    {
1306      int count = specpdl_ptr - specpdl;      int count = SPECPDL_INDEX ();
1307      Lisp_Object list;      Lisp_Object list;
1308        Lisp_Object arglist[1];
1309    
1310      record_unwind_protect (save_excursion_restore, save_excursion_save ());      record_unwind_protect (save_excursion_restore, save_excursion_save ());
1311      set_buffer_internal (b);      set_buffer_internal (b);
1312    
1313      /* First run the query functions; if any query is answered no,      /* First run the query functions; if any query is answered no,
1314         don't kill the buffer.  */         don't kill the buffer.  */
1315      for (list = Vkill_buffer_query_functions; !NILP (list); list = Fcdr (list))      arglist[0] = Qkill_buffer_query_functions;
1316        {      if (NILP (Frun_hook_with_args_until_failure (1, arglist)))
1317          tem = call0 (Fcar (list));        return unbind_to (count, Qnil);
         if (NILP (tem))  
           return unbind_to (count, Qnil);  
       }  
1318    
1319      /* Then run the hooks.  */      /* Then run the hooks.  */
1320      Frun_hooks (1, &Qkill_buffer_hook);      Frun_hooks (1, &Qkill_buffer_hook);
# Line 1330  with SIGHUP.  */) Line 1353  with SIGHUP.  */)
1353    
1354        UNGCPRO;        UNGCPRO;
1355      }      }
1356      
1357    /* Make this buffer not be current.    /* Make this buffer not be current.
1358       In the process, notice if this is the sole visible buffer       In the process, notice if this is the sole visible buffer
1359       and give up if so.  */       and give up if so.  */
# Line 1471  record_buffer (buf) Line 1494  record_buffer (buf)
1494      Vbuffer_alist = XCDR (Vbuffer_alist);      Vbuffer_alist = XCDR (Vbuffer_alist);
1495    else    else
1496      XSETCDR (prev, XCDR (XCDR (prev)));      XSETCDR (prev, XCDR (XCDR (prev)));
1497            
1498    XSETCDR (link, Vbuffer_alist);    XSETCDR (link, Vbuffer_alist);
1499    Vbuffer_alist = link;    Vbuffer_alist = link;
1500    
# Line 1495  record_buffer (buf) Line 1518  record_buffer (buf)
1518                                 XCDR (frame_buffer_list (frame)));                                 XCDR (frame_buffer_list (frame)));
1519        else        else
1520          XSETCDR (prev, XCDR (XCDR (prev)));          XSETCDR (prev, XCDR (XCDR (prev)));
1521            
1522        XSETCDR (link, frame_buffer_list (frame));        XSETCDR (link, frame_buffer_list (frame));
1523        set_frame_buffer_list (frame, link);        set_frame_buffer_list (frame, link);
1524      }      }
# Line 1516  the current buffer's major mode.  */) Line 1539  the current buffer's major mode.  */)
1539    Lisp_Object function;    Lisp_Object function;
1540    
1541    if (STRINGP (XBUFFER (buffer)->name)    if (STRINGP (XBUFFER (buffer)->name)
1542        && strcmp (XSTRING (XBUFFER (buffer)->name)->data, "*scratch*") == 0)        && strcmp (SDATA (XBUFFER (buffer)->name), "*scratch*") == 0)
1543      function = find_symbol_value (intern ("initial-major-mode"));      function = find_symbol_value (intern ("initial-major-mode"));
1544    else    else
1545      {      {
# Line 1525  the current buffer's major mode.  */) Line 1548  the current buffer's major mode.  */)
1548            && NILP (Fget (current_buffer->major_mode, Qmode_class)))            && NILP (Fget (current_buffer->major_mode, Qmode_class)))
1549          function = current_buffer->major_mode;          function = current_buffer->major_mode;
1550      }      }
1551      
1552    if (NILP (function) || EQ (function, Qfundamental_mode))    if (NILP (function) || EQ (function, Qfundamental_mode))
1553      return Qnil;      return Qnil;
1554    
1555    count = specpdl_ptr - specpdl;    count = SPECPDL_INDEX ();
1556    
1557    /* To select a nonfundamental mode,    /* To select a nonfundamental mode,
1558       select the buffer temporarily and then call the mode function. */       select the buffer temporarily and then call the mode function. */
# Line 1685  set_buffer_internal_1 (b) Line 1708  set_buffer_internal_1 (b)
1708    if (b->text->beg == NULL)    if (b->text->beg == NULL)
1709      enlarge_buffer_text (b, 0);      enlarge_buffer_text (b, 0);
1710  #endif /* USE_MMAP_FOR_BUFFERS */  #endif /* USE_MMAP_FOR_BUFFERS */
1711      
1712    if (current_buffer == b)    if (current_buffer == b)
1713      return;      return;
1714    
# Line 1913  selected window if it is displayed there Line 1936  selected window if it is displayed there
1936    else    else
1937      {      {
1938        Lisp_Object buf1;        Lisp_Object buf1;
1939          
1940        buf1 = Fget_buffer (buffer);        buf1 = Fget_buffer (buffer);
1941        if (NILP (buf1))        if (NILP (buf1))
1942          nsberror (buffer);          nsberror (buffer);
# Line 1932  selected window if it is displayed there Line 1955  selected window if it is displayed there
1955        XSETCDR (link, Qnil);        XSETCDR (link, Qnil);
1956        Vbuffer_alist = nconc2 (Vbuffer_alist, link);        Vbuffer_alist = nconc2 (Vbuffer_alist, link);
1957    
1958        frames_bury_buffer (buffer);        /* Removing BUFFER from frame-specific lists
1959             has the effect of putting BUFFER at the end
1960             of the combined list in each frame.  */
1961          frames_discard_buffer (buffer);
1962      }      }
1963    
1964    return Qnil;    return Qnil;
# Line 1985  advance_to_char_boundary (byte_pos) Line 2011  advance_to_char_boundary (byte_pos)
2011    
2012    if (byte_pos == BEG)    if (byte_pos == BEG)
2013      /* Beginning of buffer is always a character boundary.  */      /* Beginning of buffer is always a character boundary.  */
2014      return 1;      return BEG;
2015    
2016    c = FETCH_BYTE (byte_pos);    c = FETCH_BYTE (byte_pos);
2017    if (! CHAR_HEAD_P (c))    if (! CHAR_HEAD_P (c))
# Line 2148  but the contents viewed as characters do Line 2174  but the contents viewed as characters do
2174                p = GAP_END_ADDR;                p = GAP_END_ADDR;
2175                stop = Z;                stop = Z;
2176              }              }
2177                  
2178            if (UNIBYTE_STR_AS_MULTIBYTE_P (p, stop - pos, bytes))            if (UNIBYTE_STR_AS_MULTIBYTE_P (p, stop - pos, bytes))
2179              p += bytes, pos += bytes;              p += bytes, pos += bytes;
2180            else            else
# Line 2261  but the contents viewed as characters do Line 2287  but the contents viewed as characters do
2287    if (!modified_p && !NILP (Fbuffer_modified_p (Qnil)))    if (!modified_p && !NILP (Fbuffer_modified_p (Qnil)))
2288      Fset_buffer_modified_p (Qnil);      Fset_buffer_modified_p (Qnil);
2289    
2290    #ifdef subprocesses
2291      /* Update coding systems of this buffer's process (if any).  */
2292      {
2293        Lisp_Object process;
2294    
2295        process = Fget_buffer_process (Fcurrent_buffer ());
2296        if (PROCESSP (process))
2297          setup_process_coding_systems (process);
2298      }
2299    #endif  /* subprocesses */
2300    
2301    return flag;    return flag;
2302  }  }
2303    
# Line 2301  the normal hook `change-major-mode-hook' Line 2338  the normal hook `change-major-mode-hook'
2338    
2339    /* Any which are supposed to be permanent,    /* Any which are supposed to be permanent,
2340       make local again, with the same values they had.  */       make local again, with the same values they had.  */
2341        
2342    for (alist = oalist; !NILP (alist); alist = XCDR (alist))    for (alist = oalist; !NILP (alist); alist = XCDR (alist))
2343      {      {
2344        sym = XCAR (XCAR (alist));        sym = XCAR (XCAR (alist));
# Line 2363  swap_out_buffer_local_variables (b) Line 2400  swap_out_buffer_local_variables (b)
2400  }  }
2401    
2402  /* Find all the overlays in the current buffer that contain position POS.  /* Find all the overlays in the current buffer that contain position POS.
2403     Return the number found, and store them in a vector in *VEC_PTR.       Return the number found, and store them in a vector in *VEC_PTR.
2404     Store in *LEN_PTR the size allocated for the vector.     Store in *LEN_PTR the size allocated for the vector.
2405     Store in *NEXT_PTR the next position after POS where an overlay starts,     Store in *NEXT_PTR the next position after POS where an overlay starts,
2406       or ZV if there are no more overlays.       or ZV if there are no more overlays.
# Line 2479  overlays_at (pos, extend, vec_ptr, len_p Line 2516  overlays_at (pos, extend, vec_ptr, len_p
2516              {              {
2517                if (extend)                if (extend)
2518                  {                  {
2519                    *len_ptr = len *= 2;                    /* Make it work with an initial len == 0.  */
2520                      len *= 2;
2521                    if (len == 0)                    if (len == 0)
2522                      len = *len_ptr = 4;                      len = 4;
2523                      *len_ptr = len;
2524                    vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));                    vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));
2525                    *vec_ptr = vec;                    *vec_ptr = vec;
2526                  }                  }
# Line 2513  overlays_at (pos, extend, vec_ptr, len_p Line 2552  overlays_at (pos, extend, vec_ptr, len_p
2552  /* Find all the overlays in the current buffer that overlap the range BEG-END  /* Find all the overlays in the current buffer that overlap the range BEG-END
2553     or are empty at BEG.     or are empty at BEG.
2554    
2555     Return the number found, and store them in a vector in *VEC_PTR.       Return the number found, and store them in a vector in *VEC_PTR.
2556     Store in *LEN_PTR the size allocated for the vector.     Store in *LEN_PTR the size allocated for the vector.
2557     Store in *NEXT_PTR the next position after POS where an overlay starts,     Store in *NEXT_PTR the next position after POS where an overlay starts,
2558       or ZV if there are no more overlays.       or ZV if there are no more overlays.
# Line 2529  overlays_at (pos, extend, vec_ptr, len_p Line 2568  overlays_at (pos, extend, vec_ptr, len_p
2568     and we store only as many overlays as will fit.     and we store only as many overlays as will fit.
2569     But we still return the total number of overlays.  */     But we still return the total number of overlays.  */
2570    
2571  int  static int
2572  overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr)  overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr)
2573       int beg, end;       int beg, end;
2574       int extend;       int extend;
# Line 2575  overlays_in (beg, end, extend, vec_ptr, Line 2614  overlays_in (beg, end, extend, vec_ptr,
2614                   Either make it bigger, or don't store any more in it.  */                   Either make it bigger, or don't store any more in it.  */
2615                if (extend)                if (extend)
2616                  {                  {
2617                    *len_ptr = len *= 2;                    /* Make it work with an initial len == 0.  */
2618                      len *= 2;
2619                      if (len == 0)
2620                        len = 4;
2621                      *len_ptr = len;
2622                    vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));                    vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));
2623                    *vec_ptr = vec;                    *vec_ptr = vec;
2624                  }                  }
# Line 2619  overlays_in (beg, end, extend, vec_ptr, Line 2662  overlays_in (beg, end, extend, vec_ptr,
2662              {              {
2663                if (extend)                if (extend)
2664                  {                  {
2665                    *len_ptr = len *= 2;                    /* Make it work with an initial len == 0.  */
2666                      len *= 2;
2667                      if (len == 0)
2668                        len = 4;
2669                      *len_ptr = len;
2670                    vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));                    vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));
2671                    *vec_ptr = vec;                    *vec_ptr = vec;
2672                  }                  }
# Line 2654  mouse_face_overlay_overlaps (overlay) Line 2701  mouse_face_overlay_overlaps (overlay)
2701    int end = OVERLAY_POSITION (OVERLAY_END (overlay));    int end = OVERLAY_POSITION (OVERLAY_END (overlay));
2702    int n, i, size;    int n, i, size;
2703    Lisp_Object *v, tem;    Lisp_Object *v, tem;
2704      
2705    size = 10;    size = 10;
2706    v = (Lisp_Object *) alloca (size * sizeof *v);    v = (Lisp_Object *) alloca (size * sizeof *v);
2707    n = overlays_in (start, end, 0, &v, &size, NULL, NULL);    n = overlays_in (start, end, 0, &v, &size, NULL, NULL);
# Line 2861  record_overlay_string (ssl, str, str2, p Line 2908  record_overlay_string (ssl, str, str2, p
2908    ssl->used++;    ssl->used++;
2909    
2910    if (NILP (current_buffer->enable_multibyte_characters))    if (NILP (current_buffer->enable_multibyte_characters))
2911      nbytes = XSTRING (str)->size;      nbytes = SCHARS (str);
2912    else if (! STRING_MULTIBYTE (str))    else if (! STRING_MULTIBYTE (str))
2913      nbytes = count_size_as_multibyte (XSTRING (str)->data,      nbytes = count_size_as_multibyte (SDATA (str),
2914                                        STRING_BYTES (XSTRING (str)));                                        SBYTES (str));
2915    else    else
2916      nbytes = STRING_BYTES (XSTRING (str));      nbytes = SBYTES (str);
2917    
2918    ssl->bytes += nbytes;    ssl->bytes += nbytes;
2919    
2920    if (STRINGP (str2))    if (STRINGP (str2))
2921      {      {
2922        if (NILP (current_buffer->enable_multibyte_characters))        if (NILP (current_buffer->enable_multibyte_characters))
2923          nbytes = XSTRING (str2)->size;          nbytes = SCHARS (str2);
2924        else if (! STRING_MULTIBYTE (str2))        else if (! STRING_MULTIBYTE (str2))
2925          nbytes = count_size_as_multibyte (XSTRING (str2)->data,          nbytes = count_size_as_multibyte (SDATA (str2),
2926                                            STRING_BYTES (XSTRING (str2)));                                            SBYTES (str2));
2927        else        else
2928          nbytes = STRING_BYTES (XSTRING (str2));          nbytes = SBYTES (str2);
2929    
2930        ssl->bytes += nbytes;        ssl->bytes += nbytes;
2931      }      }
# Line 2990  overlay_strings (pos, w, pstr) Line 3037  overlay_strings (pos, w, pstr)
3037          {          {
3038            int nbytes;            int nbytes;
3039            tem = overlay_tails.buf[i].string;            tem = overlay_tails.buf[i].string;
3040            nbytes = copy_text (XSTRING (tem)->data, p,            nbytes = copy_text (SDATA (tem), p,
3041                                STRING_BYTES (XSTRING (tem)),                                SBYTES (tem),
3042                                STRING_MULTIBYTE (tem), multibyte);                                STRING_MULTIBYTE (tem), multibyte);
3043            p += nbytes;            p += nbytes;
3044          }          }
# Line 2999  overlay_strings (pos, w, pstr) Line 3046  overlay_strings (pos, w, pstr)
3046          {          {
3047            int nbytes;            int nbytes;
3048            tem = overlay_heads.buf[i].string;            tem = overlay_heads.buf[i].string;
3049            nbytes = copy_text (XSTRING (tem)->data, p,            nbytes = copy_text (SDATA (tem), p,
3050                                STRING_BYTES (XSTRING (tem)),                                SBYTES (tem),
3051                                STRING_MULTIBYTE (tem), multibyte);                                STRING_MULTIBYTE (tem), multibyte);
3052            p += nbytes;            p += nbytes;
3053            tem = overlay_heads.buf[i].string2;            tem = overlay_heads.buf[i].string2;
3054            if (STRINGP (tem))            if (STRINGP (tem))
3055              {              {
3056                nbytes = copy_text (XSTRING (tem)->data, p,                nbytes = copy_text (SDATA (tem), p,
3057                                    STRING_BYTES (XSTRING (tem)),                                    SBYTES (tem),
3058                                    STRING_MULTIBYTE (tem), multibyte);                                    STRING_MULTIBYTE (tem), multibyte);
3059                p += nbytes;                p += nbytes;
3060              }              }
# Line 3508  rear delimiter advance when text is inse Line 3555  rear delimiter advance when text is inse
3555    XOVERLAY (overlay)->end = end;    XOVERLAY (overlay)->end = end;
3556    XOVERLAY (overlay)->plist = Qnil;    XOVERLAY (overlay)->plist = Qnil;
3557    
3558    /* Put the new overlay on the wrong list.  */    /* Put the new overlay on the wrong list.  */
3559    end = OVERLAY_END (overlay);    end = OVERLAY_END (overlay);
3560    if (OVERLAY_POSITION (end) < XINT (b->overlay_center))    if (OVERLAY_POSITION (end) < XINT (b->overlay_center))
3561      b->overlays_after = Fcons (overlay, b->overlays_after);      b->overlays_after = Fcons (overlay, b->overlays_after);
# Line 3539  modify_overlay (buf, start, end) Line 3586  modify_overlay (buf, start, end)
3586      }      }
3587    
3588    BUF_COMPUTE_UNCHANGED (buf, start, end);    BUF_COMPUTE_UNCHANGED (buf, start, end);
3589      
3590    /* If this is a buffer not in the selected window,    /* If this is a buffer not in the selected window,
3591       we must do other windows.  */       we must do other windows.  */
3592    if (buf != XBUFFER (XWINDOW (selected_window)->buffer))    if (buf != XBUFFER (XWINDOW (selected_window)->buffer))
# Line 3564  buffer.  */) Line 3611  buffer.  */)
3611  {  {
3612    struct buffer *b, *ob;    struct buffer *b, *ob;
3613    Lisp_Object obuffer;    Lisp_Object obuffer;
3614    int count = specpdl_ptr - specpdl;    int count = SPECPDL_INDEX ();
3615    
3616    CHECK_OVERLAY (overlay);    CHECK_OVERLAY (overlay);
3617    if (NILP (buffer))    if (NILP (buffer))
# Line 3645  buffer.  */) Line 3692  buffer.  */)
3692    Fset_marker (OVERLAY_START (overlay), beg, buffer);    Fset_marker (OVERLAY_START (overlay), beg, buffer);
3693    Fset_marker (OVERLAY_END   (overlay), end, buffer);    Fset_marker (OVERLAY_END   (overlay), end, buffer);
3694    
3695    /* Put the overlay on the wrong list.  */    /* Put the overlay on the wrong list.  */
3696    end = OVERLAY_END (overlay);    end = OVERLAY_END (overlay);
3697    if (OVERLAY_POSITION (end) < XINT (b->overlay_center))    if (OVERLAY_POSITION (end) < XINT (b->overlay_center))
3698      b->overlays_after = Fcons (overlay, b->overlays_after);      b->overlays_after = Fcons (overlay, b->overlays_after);
# Line 3665  DEFUN ("delete-overlay", Fdelete_overlay Line 3712  DEFUN ("delete-overlay", Fdelete_overlay
3712  {  {
3713    Lisp_Object buffer;    Lisp_Object buffer;
3714    struct buffer *b;    struct buffer *b;
3715    int count = specpdl_ptr - specpdl;    int count = SPECPDL_INDEX ();
3716    
3717    CHECK_OVERLAY (overlay);    CHECK_OVERLAY (overlay);
3718    
# Line 3675  DEFUN ("delete-overlay", Fdelete_overlay Line 3722  DEFUN ("delete-overlay", Fdelete_overlay
3722    
3723    b = XBUFFER (buffer);    b = XBUFFER (buffer);
3724    specbind (Qinhibit_quit, Qt);    specbind (Qinhibit_quit, Qt);
3725      
3726    b->overlays_before = Fdelq (overlay, b->overlays_before);    b->overlays_before = Fdelq (overlay, b->overlays_before);
3727    b->overlays_after = Fdelq (overlay, b->overlays_after);    b->overlays_after = Fdelq (overlay, b->overlays_after);
3728    modify_overlay (b,    modify_overlay (b,
# Line 4180  call_overlay_mod_hooks (list, overlay, a Line 4227  call_overlay_mod_hooks (list, overlay, a
4227    if (! after)    if (! after)
4228      add_overlay_mod_hooklist (list, overlay);      add_overlay_mod_hooklist (list, overlay);
4229    
4230    while (!NILP (list))    while (CONSP (list))
4231      {      {
4232        if (NILP (arg3))        if (NILP (arg3))
4233          call4 (Fcar (list), overlay, after ? Qt : Qnil, arg1, arg2);          call4 (XCAR (list), overlay, after ? Qt : Qnil, arg1, arg2);
4234        else        else
4235          call5 (Fcar (list), overlay, after ? Qt : Qnil, arg1, arg2, arg3);          call5 (XCAR (list), overlay, after ? Qt : Qnil, arg1, arg2, arg3);
4236        list = Fcdr (list);        list = XCDR (list);
4237      }      }
4238    UNGCPRO;    UNGCPRO;
4239  }  }
# Line 4239  buffer_slot_type_mismatch (offset) Line 4286  buffer_slot_type_mismatch (offset)
4286  {  {
4287    Lisp_Object sym;    Lisp_Object sym;
4288    char *type_name;    char *type_name;
4289      
4290    switch (XINT (PER_BUFFER_TYPE (offset)))    switch (XINT (PER_BUFFER_TYPE (offset)))
4291      {      {
4292      case Lisp_Int:      case Lisp_Int:
4293        type_name = "integers";        type_name = "integers";
4294        break;        break;
4295          
4296      case Lisp_String:      case Lisp_String:
4297        type_name = "strings";        type_name = "strings";
4298        break;        break;
4299          
4300      case Lisp_Symbol:      case Lisp_Symbol:
4301        type_name = "symbols";        type_name = "symbols";
4302        break;        break;
4303          
4304      default:      default:
4305        abort ();        abort ();
4306      }      }
4307    
4308    sym = PER_BUFFER_SYMBOL (offset);    sym = PER_BUFFER_SYMBOL (offset);
4309    error ("Only %s should be stored in the buffer-local variable %s",    error ("Only %s should be stored in the buffer-local variable %s",
4310           type_name, XSTRING (SYMBOL_NAME (sym))->data);           type_name, SDATA (SYMBOL_NAME (sym)));
4311  }  }
4312    
4313    
# Line 4316  struct mmap_region Line 4363  struct mmap_region
4363  {  {
4364    /* User-specified size.  */    /* User-specified size.  */
4365    size_t nbytes_specified;    size_t nbytes_specified;
4366      
4367    /* Number of bytes mapped */    /* Number of bytes mapped */
4368    size_t nbytes_mapped;    size_t nbytes_mapped;
4369    
# Line 4374  static int mmap_initialized_p; Line 4421  static int mmap_initialized_p;
4421    
4422  #define MEM_ALIGN       sizeof (double)  #define MEM_ALIGN       sizeof (double)
4423    
4424  /* Predicate returning true if part of the address range [START ..  /* Predicate returning true if part of the address range [START .. END]
4425     END[ is currently mapped.  Used to prevent overwriting an existing     is currently mapped.  Used to prevent overwriting an existing
4426     memory mapping.     memory mapping.
4427    
4428     Default is to conservativly assume the address range is occupied by     Default is to conservativly assume the address range is occupied by
# Line 4407  mmap_find (start, end) Line 4454  mmap_find (start, end)
4454  {  {
4455    struct mmap_region *r;    struct mmap_region *r;
4456    char *s = (char *) start, *e = (char *) end;    char *s = (char *) start, *e = (char *) end;
4457      
4458    for (r = mmap_regions; r; r = r->next)    for (r = mmap_regions; r; r = r->next)
4459      {      {
4460        char *rstart = (char *) r;        char *rstart = (char *) r;
# Line 4441  mmap_free_1 (r) Line 4488  mmap_free_1 (r)
4488      r->prev->next = r->next;      r->prev->next = r->next;
4489    else    else
4490      mmap_regions = r->next;      mmap_regions = r->next;
4491      
4492    if (munmap ((POINTER_TYPE *) r, r->nbytes_mapped) == -1)    if (munmap ((POINTER_TYPE *) r, r->nbytes_mapped) == -1)
4493      {      {
4494        fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));        fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
# Line 4479  mmap_enlarge (r, npages) Line 4526  mmap_enlarge (r, npages)
4526    else if (npages > 0)    else if (npages > 0)
4527      {      {
4528        nbytes = npages * mmap_page_size;        nbytes = npages * mmap_page_size;
4529          
4530        /* Try to map additional pages at the end of the region.  We        /* Try to map additional pages at the end of the region.  We
4531           cannot do this if the address range is already occupied by           cannot do this if the address range is already occupied by
4532           something else because mmap deletes any previous mapping.           something else because mmap deletes any previous mapping.
# Line 4487  mmap_enlarge (r, npages) Line 4534  mmap_enlarge (r, npages)
4534        if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes))        if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes))
4535          {          {
4536            POINTER_TYPE *p;            POINTER_TYPE *p;
4537          
4538            p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE,            p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE,
4539                      MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0);                      MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0);
4540            if (p == MAP_FAILED)            if (p == MAP_FAILED)
# Line 4568  mmap_alloc (var, nbytes) Line 4615  mmap_alloc (var, nbytes)
4615    map = ROUND (nbytes + MMAP_REGION_STRUCT_SIZE, mmap_page_size);    map = ROUND (nbytes + MMAP_REGION_STRUCT_SIZE, mmap_page_size);
4616    p = mmap (NULL, map, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,    p = mmap (NULL, map, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
4617              mmap_fd, 0);              mmap_fd, 0);
4618      
4619    if (p == MAP_FAILED)    if (p == MAP_FAILED)
4620      {      {
4621        if (errno != ENOMEM)        if (errno != ENOMEM)
# Line 4578  mmap_alloc (var, nbytes) Line 4625  mmap_alloc (var, nbytes)
4625    else    else
4626      {      {
4627        struct mmap_region *r = (struct mmap_region *) p;        struct mmap_region *r = (struct mmap_region *) p;
4628          
4629        r->nbytes_specified = nbytes;        r->nbytes_specified = nbytes;
4630        r->nbytes_mapped = map;        r->nbytes_mapped = map;
4631        r->var = var;        r->var = var;
# Line 4587  mmap_alloc (var, nbytes) Line 4634  mmap_alloc (var, nbytes)
4634        if (r->next)        if (r->next)
4635          r->next->prev = r;          r->next->prev = r;
4636        mmap_regions = r;        mmap_regions = r;
4637          
4638        p = MMAP_USER_AREA (p);        p = MMAP_USER_AREA (p);
4639      }      }
4640      
4641    return *var = p;    return *var = p;
4642  }  }
4643    
# Line 4606  mmap_realloc (var, nbytes) Line 4653  mmap_realloc (var, nbytes)
4653       size_t nbytes;       size_t nbytes;
4654  {  {
4655    POINTER_TYPE *result;    POINTER_TYPE *result;
4656      
4657    mmap_init ();    mmap_init ();
4658    
4659    if (*var == NULL)    if (*var == NULL)
4660      result = mmap_alloc (var, nbytes);      result = mmap_alloc (var, nbytes);
4661    else if (nbytes == 0)    else if (nbytes == 0)
4662      {      {
4663        mmap_free (var);        mmap_free (var);
4664        result = mmap_alloc (var, nbytes);        result = mmap_alloc (var, nbytes);
# Line 4620  mmap_realloc (var, nbytes) Line 4667  mmap_realloc (var, nbytes)
4667      {      {
4668        struct mmap_region *r = MMAP_REGION (*var);        struct mmap_region *r = MMAP_REGION (*var);
4669        size_t room = r->nbytes_mapped - MMAP_REGION_STRUCT_SIZE;        size_t room = r->nbytes_mapped - MMAP_REGION_STRUCT_SIZE;
4670          
4671        if (room < nbytes)        if (room < nbytes)
4672          {          {
4673            /* Must enlarge.  */            /* Must enlarge.  */
# Line 4652  mmap_realloc (var, nbytes) Line 4699  mmap_realloc (var, nbytes)
4699        else if (room - nbytes >= mmap_page_size)        else if (room - nbytes >= mmap_page_size)
4700          {          {
4701            /* Shrinking by at least a page.  Let's give some            /* Shrinking by at least a page.  Let's give some
4702               memory back to the system.  */               memory back to the system.
4703            mmap_enlarge (r, - (room - nbytes) / mmap_page_size);  
4704                 The extra parens are to make the division happens first,
4705                 on positive values, so we know it will round towards
4706                 zero.  */
4707              mmap_enlarge (r, - ((room - nbytes) / mmap_page_size));
4708            result = *var;            result = *var;
4709            r->nbytes_specified = nbytes;            r->nbytes_specified = nbytes;
4710          }          }
# Line 4677  mmap_free (var) Line 4728  mmap_free (var)
4728       POINTER_TYPE **var;       POINTER_TYPE **var;
4729  {  {
4730    mmap_init ();    mmap_init ();
4731      
4732    if (*var)    if (*var)
4733      {      {
4734        mmap_free_1 (MMAP_REGION (*var));        mmap_free_1 (MMAP_REGION (*var));
# Line 4706  mmap_init () Line 4757  mmap_init ()
4757    if (mmap_initialized_p)    if (mmap_initialized_p)
4758      return;      return;
4759    mmap_initialized_p = 1;    mmap_initialized_p = 1;
4760      
4761  #if MAP_ANON != 0  #if MAP_ANON != 0
4762    mmap_fd = -1;    mmap_fd = -1;
4763  #endif  #endif
4764      
4765    mmap_page_size = getpagesize ();    mmap_page_size = getpagesize ();
4766  }  }
4767    
# Line 4737  alloc_buffer_text (b, nbytes) Line 4788  alloc_buffer_text (b, nbytes)
4788       size_t nbytes;       size_t nbytes;
4789  {  {
4790    POINTER_TYPE *p;    POINTER_TYPE *p;
4791      
4792    BLOCK_INPUT;    BLOCK_INPUT;
4793  #if defined USE_MMAP_FOR_BUFFERS  #if defined USE_MMAP_FOR_BUFFERS
4794    p = mmap_alloc ((POINTER_TYPE **) &b->text->beg, nbytes);    p = mmap_alloc ((POINTER_TYPE **) &b->text->beg, nbytes);
# Line 4746  alloc_buffer_text (b, nbytes) Line 4797  alloc_buffer_text (b, nbytes)
4797  #else  #else
4798    p = xmalloc (nbytes);    p = xmalloc (nbytes);
4799  #endif  #endif
4800      
4801    if (p == NULL)    if (p == NULL)
4802      {      {
4803        UNBLOCK_INPUT;        UNBLOCK_INPUT;
# Line 4776  enlarge_buffer_text (b, delta) Line 4827  enlarge_buffer_text (b, delta)
4827  #else  #else
4828    p = xrealloc (b->text->beg, nbytes);    p = xrealloc (b->text->beg, nbytes);
4829  #endif  #endif
4830      
4831    if (p == NULL)    if (p == NULL)
4832      {      {
4833        UNBLOCK_INPUT;        UNBLOCK_INPUT;
# Line 4803  free_buffer_text (b) Line 4854  free_buffer_text (b)
4854  #else  #else
4855    xfree (b->text->beg);    xfree (b->text->beg);
4856  #endif  #endif
4857      
4858    BUF_BEG_ADDR (b) = NULL;    BUF_BEG_ADDR (b) = NULL;
4859    UNBLOCK_INPUT;    UNBLOCK_INPUT;
4860  }  }
# Line 4934  init_buffer_once () Line 4985  init_buffer_once ()
4985    XSETFASTINT (buffer_local_flags.cache_long_line_scans, idx); ++idx;    XSETFASTINT (buffer_local_flags.cache_long_line_scans, idx); ++idx;
4986    XSETFASTINT (buffer_local_flags.category_table, idx); ++idx;    XSETFASTINT (buffer_local_flags.category_table, idx); ++idx;
4987    XSETFASTINT (buffer_local_flags.direction_reversed, idx); ++idx;    XSETFASTINT (buffer_local_flags.direction_reversed, idx); ++idx;
4988    XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx);    XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx);
4989    /* Make this one a permanent local.  */    /* Make this one a permanent local.  */
4990    buffer_permanent_local_flags[idx++] = 1;    buffer_permanent_local_flags[idx++] = 1;
4991    XSETFASTINT (buffer_local_flags.left_margin_width, idx); ++idx;    XSETFASTINT (buffer_local_flags.left_margin_width, idx); ++idx;
# Line 4950  init_buffer_once () Line 5001  init_buffer_once ()
5001    if (idx >= MAX_PER_BUFFER_VARS)    if (idx >= MAX_PER_BUFFER_VARS)
5002      abort ();      abort ();
5003    last_per_buffer_idx = idx;    last_per_buffer_idx = idx;
5004      
5005    Vbuffer_alist = Qnil;    Vbuffer_alist = Qnil;
5006    current_buffer = 0;    current_buffer = 0;
5007    all_buffers = 0;    all_buffers = 0;
# Line 4968  init_buffer_once () Line 5019  init_buffer_once ()
5019    
5020    Qkill_buffer_hook = intern ("kill-buffer-hook");    Qkill_buffer_hook = intern ("kill-buffer-hook");
5021    
5022      Qucs_set_table_for_input = intern ("ucs-set-table-for-input");
5023    
5024    Vprin1_to_string_buffer = Fget_buffer_create (build_string (" prin1"));    Vprin1_to_string_buffer = Fget_buffer_create (build_string (" prin1"));
5025    
5026    /* super-magic invisible buffer */    /* super-magic invisible buffer */
# Line 4993  init_buffer () Line 5046  init_buffer ()
5046        text pointers will have been set to null in the dumped Emacs.        text pointers will have been set to null in the dumped Emacs.
5047        Map new memory.  */        Map new memory.  */
5048     struct buffer *b;     struct buffer *b;
5049      
5050     for (b = all_buffers; b; b = b->next)     for (b = all_buffers; b; b = b->next)
5051       if (b->text->beg == NULL)       if (b->text->beg == NULL)
5052         enlarge_buffer_text (b, 0);         enlarge_buffer_text (b, 0);
5053   }   }
5054  #endif /* USE_MMAP_FOR_BUFFERS */  #endif /* USE_MMAP_FOR_BUFFERS */
5055      
5056    Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));    Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));
5057    if (NILP (buffer_defaults.enable_multibyte_characters))    if (NILP (buffer_defaults.enable_multibyte_characters))
5058      Fset_buffer_multibyte (Qnil);      Fset_buffer_multibyte (Qnil);
# Line 5044  init_buffer () Line 5097  init_buffer ()
5097           because of the ange-ftp completion handler.           because of the ange-ftp completion handler.
5098           However, it is not necessary to turn / into /:/.           However, it is not necessary to turn / into /:/.
5099           So avoid doing that.  */           So avoid doing that.  */
5100        && strcmp ("/", XSTRING (current_buffer->directory)->data))        && strcmp ("/", SDATA (current_buffer->directory)))
5101      current_buffer->directory      current_buffer->directory
5102        = concat2 (build_string ("/:"), current_buffer->directory);        = concat2 (build_string ("/:"), current_buffer->directory);
5103    
# Line 5095  syms_of_buffer () Line 5148  syms_of_buffer ()
5148    staticpro (&Qbefore_change_functions);    staticpro (&Qbefore_change_functions);
5149    Qafter_change_functions = intern ("after-change-functions");    Qafter_change_functions = intern ("after-change-functions");
5150    staticpro (&Qafter_change_functions);    staticpro (&Qafter_change_functions);
5151      staticpro (&Qucs_set_table_for_input);
5152    
5153      Qkill_buffer_query_functions = intern ("kill-buffer-query-functions");
5154      staticpro (&Qkill_buffer_query_functions);
5155    
5156    Fput (Qprotected_field, Qerror_conditions,    Fput (Qprotected_field, Qerror_conditions,
5157          Fcons (Qprotected_field, Fcons (Qerror, Qnil)));          Fcons (Qprotected_field, Fcons (Qerror, Qnil)));
# Line 5137  This is the same as (default-value 'ctl- Line 5194  This is the same as (default-value 'ctl-
5194                        &buffer_defaults.direction_reversed,                        &buffer_defaults.direction_reversed,
5195                        doc: /* Default value of `direction_reversed' for buffers that do not override it.                        doc: /* Default value of `direction_reversed' for buffers that do not override it.
5196  This is the same as (default-value 'direction-reversed).  */);  This is the same as (default-value 'direction-reversed).  */);
5197    
5198     DEFVAR_LISP_NOPRO ("default-enable-multibyte-characters",     DEFVAR_LISP_NOPRO ("default-enable-multibyte-characters",
5199                        &buffer_defaults.enable_multibyte_characters,                        &buffer_defaults.enable_multibyte_characters,
5200                        doc: /* *Default value of `enable-multibyte-characters' for buffers not overriding it.                        doc: /* *Default value of `enable-multibyte-characters' for buffers not overriding it.
5201  This is the same as (default-value 'enable-multibyte-characters).  */);  This is the same as (default-value 'enable-multibyte-characters).  */);
5202    
5203     DEFVAR_LISP_NOPRO ("default-buffer-file-coding-system",     DEFVAR_LISP_NOPRO ("default-buffer-file-coding-system",
5204                        &buffer_defaults.buffer_file_coding_system,                        &buffer_defaults.buffer_file_coding_system,
5205                        doc: /* Default value of `buffer-file-coding-system' for buffers not overriding it.                        doc: /* Default value of `buffer-file-coding-system' for buffers not overriding it.
5206  This is the same as (default-value 'buffer-file-coding-system).  */);  This is the same as (default-value 'buffer-file-coding-system).  */);
5207    
5208    DEFVAR_LISP_NOPRO ("default-truncate-lines",    DEFVAR_LISP_NOPRO ("default-truncate-lines",
5209                       &buffer_defaults.truncate_lines,                       &buffer_defaults.truncate_lines,
5210                       doc: /* Default value of `truncate-lines' for buffers that do not override it.                       doc: /* Default value of `truncate-lines' for buffers that do not override it.
# Line 5174  This is the same as (default-value 'tab- Line 5231  This is the same as (default-value 'tab-
5231  This is the same as (default-value 'case-fold-search).  */);  This is the same as (default-value 'case-fold-search).  */);
5232    
5233  #ifdef DOS_NT  #ifdef DOS_NT
5234    DEFVAR_LISP_NOPRO ("default-buffer-file-type",    DEFVAR_LISP_NOPRO ("default-buffer-file-type",
5235                       &buffer_defaults.buffer_file_type,                       &buffer_defaults.buffer_file_type,
5236                       doc: /* Default file type for buffers that do not override it.                       doc: /* Default file type for buffers that do not override it.
5237  This is the same as (default-value 'buffer-file-type).  This is the same as (default-value 'buffer-file-type).
# Line 5190  This is the same as (default-value 'left Line 5247  This is the same as (default-value 'left
5247                       &buffer_defaults.right_margin_width,                       &buffer_defaults.right_margin_width,
5248                       doc: /* Default value of `right_margin_width' for buffers that don't override it.                       doc: /* Default value of `right_margin_width' for buffers that don't override it.
5249  This is the same as (default-value 'right-margin-width).  */);  This is the same as (default-value 'right-margin-width).  */);
5250      
5251    DEFVAR_LISP_NOPRO ("default-indicate-empty-lines",    DEFVAR_LISP_NOPRO ("default-indicate-empty-lines",
5252                       &buffer_defaults.indicate_empty_lines,                       &buffer_defaults.indicate_empty_lines,
5253                       doc: /* Default value of `indicate-empty-lines' for buffers that don't override it.                       doc: /* Default value of `indicate-empty-lines' for buffers that don't override it.
5254  This is the same as (default-value 'indicate-empty-lines).  */);  This is the same as (default-value 'indicate-empty-lines).  */);
5255      
5256    DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively",    DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively",
5257                       &buffer_defaults.scroll_up_aggressively,                       &buffer_defaults.scroll_up_aggressively,
5258                       doc: /* Default value of `scroll-up-aggressively'.                       doc: /* Default value of `scroll-up-aggressively'.
5259  This value applies in buffers that don't have their own local values.  This value applies in buffers that don't have their own local values.
5260  This variable is an alias for (default-value 'scroll-up-aggressively).  */);  This variable is an alias for (default-value 'scroll-up-aggressively).  */);
5261      
5262    DEFVAR_LISP_NOPRO ("default-scroll-down-aggressively",    DEFVAR_LISP_NOPRO ("default-scroll-down-aggressively",
5263                       &buffer_defaults.scroll_down_aggressively,                       &buffer_defaults.scroll_down_aggressively,
5264                       doc: /* Default value of `scroll-down-aggressively'.                       doc: /* Default value of `scroll-down-aggressively'.
5265  This value applies in buffers that don't have their own local values.  This value applies in buffers that don't have their own local values.
5266  This variable is an alias for (default-value 'scroll-down-aggressively).  */);  This variable is an alias for (default-value 'scroll-down-aggressively).  */);
5267      
5268    DEFVAR_PER_BUFFER ("header-line-format",    DEFVAR_PER_BUFFER ("header-line-format",
5269                       &current_buffer->header_line_format,                       &current_buffer->header_line_format,
5270                       Qnil,                       Qnil,
5271                       doc: /* Analogous to `mode-line-format', but controls the header line.                       doc: /* Analogous to `mode-line-format', but controls the header line.
5272  The header line appears, optionally, at the top of a window;  The header line appears, optionally, at the top of a window;
5273  the mode line appears at the bottom.  */);  the mode line appears at the bottom.  */);
5274      
5275    DEFVAR_PER_BUFFER ("mode-line-format", &current_buffer->mode_line_format,    DEFVAR_PER_BUFFER ("mode-line-format", &current_buffer->mode_line_format,
5276                       Qnil,                       Qnil,
5277                       doc: /* Template for displaying mode line for current buffer.                       doc: /* Template for displaying mode line for current buffer.
# Line 5224  A value of nil means don't display a mod Line 5281  A value of nil means don't display a mod
5281  For a symbol, its value is used (but it is ignored if t or nil).  For a symbol, its value is used (but it is ignored if t or nil).
5282   A string appearing directly as the value of a symbol is processed verbatim   A string appearing directly as the value of a symbol is processed verbatim
5283   in that the %-constructs below are not recognized.   in that the %-constructs below are not recognized.
5284     Note that unless the symbol is marked as a `risky-local-variable', all
5285     properties in any strings, as well as all :eval and :propertize forms
5286     in the value of that symbol will be ignored.
5287  For a list of the form `(:eval FORM)', FORM is evaluated and the result  For a list of the form `(:eval FORM)', FORM is evaluated and the result
5288   is used as a mode line element.   is used as a mode line element.  Be careful--FORM should not load any files,
5289     because that can cause an infinite recursion.
5290    For a list of the form `(:propertize ELT PROPS...)', ELT is displayed
5291     with the specified properties PROPS applied.
5292  For a list whose car is a symbol, the symbol's value is taken,  For a list whose car is a symbol, the symbol's value is taken,
5293   and if that is non-nil, the cadr of the list is processed recursively.   and if that is non-nil, the cadr of the list is processed recursively.
5294   Otherwise, the caddr of the list (if there is one) is processed.   Otherwise, the caddr of the list (if there is one) is processed.
# Line 5279  nil here means use current buffer's majo Line 5342  nil here means use current buffer's majo
5342    
5343    DEFVAR_PER_BUFFER ("fill-column", &current_buffer->fill_column,    DEFVAR_PER_BUFFER ("fill-column", &current_buffer->fill_column,
5344                       make_number (Lisp_Int),                       make_number (Lisp_Int),
5345                       doc: /* *Column beyond which automatic line-wrapping should happen.  */);                       doc: /* *Column beyond which automatic line-wrapping should happen.
5346    Interactively, you can set this using \\[set-fill-column].  */);
5347    
5348    DEFVAR_PER_BUFFER ("left-margin", &current_buffer->left_margin,    DEFVAR_PER_BUFFER ("left-margin", &current_buffer->left_margin,
5349                       make_number (Lisp_Int),                       make_number (Lisp_Int),
# Line 5298  in the current display table (if there i Line 5362  in the current display table (if there i
5362    
5363    DEFVAR_PER_BUFFER ("enable-multibyte-characters",    DEFVAR_PER_BUFFER ("enable-multibyte-characters",
5364                       &current_buffer->enable_multibyte_characters,                       &current_buffer->enable_multibyte_characters,
5365                       make_number (-1),                       Qnil,
5366                       doc: /* Non-nil means the buffer contents are regarded as multi-byte characters.                       doc: /* Non-nil means the buffer contents are regarded as multi-byte characters.
5367  Otherwise they are regarded as unibyte.  This affects the display,  Otherwise they are regarded as unibyte.  This affects the display,
5368  file I/O and the behavior of various editing commands.  file I/O and the behavior of various editing commands.
# Line 5308  use the function `set-buffer-multibyte' Line 5372  use the function `set-buffer-multibyte'
5372  Changing its default value with `setq-default' is supported.  Changing its default value with `setq-default' is supported.
5373  See also variable `default-enable-multibyte-characters' and Info node  See also variable `default-enable-multibyte-characters' and Info node
5374  `(elisp)Text Representations'.  */);  `(elisp)Text Representations'.  */);
5375      XSYMBOL (intern ("enable-multibyte-characters"))->constant = 1;
5376    
5377    DEFVAR_PER_BUFFER ("buffer-file-coding-system",    DEFVAR_PER_BUFFER ("buffer-file-coding-system",
5378                       &current_buffer->buffer_file_coding_system, Qnil,                       &current_buffer->buffer_file_coding_system, Qnil,
# Line 5455  See also the functions `display-table-sl Line 5520  See also the functions `display-table-sl
5520                       Qnil,                       Qnil,
5521                       doc: /* *Width of left marginal area for display of a buffer.                       doc: /* *Width of left marginal area for display of a buffer.
5522  A value of nil means no marginal area.  */);  A value of nil means no marginal area.  */);
5523      
5524    DEFVAR_PER_BUFFER ("right-margin-width", &current_buffer->right_margin_width,    DEFVAR_PER_BUFFER ("right-margin-width", &current_buffer->right_margin_width,
5525                       Qnil,                       Qnil,
5526                       doc: /* *Width of right marginal area for display of a buffer.                       doc: /* *Width of right marginal area for display of a buffer.
5527  A value of nil means no marginal area.  */);  A value of nil means no marginal area.  */);
5528      
5529    DEFVAR_PER_BUFFER ("indicate-empty-lines",    DEFVAR_PER_BUFFER ("indicate-empty-lines",
5530                       &current_buffer->indicate_empty_lines, Qnil,                       &current_buffer->indicate_empty_lines, Qnil,
5531                       doc: /* *Visually indicate empty lines after the buffer end.                       doc: /* *Visually indicate empty lines after the buffer end.
5532  If non-nil, a bitmap is displayed in the left fringe of a window on  If non-nil, a bitmap is displayed in the left fringe of a window on
5533  window-systems.  */);  window-systems.  */);
5534      
5535    DEFVAR_PER_BUFFER ("scroll-up-aggressively",    DEFVAR_PER_BUFFER ("scroll-up-aggressively",
5536                       &current_buffer->scroll_up_aggressively, Qnil,                       &current_buffer->scroll_up_aggressively, Qnil,
5537                       doc: /* *If a number, scroll display up aggressively.                       doc: /* How far to scroll windows upward.
5538  If scrolling a window because point is below the window end, choose  If you move point off the bottom, the window scrolls automatically.
5539  a new window start so that point ends up that fraction of the window's  This variable controls how far it scrolls.  nil, the default,
5540  height from the bottom of the window.  */);  means scroll to center point.  A fraction means scroll to put point
5541      that fraction of the window's height from the bottom of the window.
5542    When the value is 0.0, point goes at the bottom line, which in the simple
5543    case that you moved off with C-f means scrolling just one line.  1.0 means
5544    point goes at the top, so that in that simple case, the window
5545    window scrolls by a full window height.  Meaningful values are
5546    between 0.0 and 1.0, inclusive.  */);
5547    
5548    DEFVAR_PER_BUFFER ("scroll-down-aggressively",    DEFVAR_PER_BUFFER ("scroll-down-aggressively",
5549                       &current_buffer->scroll_down_aggressively, Qnil,                       &current_buffer->scroll_down_aggressively, Qnil,
5550                       doc: /* *If a number, scroll display down aggressively.                       doc: /* How far to scroll windows downward.
5551  If scrolling a window because point is above the window start, choose  If you move point off the top, the window scrolls automatically.
5552  a new window start so that point ends up that fraction of the window's  This variable controls how far it scrolls.  nil, the default,
5553  height from the top of the window.  */);  means scroll to center point.  A fraction means scroll to put point
5554      that fraction of the window's height from the top of the window.
5555    When the value is 0.0, point goes at the top line, which in the simple
5556    case that you moved off with C-b means scrolling just one line.  1.0 means
5557    point goes at the bottom, so that in that simple case, the window
5558    window scrolls by a full window height.  Meaningful values are
5559    between 0.0 and 1.0, inclusive.  */);
5560    
5561  /*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol,  /*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol,
5562      "Don't ask.");      "Don't ask.");
5563  */  */
# Line 5600  functions; it should only affect their p Line 5677  functions; it should only affect their p
5677    DEFVAR_PER_BUFFER ("buffer-file-format", &current_buffer->file_format, Qnil,    DEFVAR_PER_BUFFER ("buffer-file-format", &current_buffer->file_format, Qnil,
5678                       doc: /* List of formats to use when saving this buffer.                       doc: /* List of formats to use when saving this buffer.
5679  Formats are defined by `format-alist'.  This variable is  Formats are defined by `format-alist'.  This variable is
5680  set when a file is visited.  Automatically local in all buffers.  */);  set when a file is visited.  */);
5681    
5682    DEFVAR_PER_BUFFER ("buffer-invisibility-spec",    DEFVAR_PER_BUFFER ("buffer-invisibility-spec",
5683                       &current_buffer->invisibility_spec, Qnil,                       &current_buffer->invisibility_spec, Qnil,

Legend:
Removed from v.1.388  
changed lines
  Added in v.1.388.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26