(message_dolog, message2): New arg MULTIBYTE.
Callers changed.
(message1, message1_nolog): String must be ASCII-only.
(message2, message2_nolog): Now static.
(x_consider_frame_title): Use size_byte.
(display_text_line): Likewise.
And scan Voverlay_arrow_string by bytes and chars.
(display_menu_bar): Call display_string with a byte size.
(display_mode_line): Call display_string with a byte size.
(describe_vector): Unconditionally handle multibyte chars.
(describe_vector): Pass new args to insert_from_string.
(Ftext_char_description): Use make_multibyte_string.
(Fkey_binding): Scan PREFIX a char at a time.
(Fkey_description): Scan KEYS by chars.
(echo_now): Use message2_nolog, not message1_nolog.
(Fexecute_extended_command): Likewise.
(read_char_minibuf_menu_prompt): Use message2_nolog, not message1.
(parse_modifiers): Use size_byte.
(echo_char): Use size_byte.
(parse_modifiers_uncached): Likewise.
(record_char): Likewise.
(parse_solitary_modifier): Likewise.
(read_char): Use Faref on Vkeyboard_translate_table
if it is a string.
(apply_modifiers_uncached): New arg base_len_byte. Calls changed.
(read_char_minibuf_menu_prompt):
(read_key_sequence): Access buffer's downcase_table with XCHAR_TABLE.
(Fexecute_extended_command): Use Faref to access FUNCTION.
Use size_byte of BINDING.
(stuff_buffered_input): Use size_byte of STUFFSTRING.
(Fdo_auto_save): Save and restore multibyteness of minibuffer.
(Fwrite_region): Use message_with_string.
(auto_save_error, Fdo_auto_save): Likewise.
(Ffile_name_directory): Maybe use make_unibyte_string.
(Ffile_name_nondirectory): Likewise.
(Fsubstitute_in_file_name): Convert substituted envvars to multibyte
if necessary. Otherwise use make_unibyte_string.
(Finsert_file_contents): Use make_unibyte_string.
(double_dollars): Use make_uninit_multibyte_string.
(multibyte_chars_in_text): New function.
(Fstring): Use make_multibyte_string.
(Fcompose_string): Likewise.
(Ffind_charset_string): Handle bytes vs chars in string.
Special case for single-byte strings.
(Fchars_in_string): Function deleted.
(Fstring): Renamed from Fconcat_chars.
Handle bytes vs chars in string.
(syms_of_charset): Corresponding changes.
(read_escape): `\ ' stands for nothing at all.
(oblookup): Take args SIZE and SIZE_BYTE. Callers changed.
(init_obarray, read1, make_symbol):
Pass new arg to make_pure_string.
(Fintern, oblookup, Fintern_soft, intern): Handle size_byte.
(dir_warning): Pass new arg to message_dolog.
(read1): PCH is now int *.
Declare ch as int.
(read0): Declare c as int.
(read_list): Declare ch as int.
(read0): Use Fmake_string not make_string.
(read1): When reading a string, maybe use make_unibyte_string.
(Fread_from_string): Convert string indices to/from bytes.
(count_size_as_multibyte): New function.
(insert_from_string_1, insert_from_buffer_1): Use it.
(copy_text): New function.
(insert_from_buffer_1): Call copy_text to convert between
single-byte and multibyte text.
(insert_from_string_1): Likewise.
(insert_1_both): New function.
(insert_from_string): New args POS_BYTE, LENGTH.
(insert_from_string_before_markers):
(insert_from_string_1): New arg POS_BYTE. Swap args NCHARS, NBYTES.
Don't fail to use POS_BYTE!
(insert_from_buffer_1): Get both inschars and insbytes from NEW.
(Fformat): Do all the work directly--don't use doprnt.
Calculate the right size the first time, so no need to retry.
Count chars and bytes in the result.
Convert single-byte strings to multibyte as needed.
Eric M. Ludlam [Thu, 8 Jan 1998 23:35:34 +0000 (23:35 +0000)]
Added some more comments in the commentary.
You can now `quote' symbols that look like keystrokes
When spell checking, meta variables can end in `th' or `s'.
(print_string): Now static.
(print): When multibyte is disabled,
print multibyte string chars using hex escapes.
(printchar): Pass new arg to message_dolog.
(strout): New arg MULTIBYTE. Callers changed.
(strout): Take args SIZE and SIZE_BYTE;
operate on both chars and bytes.
(print_string): Pass new arg to strout.
If not using strout, fetch a whole multibyte char at once.
(write_string): Pass new arg to strout.
(write_string_1): Likewise.
(print) <case Lisp_String>: Scan by chars and bytes.
(print) <case Lisp_Symbol>: Scan name by chars and bytes.
(PRINTPREPARE): Use make_multibyte_string.
Initialize print_buffer_pos_byte. Use insert_1_both.
(printchar): Update print_buffer_pos_byte and print_buffer_pos.
(print_buffer_pos_byte): New variable.
(make_pure_string): New arg length_byte.
Take account of size used by size_byte; store both sizes.
(Fpurecopy): Call make_pure_string the new way.
(compact_strings): Use size_byte field to compute string's size.
(make_uninit_multibyte_string): New function.
(make_uninit_string): Use make_uninit_multibyte_string.
(make_multibyte_string): New function.
(make_unibyte_string): New function.
(make_string): Compute number of chars from the data.
(record_overlay_string): Totalize sizes assuming
strings are converted to match buffer in multibyteness.
(overlay_strings): Convert strings to match buffer in multibyteness.
(test_completion): Pass both kinds of size to oblookup.
(Fminibuffer_complete_word): Scan string bytes and chars.
Pass new args to insert_from_string.
(Ftry_completion): Use size_byte while comparing.
(Fall_completions): Use size_byte while comparing.
(current_column_1, Fmove_to_column):
Update call to CHAR_HEAD_P.
(indented_beyond_p): Take POS in bytes and chars. Callers changed.
(pos_tab_indent): Function moved to xdisp.c.
(Fcurrent_indentation): Use scan_newline and SET_PT_BOTH.
(indented_beyond_p, current_column_1): Likewise.
(vmotion, compute_motion): Set up bytepos value to return it.
(current_column): Handle bytepos and charpos.
(position_indentation): Take bytepos as arg, and scan with it. Calls changed.
(Fmove_to_column): Scan with bytepos and charpos.
(pos_tab_offset): Use bytepos to do FETCH_BYTE.
(skip_invisible): Don't worry about position in middle of character.
(adjust_markers_gap_motion): Now a no-op.
(adjust_markers_for_delete): Update ->bytepos instead of ->bufpos,
but don't adjust for the gap.
(adjust_markers_for_insert): Likewise.
(Fgoto_char): When arg is a marker, copy char and byte
positions from it. When arg is an integer, no need to worry that it
is in middle of a character.
(buildmark): Take 2 args (charpos and bytepos). Callers changed.
(Fline_beginning_position): Save and restore both kinds of PT.
(Fprevious_char): Use PT_BYTE.
(Fbolp, Feolp): Use PT_BYTE.
(transpose_markers): Take args in chars and bytes.
(Ftranspose_regions): Work with byte and char positions.
(Fchar_after, Fchar_before): Use bytepos.
(make_buffer_string): Convert charpos to bytepos.
(Fcompare_buffer_substrings): Work with charpos and bytepos.
(Fsubst_char_in_region): Handle charpos and bytepos.
(Fwiden, Fnarrow_to_region): Likewise.
(save_restriction_restore): Update PT and PT_BYTES.
Cast arg to doprnt_lisp.
(set_point_both): Renamed from set_point;
New arg BYTE; BUFFER is now first arg; use temp_set_point_both.
(set_point): New function; uses set_point_both.
(temp_set_point_both): New function.
(temp_set_point): Update BUF_PT_BYTE.
(get_local_map): Save and restore both forms of the buffer bounds.
(move_gap): Use move_gap_both.
(move_gap_both): New function.
(gap_left, gap_right): Take both charpos and bytepos args.
(adjust_markers_gap_motion): Renamed from adjust_markers and simplified.
(adjust_markers_for_delete): New function.
(adjust_markers_for_insert): Take args in chars and bytes.
Also new arg BEFORE_MARKERS. One call does all marker updating
needed for any insert.
(adjust_point): Take 2 args and update PT and PT_BYTE.
(make_gap): Handle bytes vs chars.
(insert, insert_and_inherit): Handle bytes vs chars.
Pass new BEFORE_MARKERS arg to insert_1.
(insert_before_markers, insert_before_markers_and_inherit): Likewise.
(insert_from_string, insert_from_string_before_markers): Likewise.
(insert_from_buffer): Likewise.
(insert_1): Handle bytes vs chars. New arg BEFORE_MARKERS.
(insert_from_string_1, insert_from_buffer_1): Likewise.
(replace_range): Likewise.
(del_range_2): New subroutine, taken from del_range_1.
(del_range_1): Use del_range_2.
(del_range_byte, del_range_both): New functions.
(DECODE_POSITION): New macro.
(CHAR_TO_BYTE, BYTE_TO_CHAR): New macros.
(BEG_BYTE, BEGV_BYTE, PT_BYTE, GPT_BYTE)
(ZV_BYTE, Z_BYTE): New macros.
(BUF_BEG_BYTE, BUF_BEGV_BYTE, BUF_PT_BYTE, BUF_GPT_BYTE)
(BUF_ZV_BYTE, BUF_Z_BYTE): New macros.
(BUF_GAP_END_ADDR): New macro.
(BEGV_ADDR, PT_ADDR, GPT_ADDR, GAP_END_ADDR, ZV_ADDR, Z_ADDR):
Use the new ..._byte buffer data.
(BUFFER_CEILING_OF, BUFFER_FLOOR_OF): Likewise.
(BUF_GPT_ADDR, BUF_Z_ADDR): Likewise.
(SET_PT_BOTH, TEMP_SET_PT_BOTH): New macros.
(SET_PT, TEMP_SET_PT, BUF_SET_PT, BUF_TEMP_SET_PT):
Call functions with new arg order.
(SET_BUF_BEGV, SET_BUF_BEGV_BOTH): New macros.
(SET_BUF_PT): Macro deleted.
(SET_BUF_ZV): Set charpos and bytepos.
(SET_BUF_ZV_BOTH, SET_BUF_PT_BOTH): New macros.
(BYTE_POS_ADDR): Renamed from POS_ADDR.
(CHAR_POS_ADDR): New macro.
(FETCH_BYTE): Use BYTE_POS_ADDR.
(FETCH_MULTIBYTE_CHAR): Use ..._BYTE macros.
(BUF_CHAR_ADDRESS): Convert charpos to bytepos.
(BUF_BYTE_ADDRESS): New macro, like the old BUF_CHAR_ADDRESS.
(PTR_BYTE_POS): Renamed from PTR_CHAR_POS.
(BUF_PTR_BYTE_POS): New macro.
(BUF_FETCH_CHAR, BUF_FETCH_BYTE, BUF_FETCH_MULTIBYTE_CHAR): New macros.
(struct buffer_text): New fields gpt_byte, z_byte.
(struct buffer): New fields pt_byte, begv_byte, zv_byte.
(Fprocess_send_region): Make bytepos for send_process.
(read_process_output): Save, restore, and update both kinds of ptrs.
(send_process): OFFSET is now in bytes.
(PRINTDECLARE): Declare old_point_byte and start_point_byte.
(PRINTPREPARE): For a marker, set old_point_byte and start_point_byte.
Set both kinds of PT from the marker.
(PRINTFINISH): For a marker, use set_marker_both.
Restore both kinds of PT.
(print): For strings and symbols, handle multibyte chars.
(readchar_backlog): New variable.
(readchar): When fetching from buffer or marker,
use readchar_backlog to fetch bytes from a character.
(unreadchar): Increment readchar_backlog.
(readevalloop, Fread): Init readchar_backlog.
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
(find_defun_start): Additional arg POS_BYTE.
Save final byte pos in find_start_value_byte.
(find_start_value_byte): New variable.
(Fforward_comment): Scan by bytes and chars.
(Fbackward_prefix_chars): Scan by bytes and chars.
(scan_words, scan_sexps_forward): Scan bytes as well as chars.
(skip_chars, scan_lists): Scan by bytes and chars. Now static.
(char_quoted): Take charpos and bytepos as args.
(back_comment): Likewise.
(update_syntax_table): Arg renamed.
(inc_bytepos, dec_bytepos): New functions.
(looking_at_1): Use bytepos to call re_search_2.
Convert search regs to charpos, if search succeeded.
(search_buffer): Likewise. Also convert charpos <-> bytepos
in non-regexp case.
(scan_buffer): Convert charpos <-> bytepos.
(scan_newline): New function.
(find_next_newline): Function deleted.
(set_search_regs): Args now in bytes; convert to charpos.
(Freplace_match): Convert charpos <-> bytepos when scanning case.
(forward_point): Function deleted.
(Fforward_point): Just add.
(Fforward_char): Don't call forward_point, just add.
(Fforward_line): Use scan_newline.
(Fdelete_char): No need for forward_point, just add.
(Fdelete_backward_char): Handle bytes and chars.
(internal_self_insert): Handle bytes and chars.