XEmacs 21.4.3 "Academic Rigor".
[chise/xemacs-chise.git.1] / src / buffer.c
index 2a97d62..abf70fb 100644 (file)
@@ -70,6 +70,7 @@ Boston, MA 02111-1307, USA.  */
 
 #include "buffer.h"
 #include "chartab.h"
+#include "casetab.h"
 #include "commands.h"
 #include "elhash.h"
 #include "extents.h"
@@ -207,8 +208,8 @@ Lisp_Object Qfind_file_compare_truenames;
 Lisp_Object Qswitch_to_buffer;
 
 /* Two thresholds controlling how much undo information to keep.  */
-int undo_threshold;
-int undo_high_threshold;
+Fixnum undo_threshold;
+Fixnum undo_high_threshold;
 
 int find_file_compare_truenames;
 int find_file_use_truenames;
@@ -402,11 +403,10 @@ assoc_ignore_text_properties (REGISTER Lisp_Object key, Lisp_Object list)
 #endif /* FSFmacs */
 
 DEFUN ("get-buffer", Fget_buffer, 1, 1, 0, /*
-Return the buffer named NAME (a string).
-If there is no live buffer named NAME, return nil.
-NAME may also be a buffer; if so, the value is that buffer.
+Return the buffer named BUFFER-NAME (a string), or nil if there is none.
+BUFFER-NAME may also be a buffer; if so, the value is that buffer.
 */
-       (name))
+       (buffer_name))
 {
 #ifdef I18N3
   /* #### Doc string should indicate that the buffer name will get
@@ -415,9 +415,9 @@ NAME may also be a buffer; if so, the value is that buffer.
 
   /* #### This might return a dead buffer.  This is gross.  This is
      called FSF compatibility. */
-  if (BUFFERP (name))
-    return name;
-  return get_buffer (name, 0);
+  if (BUFFERP (buffer_name))
+    return buffer_name;
+  return get_buffer (buffer_name, 0);
   /* FSFmacs 19.29 calls assoc_ignore_text_properties() here.
      Bleagh!! */
 }
@@ -633,10 +633,11 @@ The value is never nil.
 
 DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, 2, 2,
        "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", /*
-Create and return an indirect buffer for buffer BASE, named NAME.
-BASE should be an existing buffer (or buffer name).
+Create and return an indirect buffer for buffer BASE-BUFFER, named NAME.
+BASE-BUFFER should be an existing buffer (or buffer name).
 NAME should be a string which is not the name of an existing buffer.
-If BASE is an indirect buffer itself, the base buffer for that buffer
+
+If BASE-BUFFER is itself an indirect buffer, the base buffer for that buffer
  is made the base buffer for the newly created buffer. (Thus, there will
  never be indirect buffers whose base buffers are themselves indirect.)
 */
@@ -697,28 +698,6 @@ reset_buffer_local_variables (struct buffer *b, int first_time)
   }
 #include "bufslots.h"
 #undef MARKED_SLOT
-#if 0
-#define STRING256_P(obj) \
-  (STRINGP (obj) && XSTRING_CHAR_LENGTH (obj) == 256)
-  /* If the standard case table has been altered and invalidated,
-     fix up its insides first.  */
-  if (!(STRING256_P(Vascii_upcase_table) &&
-       STRING256_P(Vascii_canon_table) &&
-       STRING256_P(Vascii_eqv_table)))
-    {
-      Fset_standard_case_table (Vascii_downcase_table);
-    }
-  b->downcase_table = Vascii_downcase_table;
-  b->upcase_table = Vascii_upcase_table;
-  b->case_canon_table = Vascii_canon_table;
-  b->case_eqv_table = Vascii_eqv_table;
-#ifdef MULE
-  b->mirror_downcase_table = Vmirror_ascii_downcase_table;
-  b->mirror_upcase_table = Vmirror_ascii_upcase_table;
-  b->mirror_case_canon_table = Vmirror_ascii_canon_table;
-  b->mirror_case_eqv_table = Vmirror_ascii_eqv_table;
-#endif
-#endif
 }
 
 \f
@@ -924,7 +903,7 @@ as BUFFER means use current buffer.
      display).  We still need to make sure redisplay realizes that the
      contents have potentially altered and it needs to do some
      work. */
-  buf = decode_buffer(buffer, 0);
+  buf = decode_buffer (buffer, 0);
   BUF_MODIFF (buf)++;
   BUF_SAVE_MODIFF (buf) = NILP (flag) ? BUF_MODIFF (buf) : 0;
   MARK_MODELINE_CHANGED;
@@ -1078,7 +1057,7 @@ VISIBLE-OK.
 }
 \f
 DEFUN ("buffer-disable-undo", Fbuffer_disable_undo, 0, 1, "", /*
-Make BUFFER stop keeping undo information.
+Stop keeping undo information for BUFFER.
 Any undo records it already has are discarded.
 No argument or nil as argument means do this for the current buffer.
 */
@@ -1091,7 +1070,7 @@ No argument or nil as argument means do this for the current buffer.
 }
 
 DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, 0, 1, "", /*
-Start keeping undo information for buffer BUFFER.
+Start keeping undo information for BUFFER.
 No argument or nil as argument means do this for the current buffer.
 */
        (buffer))
@@ -1280,7 +1259,9 @@ with `delete-process'.
     /* #### This is a problem if this buffer is in a dedicated window.
        Need to undedicate any windows of this buffer first (and delete them?)
        */
-    Freplace_buffer_in_windows (buf);
+    GCPRO1 (buf);
+    Freplace_buffer_in_windows (buf, Qnil, Qall);
+    UNGCPRO;
 
     font_lock_buffer_was_killed (b);
 
@@ -1524,7 +1505,7 @@ Use `switch-to-buffer' or `pop-to-buffer' to switch buffers permanently.
 
 \f
 DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only, 0, 3, 0, /*
-Signal a `buffer-read-only' error if the buffer is read-only.
+Signal a `buffer-read-only' error if BUFFER is read-only.
 Optional argument BUFFER defaults to the current buffer.
 
 If optional argument START is non-nil, all extents in the buffer
@@ -1643,7 +1624,6 @@ BUFFER defaults to the current buffer if omitted.
      implies that the future text is not really related to the past text.  */
   b->saved_size = Qzero;
 
-  zmacs_region_stays = 0;
   return Qnil;
 }
 
@@ -1937,7 +1917,7 @@ dfc_convert_to_external_format (dfc_conversion_type source_type,
 
       while (1)
         {
-          ssize_t size_in_bytes;
+          Lstream_data_count size_in_bytes;
          char tempbuf[1024]; /* some random amount */
 
          size_in_bytes = Lstream_read (reader, tempbuf, sizeof (tempbuf));
@@ -1968,7 +1948,7 @@ dfc_convert_to_external_format (dfc_conversion_type source_type,
   if (sink_type != DFC_TYPE_LISP_LSTREAM)
     {
       sink->data.len = Dynarr_length (conversion_out_dynarr);
-      Dynarr_add (conversion_out_dynarr, 0);
+      Dynarr_add (conversion_out_dynarr, '\0');        /* NUL-terminate! */
       sink->data.ptr = Dynarr_atp (conversion_out_dynarr, 0);
     }
 }
@@ -2017,7 +1997,7 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type,
 
       for (; ptr < end; ptr++)
         {
-          Extbyte c = *ptr;
+          Bufbyte c = *ptr;
 
          if (BYTE_ASCII_P (c))
            Dynarr_add (conversion_in_dynarr, c);
@@ -2075,7 +2055,7 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type,
 
       while (1)
         {
-          ssize_t size_in_bytes;
+          Lstream_data_count size_in_bytes;
          char tempbuf[1024]; /* some random amount */
 
          size_in_bytes = Lstream_read (reader, tempbuf, sizeof (tempbuf));
@@ -2106,7 +2086,7 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type,
   if (sink_type != DFC_TYPE_LISP_LSTREAM)
     {
       sink->data.len = Dynarr_length (conversion_in_dynarr);
-      Dynarr_add (conversion_in_dynarr, 0); /* remember to zero-terminate! */
+      Dynarr_add (conversion_in_dynarr, '\0'); /* NUL-terminate! */
       sink->data.ptr = Dynarr_atp (conversion_in_dynarr, 0);
     }
 }
@@ -2216,18 +2196,22 @@ the read-only state of the buffer.  See also `kill-all-local-variables'.
   Vchange_major_mode_hook = Qnil;
 
   DEFVAR_BOOL ("find-file-compare-truenames", &find_file_compare_truenames /*
-If this is true, then the find-file command will check the truenames
+If this is true, then the `find-file' command will check the truenames
 of all visited files when deciding whether a given file is already in
-a buffer, instead of just the buffer-file-name.  This means that if you
-attempt to visit another file which is a symbolic-link to a file which is
-already in a buffer, the existing buffer will be found instead of a newly-
-created one.  This works if any component of the pathname (including a non-
-terminal component) is a symbolic link as well, but doesn't work with hard
-links (nothing does).
-
-See also the variable find-file-use-truenames.
+a buffer, instead of just `buffer-file-name'.  This means that if you
+attempt to visit another file which is a symbolic link to a file which
+is already in a buffer, the existing buffer will be found instead of a
+newly-created one.  This works if any component of the pathname
+(including a non-terminal component) is a symbolic link as well, but
+doesn't work with hard links (nothing does).
+
+See also the variable `find-file-use-truenames'.
 */ );
+#if defined(CYGWIN) || defined(WIN32_NATIVE)
+  find_file_compare_truenames = 1;
+#else
   find_file_compare_truenames = 0;
+#endif
 
   DEFVAR_BOOL ("find-file-use-truenames", &find_file_use_truenames /*
 If this is true, then a buffer's visited file-name will always be
@@ -2236,7 +2220,7 @@ will never be a symbolic link anywhere in its directory path.
 That is, the buffer-file-name and buffer-file-truename will be equal.
 This doesn't work with hard links.
 
-See also the variable find-file-compare-truenames.
+See also the variable `find-file-compare-truenames'.
 */ );
   find_file_use_truenames = 0;
 
@@ -2427,16 +2411,8 @@ common_init_complex_vars_of_buffer (void)
   defs->mode_name = QSFundamental;
   defs->abbrev_table = Qnil;    /* real default setup by Lisp code */
 
-  defs->downcase_table  = Vascii_downcase_table;
-  defs->upcase_table    = Vascii_upcase_table;
-  defs->case_canon_table = Vascii_canon_table;
-  defs->case_eqv_table  = Vascii_eqv_table;
+  defs->case_table = Vstandard_case_table;
 #ifdef MULE
-  defs->mirror_downcase_table  = Vmirror_ascii_downcase_table;
-  defs->mirror_upcase_table    = Vmirror_ascii_upcase_table;
-  defs->mirror_case_canon_table = Vmirror_ascii_canon_table;
-  defs->mirror_case_eqv_table  = Vmirror_ascii_eqv_table;
-
   defs->category_table = Vstandard_category_table;
 #endif /* MULE */
   defs->syntax_table = Vstandard_syntax_table;
@@ -2454,6 +2430,7 @@ common_init_complex_vars_of_buffer (void)
   defs->auto_save_modified = 0;
   defs->auto_save_failure_time = -1;
   defs->invisibility_spec = Qt;
+  defs->buffer_local_face_property = 0;
 
   defs->indirect_children = Qnil;
   syms->indirect_children = Qnil;
@@ -2499,10 +2476,7 @@ common_init_complex_vars_of_buffer (void)
     buffer_local_flags.generated_modeline_string = always_local_no_default;
 
     buffer_local_flags.keymap          = resettable;
-    buffer_local_flags.downcase_table  = resettable;
-    buffer_local_flags.upcase_table    = resettable;
-    buffer_local_flags.case_canon_table = resettable;
-    buffer_local_flags.case_eqv_table  = resettable;
+    buffer_local_flags.case_table      = resettable;
     buffer_local_flags.syntax_table    = resettable;
 #ifdef MULE
     buffer_local_flags.category_table  = resettable;
@@ -2576,8 +2550,8 @@ complex_vars_of_buffer (void)
   syms = XBUFFER (Vbuffer_local_symbols);
   buffer_defaults_saved_slots      = &defs->BUFFER_SLOTS_FIRST_NAME;
   buffer_local_symbols_saved_slots = &syms->BUFFER_SLOTS_FIRST_NAME;
-  dumpstruct (&buffer_defaults_saved_slots,      &buffer_slots_description);
-  dumpstruct (&buffer_local_symbols_saved_slots, &buffer_slots_description);
+  dump_add_root_struct_ptr (&buffer_defaults_saved_slots,      &buffer_slots_description);
+  dump_add_root_struct_ptr (&buffer_local_symbols_saved_slots, &buffer_slots_description);
 
   DEFVAR_BUFFER_DEFAULTS ("default-modeline-format", modeline_format /*
 Default value of `modeline-format' for buffers that don't override it.
@@ -2700,12 +2674,6 @@ Automatically becomes buffer-local when set in any fashion.
   DEFVAR_BUFFER_LOCAL ("case-fold-search", case_fold_search /*
 *Non-nil if searches should ignore case.
 Automatically becomes buffer-local when set in any fashion.
-
-BUG: Under XEmacs/Mule, translations to or from non-ASCII characters
- (this includes chars in the range 128 - 255) are ignored by
- the string/buffer-searching routines.  Thus, `case-fold-search'
- will not correctly conflate a-umlaut and A-umlaut even if the
- case tables call for this.
 */ );
 
   DEFVAR_BUFFER_LOCAL ("fill-column", fill_column /*
@@ -2920,8 +2888,8 @@ and VALUE is the old value.
 List of undo entries in current buffer.
 Recent changes come first; older changes follow newer.
 
-An entry (BEG . END) represents an insertion which begins at
-position BEG and ends at position END.
+An entry (START . END) represents an insertion which begins at
+position START and ends at position END.
 
 An entry (TEXT . POSITION) represents the deletion of the string TEXT
 from (abs POSITION).  If POSITION is positive, point was at the front
@@ -3005,8 +2973,8 @@ The default is t, which means that text is invisible
 if it has (or is covered by an extent with) a non-nil `invisible' property.
 If the value is a list, a text character is invisible if its `invisible'
 property is an element in that list.
-If an element is a cons cell of the form (PROP . ELLIPSIS),
-then characters with property value PROP are invisible,
+If an element is a cons cell of the form (PROPERTY . ELLIPSIS),
+then characters with property value PROPERTY are invisible,
 and they have an ellipsis as well if ELLIPSIS is non-nil.
 Note that the actual characters used for the ellipsis are controllable
 using `invisible-text-glyph', and default to "...".