X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fbuffer.c;h=e7f8a4cf8ef85e1c75593afc2a2a8cc12791edf8;hp=1ba488c7683452bfa1c99786f3a0f3bb7031473c;hb=7b241b273a632ab80d7c620b5add28d5f11b0fd3;hpb=98a6e4055a1fa624c592ac06f79287d55196ca37 diff --git a/src/buffer.c b/src/buffer.c index 1ba488c..e7f8a4c 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2,6 +2,7 @@ Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc. Copyright (C) 1995 Sun Microsystems, Inc. Copyright (C) 1995, 1996 Ben Wing. + Copyright (C) 1999,2000,2001 MORIOKA Tomohiko This file is part of XEmacs. @@ -29,6 +30,7 @@ Boston, MA 02111-1307, USA. */ list per frame.) Mly: a few changes for buffer-local vars, 19.8 or 19.9. Ben Wing: some changes and cleanups for Mule, 19.12. + MORIOKA Tomohiko: some changes for XEmacs UTF-2000. */ /* This file contains functions that work with buffer objects. @@ -70,6 +72,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 +210,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; @@ -355,7 +358,7 @@ get_buffer (Lisp_Object name, int error_if_deleted_or_does_not_exist) struct buffer * decode_buffer (Lisp_Object buffer, int allow_string) { - if (NILP (buffer)) + if (NILP (buffer) || (!POINTER_TYPE_P( XTYPE(buffer)))) return current_buffer; if (allow_string && STRINGP (buffer)) @@ -521,7 +524,7 @@ delete_from_buffer_alist (Lisp_Object buf) Lisp_Object cons = Frassq (buf, Vbuffer_alist); Lisp_Object frmcons, devcons, concons; if (NILP (cons)) - return; /* abort() ? */ + return; /* ABORT() ? */ Vbuffer_alist = delq_no_quit (cons, Vbuffer_alist); FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) @@ -697,28 +700,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 } @@ -1019,8 +1000,8 @@ The ordering is for this frame; If second optional argument FRAME is provided, then the ordering is for that frame. If the second arg is t, then the global ordering is returned. -Note: In FSF Emacs, this function takes two arguments: BUFFER and -VISIBLE-OK. +Note: In FSF Emacs, this function takes the arguments in the order of +BUFFER, VISIBLE-OK and FRAME. */ (buffer, frame, visible_ok)) { @@ -1277,10 +1258,14 @@ with `delete-process'. delete_from_buffer_alist (buf); - /* #### 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, Qnil, Qnil); + /* Undedicate any windows of this buffer, and make sure no windows + show it. */ + + undedicate_windows (buf, Qt); + + GCPRO1 (buf); + Freplace_buffer_in_windows (buf, Qnil, Qall); + UNGCPRO; font_lock_buffer_was_killed (b); @@ -1351,38 +1336,60 @@ buffer. See `other-buffer' for more information. { REGISTER Lisp_Object lynk, prev; struct frame *f = selected_frame (); + int buffer_found = 0; + CHECK_BUFFER (buffer); + if (!BUFFER_LIVE_P (XBUFFER (buffer))) + return Qnil; prev = Qnil; for (lynk = Vbuffer_alist; CONSP (lynk); lynk = XCDR (lynk)) { if (EQ (XCDR (XCAR (lynk)), buffer)) - break; + { + buffer_found = 1; + break; + } prev = lynk; } - /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */ - if (NILP (prev)) - Vbuffer_alist = XCDR (Vbuffer_alist); + if (buffer_found) + { + /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */ + if (NILP (prev)) + Vbuffer_alist = XCDR (Vbuffer_alist); + else + XCDR (prev) = XCDR (XCDR (prev)); + XCDR (lynk) = Vbuffer_alist; + Vbuffer_alist = lynk; + } else - XCDR (prev) = XCDR (XCDR (prev)); - XCDR (lynk) = Vbuffer_alist; - Vbuffer_alist = lynk; + Vbuffer_alist = Fcons (Fcons (Fbuffer_name(buffer), buffer), Vbuffer_alist); /* That was the global one. Now do the same thing for the per-frame buffer-alist. */ + buffer_found = 0; prev = Qnil; for (lynk = f->buffer_alist; CONSP (lynk); lynk = XCDR (lynk)) { if (EQ (XCDR (XCAR (lynk)), buffer)) - break; + { + buffer_found = 1; + break; + } prev = lynk; } - /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */ - if (NILP (prev)) - f->buffer_alist = XCDR (f->buffer_alist); + if (buffer_found) + { + /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */ + if (NILP (prev)) + f->buffer_alist = XCDR (f->buffer_alist); + else + XCDR (prev) = XCDR (XCDR (prev)); + XCDR (lynk) = f->buffer_alist; + f->buffer_alist = lynk; + } else - XCDR (prev) = XCDR (XCDR (prev)); - XCDR (lynk) = f->buffer_alist; - f->buffer_alist = lynk; + f->buffer_alist = Fcons (Fcons (Fbuffer_name(buffer), buffer), + f->buffer_alist); return Qnil; } @@ -1643,7 +1650,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; } @@ -1879,11 +1885,17 @@ dfc_convert_to_external_format (dfc_conversion_type source_type, const Bufbyte *end; for (end = ptr + len; ptr < end;) { +#ifdef UTF2000 + Bufbyte c = + (*ptr < 0xc0) ? *ptr : + ((*ptr & 0x1f) << 6) | (*(ptr+1) & 0x3f); +#else Bufbyte c = (BYTE_ASCII_P (*ptr)) ? *ptr : (*ptr == LEADING_BYTE_CONTROL_1) ? (*(ptr+1) - 0x20) : (*ptr == LEADING_BYTE_LATIN_ISO8859_1) ? (*(ptr+1)) : '~'; +#endif Dynarr_add (conversion_out_dynarr, (Extbyte) c); INC_CHARPTR (ptr); @@ -1937,7 +1949,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)); @@ -2019,6 +2031,15 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type, { Bufbyte c = *ptr; +#ifdef UTF2000 + if (BYTE_ASCII_P (c)) + Dynarr_add (conversion_in_dynarr, c); + else + { + Dynarr_add (conversion_in_dynarr, (c >> 6) | 0xC0); + Dynarr_add (conversion_in_dynarr, (c & 0x3F) | 0x80); + } +#else if (BYTE_ASCII_P (c)) Dynarr_add (conversion_in_dynarr, c); else if (BYTE_C1_P (c)) @@ -2031,6 +2052,7 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type, Dynarr_add (conversion_in_dynarr, LEADING_BYTE_LATIN_ISO8859_1); Dynarr_add (conversion_in_dynarr, c); } +#endif } #else Dynarr_add_many (conversion_in_dynarr, source->data.ptr, source->data.len); @@ -2075,7 +2097,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)); @@ -2227,7 +2249,11 @@ 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 @@ -2427,21 +2453,15 @@ 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; +#ifndef UTF2000 defs->mirror_syntax_table = XCHAR_TABLE (Vstandard_syntax_table)->mirror_table; +#endif defs->modeline_format = build_string ("%-"); /* reset in loaddefs.el */ defs->case_fold_search = Qt; defs->selective_display_ellipses = Qt; @@ -2454,6 +2474,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 +2520,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; @@ -2530,7 +2548,9 @@ common_init_complex_vars_of_buffer (void) /* #### Warning: 1<<31 is the largest number currently allowable due to the XINT() handling of this value. With some - rearrangement you can get 3 more bits. */ + rearrangement you can get 3 more bits. + + #### 3 more? 34 bits???? -ben */ } } @@ -2576,8 +2596,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 +2720,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 /* @@ -2827,6 +2841,8 @@ It may not be a list of functions. DEFVAR_BUFFER_LOCAL ("buffer-file-name", filename /* Name of file visited in current buffer, or nil if not visiting a file. Each buffer has its own value of this variable. +Code that changes this variable must maintain the invariant +`(equal buffer-file-truename (file-truename buffer-file-name))'. */ ); #if 0 /* FSFmacs */ @@ -2839,12 +2855,11 @@ Each buffer has its own value of this variable. #endif /* FSFmacs */ DEFVAR_BUFFER_LOCAL ("buffer-file-truename", file_truename /* -The real name of the file visited in the current buffer, -or nil if not visiting a file. This is the result of passing -buffer-file-name to the `file-truename' function. Every buffer has -its own value of this variable. This variable is automatically -maintained by the functions that change the file name associated -with a buffer. +The real name of the file visited in the current buffer, or nil if not +visiting a file. This is the result of passing `buffer-file-name' to the +`file-truename' function. Every buffer has its own value of this variable. +Code that changes the file name associated with a buffer maintains the +invariant `(equal buffer-file-truename (file-truename buffer-file-name))'. */ ); DEFVAR_BUFFER_LOCAL ("buffer-auto-save-file-name", auto_save_file_name /* @@ -3057,7 +3072,7 @@ handled: if ((XINT (buffer_local_flags.slot) != -2 && \ XINT (buffer_local_flags.slot) != -3) \ != !(NILP (XBUFFER (Vbuffer_local_symbols)->slot))) \ - abort () + ABORT () #include "bufslots.h" #undef MARKED_SLOT