diff options
author | Tom Tromey <tromey@redhat.com> | 2012-08-20 07:34:41 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-08-20 07:34:41 -0600 |
commit | 49bc1a9dfc6e81a370bf12157c3c573743ee200a (patch) | |
tree | 24df8b040aff367adc11a2c676334ec238651e1d /src | |
parent | b94de893429bbfbb27572c8c3118fcc876957adb (diff) | |
parent | a05731a0cc2553af0469bd9b7d6ac10cd2e6a817 (diff) | |
download | emacs-49bc1a9dfc6e81a370bf12157c3c573743ee200a.tar.gz emacs-49bc1a9dfc6e81a370bf12157c3c573743ee200a.tar.bz2 emacs-49bc1a9dfc6e81a370bf12157c3c573743ee200a.zip |
Merge from trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/.gdbinit | 6 | ||||
-rw-r--r-- | src/ChangeLog | 431 | ||||
-rw-r--r-- | src/alloc.c | 6 | ||||
-rw-r--r-- | src/buffer.c | 593 | ||||
-rw-r--r-- | src/buffer.h | 153 | ||||
-rw-r--r-- | src/callint.c | 4 | ||||
-rw-r--r-- | src/callproc.c | 4 | ||||
-rw-r--r-- | src/casetab.c | 24 | ||||
-rw-r--r-- | src/category.c | 37 | ||||
-rw-r--r-- | src/category.h | 8 | ||||
-rw-r--r-- | src/charset.c | 6 | ||||
-rw-r--r-- | src/chartab.c | 112 | ||||
-rw-r--r-- | src/cmds.c | 2 | ||||
-rw-r--r-- | src/coding.c | 16 | ||||
-rw-r--r-- | src/data.c | 85 | ||||
-rw-r--r-- | src/dispnew.c | 51 | ||||
-rw-r--r-- | src/doc.c | 7 | ||||
-rw-r--r-- | src/doprnt.c | 1 | ||||
-rw-r--r-- | src/dosfns.c | 2 | ||||
-rw-r--r-- | src/editfns.c | 25 | ||||
-rw-r--r-- | src/emacs.c | 4 | ||||
-rw-r--r-- | src/eval.c | 56 | ||||
-rw-r--r-- | src/fileio.c | 53 | ||||
-rw-r--r-- | src/fns.c | 74 | ||||
-rw-r--r-- | src/font.c | 9 | ||||
-rw-r--r-- | src/font.h | 12 | ||||
-rw-r--r-- | src/fontset.c | 4 | ||||
-rw-r--r-- | src/frame.c | 119 | ||||
-rw-r--r-- | src/frame.h | 114 | ||||
-rw-r--r-- | src/gnutls.c | 2 | ||||
-rw-r--r-- | src/gtkutil.c | 15 | ||||
-rw-r--r-- | src/image.c | 34 | ||||
-rw-r--r-- | src/indent.c | 10 | ||||
-rw-r--r-- | src/insdel.c | 20 | ||||
-rw-r--r-- | src/intervals.c | 229 | ||||
-rw-r--r-- | src/intervals.h | 39 | ||||
-rw-r--r-- | src/keyboard.c | 182 | ||||
-rw-r--r-- | src/keyboard.h | 49 | ||||
-rw-r--r-- | src/keymap.c | 2 | ||||
-rw-r--r-- | src/lisp.h | 170 | ||||
-rw-r--r-- | src/lread.c | 8 | ||||
-rw-r--r-- | src/macros.c | 15 | ||||
-rw-r--r-- | src/makefile.w32-in | 14 | ||||
-rw-r--r-- | src/minibuf.c | 14 | ||||
-rw-r--r-- | src/msdos.c | 6 | ||||
-rw-r--r-- | src/nsfns.m | 24 | ||||
-rw-r--r-- | src/nsfont.m | 65 | ||||
-rw-r--r-- | src/nsimage.m | 3 | ||||
-rw-r--r-- | src/nsmenu.m | 47 | ||||
-rw-r--r-- | src/nsterm.h | 9 | ||||
-rw-r--r-- | src/nsterm.m | 340 | ||||
-rw-r--r-- | src/print.c | 22 | ||||
-rw-r--r-- | src/process.c | 302 | ||||
-rw-r--r-- | src/process.h | 27 | ||||
-rw-r--r-- | src/search.c | 12 | ||||
-rw-r--r-- | src/syntax.c | 12 | ||||
-rw-r--r-- | src/sysdep.c | 9 | ||||
-rw-r--r-- | src/term.c | 5 | ||||
-rw-r--r-- | src/termhooks.h | 23 | ||||
-rw-r--r-- | src/terminal.c | 12 | ||||
-rw-r--r-- | src/textprop.c | 26 | ||||
-rw-r--r-- | src/undo.c | 45 | ||||
-rw-r--r-- | src/unexaix.c | 3 | ||||
-rw-r--r-- | src/unexcoff.c | 2 | ||||
-rw-r--r-- | src/vm-limit.c | 2 | ||||
-rw-r--r-- | src/w32.c | 2 | ||||
-rw-r--r-- | src/w32fns.c | 46 | ||||
-rw-r--r-- | src/w32menu.c | 6 | ||||
-rw-r--r-- | src/w32term.c | 20 | ||||
-rw-r--r-- | src/window.c | 985 | ||||
-rw-r--r-- | src/window.h | 91 | ||||
-rw-r--r-- | src/xdisp.c | 258 | ||||
-rw-r--r-- | src/xfaces.c | 57 | ||||
-rw-r--r-- | src/xfns.c | 53 | ||||
-rw-r--r-- | src/xfont.c | 1 | ||||
-rw-r--r-- | src/xftfont.c | 19 | ||||
-rw-r--r-- | src/xmenu.c | 6 | ||||
-rw-r--r-- | src/xselect.c | 9 | ||||
-rw-r--r-- | src/xterm.c | 30 |
79 files changed, 3582 insertions, 1818 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index c0a1bbfffd8..b703842f4cf 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -89,7 +89,7 @@ define pp set $tmp = $arg0 set $output_debug = print_output_debug_flag set print_output_debug_flag = 0 - set safe_debug_print ($tmp) + call safe_debug_print ($tmp) set print_output_debug_flag = $output_debug end document pp @@ -102,7 +102,7 @@ define pv set $tmp = "$arg0" set $output_debug = print_output_debug_flag set print_output_debug_flag = 0 - set safe_debug_print (find_symbol_value (intern ($tmp))) + call safe_debug_print (find_symbol_value (intern ($tmp))) set print_output_debug_flag = $output_debug end document pv @@ -1162,7 +1162,7 @@ end define xwhichsymbols set $output_debug = print_output_debug_flag set print_output_debug_flag = 0 - set safe_debug_print (which_symbols ($arg0, $arg1)) + call safe_debug_print (which_symbols ($arg0, $arg1)) set print_output_debug_flag = $output_debug end document xwhichsymbols diff --git a/src/ChangeLog b/src/ChangeLog index 20e5e4bdfbb..1e25015da20 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,421 @@ +2012-08-20 Dmitry Antipov <dmantipov@yandex.ru> + + Inline setter functions for Lisp_Objects slots of struct specbinding. + * eval.c (set_specpdl_symbol, set_specpdl_old_value): New functions. + Adjust users. + +2012-08-20 Martin Rudalics <rudalics@gmx.at> + + * window.c (select_window): Always make selected window's buffer + current. + +2012-08-20 Dmitry Antipov <dmantipov@yandex.ru> + + Use AREF and ASET for docstrings of category tables. + * category.h (CATEGORY_DOCSTRING): Use AREF. + (SET_CATEGORY_DOCSTRING): Use ASET. + * category.c (Fdefine_category): Use SET_CATEGORY_DOCSTRING. + +2012-08-20 Dmitry Antipov <dmantipov@yandex.ru> + + Inline setter functions for hash table members. + * lisp.h (set_hash_key, set_hash_value, set_hash_next) + (set_hash_hash, set_hash_index): Rename with _slot suffix. + (set_hash_key_and_value, set_hash_index, set_hash_next) + (set_hash_hash): New functions. + * charset.c, fns.c: Adjust users. + +2012-08-20 Dmitry Antipov <dmantipov@yandex.ru> + + Inline getter and setter functions for per-buffer values. + * buffer.h (per_buffer_default, set_per_buffer_default) + (per_buffer_value, set_per_buffer_value): New functions. + (PER_BUFFER_VALUE, PER_BUFFER_DEFAULT): Remove. + * buffer.c, data.c: Adjust users. + +2012-08-20 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/vm-limit.$(O)): Update dependencies. + +2012-08-19 Paul Eggert <eggert@cs.ucla.edu> + + Rely on <config.h> + <unistd.h> to declare 'environ', + as gnulib does this if the system doesn't. + * callproc.c, editfns.c, process.c (environ) [!USE_CRT_DLL]: + * emacs.c (environ) [DOUG_LEA_MALLOC]: + * vm-limit.c (environ) [ORDINARY_LINK]: Remove decl. + * vm-limit.c: Include <unistd.h>, for 'environ'. + + * unexaix.c, unexcoff.c: Include "mem-limits.h". + (start_of_data): Remove decl; mem-limits.h provides it. + + * xdisp.c (handle_invisible_prop): Make it a bit faster + and avoid a gcc -Wmaybe-uninitialized diagnostic. + +2012-08-19 Chong Yidong <cyd@gnu.org> + + * xdisp.c (handle_invisible_prop): Fix ellipses at overlay string + ends (Bug#3874). + +2012-08-19 Andreas Schwab <schwab@linux-m68k.org> + + * .gdbinit: Use call instead of set when calling a function in the + inferior. + + * data.c (set_internal): Don't use set_blv_found. + (Fkill_local_variable): Likewise. + +2012-08-18 Alp Aker <alp.tekin.aker@gmail.com> + + * nsfont.m (ns_ascii_average_width): Ensure the string + ascii_printable is initialized with a null-terminated character + array. Otherwise, it can contain undesired extra characters. + +2012-08-18 Paul Eggert <eggert@cs.ucla.edu> + + port new setting code to Sun C 5.8 2005/10/13 + * chartab.c, lisp.h (char_table_set, char_table_set_range): + Return void, not Lisp_Object. Otherwise, the compiler + complains about (A?B:C) where B is void and C is Lisp_Object + when compiling CHAR_TABLE_SET, due to the recent change to + the API of sub_char_table_set_contents. + +2012-08-18 Chong Yidong <cyd@gnu.org> + + * xdisp.c (handle_invisible_prop): Obey TEXT_PROP_MEANS_INVISIBLE + for the string case (Bug#3874). + +2012-08-18 Paul Eggert <eggert@cs.ucla.edu> + + * buffer.h (BSET): Remove (Bug#12215). + Replace all uses with calls to new setter functions. + (bset_bidi_paragraph_direction, bset_case_canon_table) + (bset_case_eqv_table, bset_directory, bset_display_count) + (bset_display_time, bset_downcase_table) + (bset_enable_multibyte_characters, bset_filename, bset_keymap) + (bset_last_selected_window, bset_local_var_alist) + (bset_mark_active, bset_point_before_scroll, bset_read_only) + (bset_truncate_lines, bset_undo_list, bset_upcase_table) + (bset_width_table): + * buffer.c (bset_abbrev_mode, bset_abbrev_table) + (bset_auto_fill_function, bset_auto_save_file_format) + (bset_auto_save_file_name, bset_backed_up, bset_begv_marker) + (bset_bidi_display_reordering, bset_buffer_file_coding_system) + (bset_cache_long_line_scans, bset_case_fold_search) + (bset_ctl_arrow, bset_cursor_in_non_selected_windows) + (bset_cursor_type, bset_display_table, bset_extra_line_spacing) + (bset_file_format, bset_file_truename, bset_fringe_cursor_alist) + (bset_fringe_indicator_alist, bset_fringes_outside_margins) + (bset_header_line_format, bset_indicate_buffer_boundaries) + (bset_indicate_empty_lines, bset_invisibility_spec) + (bset_left_fringe_width, bset_major_mode, bset_mark) + (bset_minor_modes, bset_mode_line_format, bset_mode_name) + (bset_name, bset_overwrite_mode, bset_pt_marker) + (bset_right_fringe_width, bset_save_length) + (bset_scroll_bar_width, bset_scroll_down_aggressively) + (bset_scroll_up_aggressively, bset_selective_display) + (bset_selective_display_ellipses, bset_vertical_scroll_bar_type) + (bset_word_wrap, bset_zv_marker): + * category.c (bset_category_table): + * syntax.c (bset_syntax_table): + New setter functions. + + * process.h (PSET): Remove (Bug#12215). + Replace all uses with calls to new setter functions. + Use INLINE_HEADER_BEGIN, INLINE_HEADER_END. + (PROCESS_INLINE): New macro. + (pset_childp): New setter function. + (pset_gnutls_cred_type) [HAVE_GNUTLS]: New setter function. + * process.c (PROCESS_INLINE): + Define to EXTERN_INLINE, so that the corresponding functions + are compiled into code. + (pset_buffer, pset_command, pset_decode_coding_system) + (pset_decoding_buf, pset_encode_coding_system) + (pset_encoding_buf, pset_filter, pset_log, pset_mark, pset_name) + (pset_plist, pset_sentinel, pset_status, pset_tty_name) + (pset_type, pset_write_queue): New setter functions. + + * window.h (WSET): Remove (Bug#12215). + Replace all uses with calls to new setter functions. + Use INLINE_HEADER_BEGIN, INLINE_HEADER_END. + (WINDOW_INLINE): New macro. + (wset_buffer, wset_frame, wset_left_col, wset_next, wset_prev) + (wset_redisplay_end_trigger, wset_top_line, wset_total_cols) + (wset_total_lines, wset_vertical_scroll_bar) + (wset_window_end_pos, wset_window_end_valid) + (wset_window_end_vpos): New setter functions. + * window.c (WINDOW_INLINE): + Define to EXTERN_INLINE, so that the corresponding functions + are compiled into code. + (wset_combination_limit, wset_dedicated, wset_display_table) + (wset_hchild, wset_left_fringe_width, wset_left_margin_cols) + (wset_new_normal, wset_new_total, wset_next_buffers) + (wset_normal_cols, wset_normal_lines, wset_parent, wset_pointm) + (wset_prev_buffers, wset_right_fringe_width) + (wset_right_margin_cols, wset_scroll_bar_width, wset_start) + (wset_temslot, wset_vchild, wset_vertical_scroll_bar_type) + (wset_window_parameters): + * xdisp.c (wset_base_line_number, wset_base_line_pos) + (wset_column_number_displayed, wset_region_showing): + New setter functions. + + * termhooks.h (TSET): Remove (Bug#12215). + Replace all uses with calls to new setter functions. + Use INLINE_HEADER_BEGIN, INLINE_HEADER_END. + (TERMHOOKS_INLINE): New macro. + (tset_charset_list, tset_selection_alist): New setter functions. + * terminal.c (TERMHOOKS_INLINE): + Define to EXTERN_INLINE, so that the corresponding functions + are compiled into code. + (tset_param_alist): New setter function. + +2012-08-17 Paul Eggert <eggert@cs.ucla.edu> + + * keyboard.h (KSET): Remove (Bug#12215). + Replace all uses with calls to new setter functions. + Use INLINE_HEADER_BEGIN, INLINE_HEADER_END. + (KEYBOARD_INLINE): New macro. + (kset_default_minibuffer_frame, kset_defining_kbd_macro) + (kset_input_decode_map, kset_last_command, kset_last_kbd_macro) + (kset_prefix_arg, kset_system_key_alist, kset_window_system): + New setter functions. + * keyboard.c (KEYBOARD_INLINE): + Define to EXTERN_INLINE, so that the corresponding functions + are compiled into code. + (kset_echo_string, kset_kbd_queue) + (kset_keyboard_translate_table, kset_last_prefix_arg) + (kset_last_repeatable_command, kset_local_function_key_map) + (kset_overriding_terminal_local_map, kset_real_last_command) + (kset_system_key_syms): New setter functions. + + * frame.h (FSET): Remove (Bug#12215). + Replace all uses with calls to new setter functions. + Use INLINE_HEADER_BEGIN, INLINE_HEADER_END. + (FRAME_INLINE): New macro. + (fset_buffer_list, fset_buried_buffer_list, fset_condemned_scroll_bars) + (fset_current_tool_bar_string, fset_desired_tool_bar_string) + (fset_face_alist, fset_focus_frame, fset_icon_name, fset_menu_bar_items) + (fset_menu_bar_vector, fset_menu_bar_window, fset_name) + (fset_param_alist, fset_root_window, fset_scroll_bars) + (fset_selected_window, fset_title, fset_tool_bar_items) + (fset_tool_bar_position, fset_tool_bar_window): New functions. + * frame.c (FRAME_INLINE): + Define to EXTERN_INLINE, so that the corresponding functions + are compiled into code. + (fset_buffer_predicate, fset_minibuffer_window): New setter functions. + + A few more naming-convention fixes for getters and setters. + * buffer.c (set_buffer_overlays_before): Move here from buffer.h, + and rename from buffer_overlays_set_before. + (set_buffer_overlays_after): Move here from buffer.h, and rename + from buffer_overlays_set_after. + * buffer.h (buffer_intervals): Rename from buffer_get_intervals. + All uses changed. + (set_buffer_intervals): Rename from buffer_set_intervals. + * intervals.c (set_interval_object): Move here from intervals.h, + and rename from interval_set_object. + (set_interval_left): Move here from intervals.h, and rename from + interval_set_left. + (set_interval_right): Move here from intervals.h, and rename from + interval_set_right. + (copy_interval_parent): Move here from intervals.h, and rename from + interval_copy_parent. + * intervals.h (set_interval_parent): Rename from interval_set_parent. + (set_interval_plist): Rename from interval_set_plist. + Return void, not Lisp_Object, since no caller uses the result. + * lisp.h (string_intervals): Rename from string_get_intervals. + (set_string_intervals): Rename from string_set_intervals. + + * lisp.h (set_char_table_extras): Rename from char_table_set_extras. + (set_char_table_contents): Rename from char_table_set_contents. + (set_sub_char_table_contents): Rename from sub_char_table_set_contents. + All uses changed. See the end of + <http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00549.html>. + + * lisp.h (CSET): Remove (Bug#12215). + (set_char_table_ascii, set_char_table_defalt, set_char_table_parent) + (set_char_table_purpose): New functions, + replacing CSET. All uses changed. For example, replace + "CSET (XCHAR_TABLE (char_table), parent, parent);" with + "set_char_table_parent (char_table, parent);". + The old version was confusing because it used the same name + 'parent' for two different things. + +2012-08-17 Dmitry Antipov <dmantipov@yandex.ru> + + Functions to get and set Lisp_Object fields of buffer-local variables. + * lisp.h (blv_found, set_blv_found, blv_value, set_blv_value) + (set_blv_where, set_blv_defcell, set_blv_valcell): New functions. + (BLV_FOUND, SET_BLV_FOUND, BLV_VALUE, SET_BLV_VALUE): Remove. + * data.c, eval.c, frame.c: Adjust users. + +2012-08-17 Chong Yidong <cyd@gnu.org> + + * xfaces.c (merge_face_vectors): If the target font specfies a + font spec, make the font's attributes take precedence over + directly-specified attributes. + (merge_face_ref): Recognize :font. + +2012-08-17 Dmitry Antipov <dmantipov@yandex.ru> + + Do not use memcpy for copying intervals. + * intervals.c (reproduce_interval): New function. + (reproduce_tree, reproduce_tree_obj): Use it. + (reproduce_tree_obj): Remove prototype. + +2012-08-17 Paul Eggert <eggert@cs.ucla.edu> + + * lisp.h (duration_to_sec_usec): Remove unused decl. + +2012-08-17 Alp Aker <alp.tekin.aker@gmail.com> + + * nsfont.m (ns_ascii_average_width): Send initWithFormat selector + to an allocated instance of NSString, not to the class itself. + +2012-08-17 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in (C_CTYPE_H): New macro. + (LISP_H, $(BLD)/ccl.$(O), $(BLD)/doc.$(O), $(BLD)/w32console.$(O)): + ($(BLD)/fontset.$(O), $(BLD)/frame.$(O), $(BLD)/composite.$(O)): + ($(BLD)/sysdep.$(O), $(BLD)/w32uniscribe.$(O)): Update dependencies. + +2012-08-16 Paul Eggert <eggert@cs.ucla.edu> + + Use ASCII tests for character types. + * category.c, dispnew.c, doprnt.c, editfns.c, syntax.c, term.c: + * xfns.c, xterm.c: + Don't include <ctype.h>; was not needed. + * charset.c, doc.c, fileio.c, font.c, frame.c, gtkutil.c, image.c: + * sysdep.c, xfaces.c: + Include <c-ctype.h> instead of <ctype.h>. + * nsterm.m: Include <c-ctype.h>. + * charset.c (read_hex): + * doc.c (Fsnarf_documentation): + * fileio.c (IS_DRIVE) [WINDOWSNT]: + (DRIVE_LETTER) [DOS_NT]: + (Ffile_name_directory, Fexpand_file_name) + (Fsubstitute_in_file_name): + * font.c (font_parse_xlfd, font_parse_fcname): + * frame.c (x_set_font_backend): + * gtkutil.c (xg_get_font): + * image.c (xbm_scan, xpm_scan, pbm_scan_number): + * nsimage.m (hexchar): + * nsterm.m (ns_xlfd_to_fontname): + * sysdep.c (system_process_attributes): + * xfaces.c (hash_string_case_insensitive): + Use C-locale tests instead of locale-specific tests for character + types, since we want the ASCII interpretation here, not the + interpretation suitable for whatever happens to be the current locale. + +2012-08-16 Martin Rudalics <rudalics@gmx.at> + + Consistently check windows for validity/liveness + (Bug#11984, Bug#12025, Bug#12026). + * lisp.h (CHECK_VALID_WINDOW): New macro. + * window.c (decode_window): Rename to decode_live_window. + (decode_valid_window, Fwindow_valid_p): New functions. + (Fwindow_frame, Fframe_root_window, Fwindow_minibuffer_p) + (Fframe_first_window, Fframe_selected_window, Fwindow_parent) + (Fwindow_top_child, Fwindow_left_child, Fwindow_next_sibling) + (Fwindow_prev_sibling, Fwindow_combination_limit) + (Fset_window_combination_limit, Fwindow_use_time) + (Fwindow_total_height, Fwindow_total_width, Fwindow_new_total) + (Fwindow_normal_size, Fwindow_new_normal, Fwindow_left_column) + (Fwindow_top_line, Fwindow_body_height, Fwindow_body_width) + (Fwindow_hscroll, Fset_window_hscroll) + (Fwindow_redisplay_end_trigger) + (Fset_window_redisplay_end_trigger, Fwindow_edges) + (Fwindow_pixel_edges, Fwindow_absolute_pixel_edges) + (Fwindow_inside_edges, Fwindow_inside_pixel_edges) + (Fcoordinates_in_window_p, Fwindow_point, Fwindow_start) + (Fwindow_end, Fset_window_point, Fset_window_start) + (Fpos_visible_in_window_p, Fwindow_line_height) + (Fwindow_dedicated_p, Fset_window_dedicated_p) + (Fwindow_prev_buffers, Fset_window_prev_buffers) + (Fwindow_next_buffers, Fwindow_parameters, Fwindow_parameter) + (Fset_window_parameter, Fwindow_display_table) + (Fset_window_display_table, Fdelete_other_windows_internal) + (Fset_window_buffer, Fset_window_new_total) + (Fset_window_new_normal, Fdelete_window_internal) + (Fwindow_text_height, Fset_window_margins, Fwindow_margins) + (Fset_window_fringes, Fwindow_fringes, Fset_window_scroll_bars) + (Fwindow_scroll_bars): Check whether argument window is a valid or + live window. Update doc-strings. + (syms_of_window): New symbol Qwindow_valid_p. + * keyboard.c (Fposn_at_x_y): Check whether argument + frame_or_window denotes a valid window. + +2012-08-16 Dmitry Antipov <dmantipov@yandex.ru> + + Fix previous char table change. + * lisp.h (CHAR_TABLE_SET): Use sub_char_table_set_contents. + * chartab.c (optimize_sub_char_table): Likewise. + +2012-08-16 Chong Yidong <cyd@gnu.org> + + * gtkutil.c (xg_get_font): Demand an Xft font (Bug#3228). + + * xfont.c (xfont_open): + * xftfont.c (xftfont_open): Set the font's max_width field. + + * nsfont.m (nsfont_open): Similar to the Xft backend, set + min_width to space_width and average_width to the average over + printable ASCII characters. + (ns_char_width): Code cleanup. + (ns_ascii_average_width): New utility function. + + * font.h (struct font): Update comments. + +2012-08-16 Dmitry Antipov <dmantipov@yandex.ru> + + Simple interface to set Lisp_Object fields of character tables. + * lisp.h (CSET): New macro. + (char_table_set_extras, char_table_set_contents) + (sub_char_table_set_contents): New function. + * casetab.c, category.c, chartab.c, fns.c, fontset.c, search.c: + * syntax.c: Adjust users. + +2012-08-16 Stefan Monnier <monnier@iro.umontreal.ca> + + * eval.c (eval_sub): Bind lexical-binding. + * lread.c (Qlexical_binding): Make non-static. + +2012-08-15 Jan Djärv <jan.h.d@swipnet.se> + + * nsmenu.m (popupSession): Remove. + (pop_down_menu): Remove endModalSession. + (timeout_handler:): New method. + (runDialogAt:): Get next timeout. Start a NSTimer with that timeout. + Call runModalForWindow. Check timer_fired when it returns. + If not set, cancel timer and break out of loop. + Otherwise loop again, with a new timeout. + + * nsterm.m: Include fcntl.h if present. + (fd_entry, t_readfds, inNsSelect): Remove. + (select_writefds, select_valid, select_timeout, selfds) + (select_mutex, apploopnr): Add. + (EV_TRAILER): Call kbd_buffer_store_event_hold only if q_event_ptr. + Otherwise call kbd_buffer_store_event. + (ns_send_appdefined): Remove release of fd_entry. + (ns_read_socket): Always send appdefined. Remove inNsSelect check. + Increment and decrement apploopnr. + (ns_select): If no file descriptors, just do a NSTimer. + Otherwise copy read/write masks and start select thread (fd_handler). + Start main loop and wait for application defined event. + Inform select thread to stop selecting after main loop is exited. + (ns_term_init): Create selfds pipe and set non-blocking. + Initialize select_mutex. Start the select thread (fd_handler). + (fd_handler:): Loop forever, wait for info from the main thread + to either start or stop selecting. When select returns, send + and appdefined event. + (sendScrollEventAtLoc:fromEvent:): Check if q_event_ptr is set. + If not call kbd_buffer_store_event. + + * nsterm.h (EmacsApp): fd_handler takes id argument. + (EmacsDialogPanel): Add timer_fired and timeout_handler. + + * gtkutil.c (xg_mark_data): Use FRAME_X_P. + 2012-08-15 Eli Zaretskii <eliz@gnu.org> * region-cache.c (move_cache_gap): Update gap_len using the actual @@ -8,8 +426,8 @@ Generalize and cleanup font subsystem checks. * font.h (FONT_DEBUG, font_assert): Remove. - * font.c, fontset.c, w32font.c, xfont.c, xftfont.c: Change - font_assert to eassert. Use eassert where appropriate. + * font.c, fontset.c, w32font.c, xfont.c, xftfont.c: + Change font_assert to eassert. Use eassert where appropriate. 2012-08-15 Dmitry Antipov <dmantipov@yandex.ru> @@ -17,10 +435,10 @@ 2012-08-15 Chong Yidong <cyd@gnu.org> - * gtkutil.c (xg_get_font): Rename from xg_get_font_name. When - using the new font chooser, use gtk_font_chooser_get_font_desc to - extract the font descriptor instead of just the font name. In - that case, return a font spec instead of a string. + * gtkutil.c (xg_get_font): Rename from xg_get_font_name. + When using the new font chooser, use gtk_font_chooser_get_font_desc to + extract the font descriptor instead of just the font name. + In that case, return a font spec instead of a string. (x_last_font_name): Move to this file from xfns.c. * xfns.c (Fx_select_font): The return value can also be a font @@ -3302,6 +3720,7 @@ has at least microseconds now. All uses removed. (update_frame, update_single_window, update_window, update_frame_1) (Fsleep_for, sit_for): Port to higher-resolution time stamps. + (duration_to_sec_usec): Remove; no longer needed. * editfns.c (time_overflow): Now extern. (Fcurrent_time, Fget_internal_run_time, make_time, lisp_time_argument) diff --git a/src/alloc.c b/src/alloc.c index 19b77d567d0..a8830684580 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5809,7 +5809,7 @@ mark_buffer (struct buffer *buffer) /* ...but there are some buffer-specific things. */ - MARK_INTERVAL_TREE (buffer_get_intervals (buffer)); + MARK_INTERVAL_TREE (buffer_intervals (buffer)); /* For now, we just don't mark the undo_list. It's done later in a special way just before the sweep phase, and after stripping @@ -6063,7 +6063,7 @@ mark_object (Lisp_Object arg) } if (!PURE_POINTER_P (XSTRING (ptr->name))) MARK_STRING (XSTRING (ptr->name)); - MARK_INTERVAL_TREE (string_get_intervals (ptr->name)); + MARK_INTERVAL_TREE (string_intervals (ptr->name)); ptr = ptr->next; if (ptr) @@ -6378,7 +6378,7 @@ gc_sweep (void) { if (!iblk->intervals[i].gcmarkbit) { - interval_set_parent (&iblk->intervals[i], interval_free_list); + set_interval_parent (&iblk->intervals[i], interval_free_list); interval_free_list = &iblk->intervals[i]; this_free++; } diff --git a/src/buffer.c b/src/buffer.c index 7fb1029a314..6f748158e21 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -155,6 +155,228 @@ static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); static Lisp_Object buffer_lisp_local_variables (struct buffer *, int); +/* These setters are used only in this file, so they can be private. */ +static inline void +bset_abbrev_mode (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (abbrev_mode) = val; +} +static inline void +bset_abbrev_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (abbrev_table) = val; +} +static inline void +bset_auto_fill_function (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (auto_fill_function) = val; +} +static inline void +bset_auto_save_file_format (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (auto_save_file_format) = val; +} +static inline void +bset_auto_save_file_name (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (auto_save_file_name) = val; +} +static inline void +bset_backed_up (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (backed_up) = val; +} +static inline void +bset_begv_marker (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (begv_marker) = val; +} +static inline void +bset_bidi_display_reordering (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (bidi_display_reordering) = val; +} +static inline void +bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (buffer_file_coding_system) = val; +} +static inline void +bset_cache_long_line_scans (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (cache_long_line_scans) = val; +} +static inline void +bset_case_fold_search (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (case_fold_search) = val; +} +static inline void +bset_ctl_arrow (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (ctl_arrow) = val; +} +static inline void +bset_cursor_in_non_selected_windows (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (cursor_in_non_selected_windows) = val; +} +static inline void +bset_cursor_type (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (cursor_type) = val; +} +static inline void +bset_display_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (display_table) = val; +} +static inline void +bset_extra_line_spacing (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (extra_line_spacing) = val; +} +static inline void +bset_file_format (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (file_format) = val; +} +static inline void +bset_file_truename (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (file_truename) = val; +} +static inline void +bset_fringe_cursor_alist (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (fringe_cursor_alist) = val; +} +static inline void +bset_fringe_indicator_alist (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (fringe_indicator_alist) = val; +} +static inline void +bset_fringes_outside_margins (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (fringes_outside_margins) = val; +} +static inline void +bset_header_line_format (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (header_line_format) = val; +} +static inline void +bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (indicate_buffer_boundaries) = val; +} +static inline void +bset_indicate_empty_lines (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (indicate_empty_lines) = val; +} +static inline void +bset_invisibility_spec (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (invisibility_spec) = val; +} +static inline void +bset_left_fringe_width (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (left_fringe_width) = val; +} +static inline void +bset_major_mode (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (major_mode) = val; +} +static inline void +bset_mark (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (mark) = val; +} +static inline void +bset_minor_modes (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (minor_modes) = val; +} +static inline void +bset_mode_line_format (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (mode_line_format) = val; +} +static inline void +bset_mode_name (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (mode_name) = val; +} +static inline void +bset_name (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (name) = val; +} +static inline void +bset_overwrite_mode (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (overwrite_mode) = val; +} +static inline void +bset_pt_marker (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (pt_marker) = val; +} +static inline void +bset_right_fringe_width (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (right_fringe_width) = val; +} +static inline void +bset_save_length (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (save_length) = val; +} +static inline void +bset_scroll_bar_width (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (scroll_bar_width) = val; +} +static inline void +bset_scroll_down_aggressively (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (scroll_down_aggressively) = val; +} +static inline void +bset_scroll_up_aggressively (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (scroll_up_aggressively) = val; +} +static inline void +bset_selective_display (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (selective_display) = val; +} +static inline void +bset_selective_display_ellipses (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (selective_display_ellipses) = val; +} +static inline void +bset_vertical_scroll_bar_type (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (vertical_scroll_bar_type) = val; +} +static inline void +bset_word_wrap (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (word_wrap) = val; +} +static inline void +bset_zv_marker (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (zv_marker) = val; +} + /* For debugging; temporary. See set_buffer_internal. */ /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ @@ -358,7 +580,7 @@ even if it is dead. The return value is never nil. */) BUF_CHARS_MODIFF (b) = 1; BUF_OVERLAY_MODIFF (b) = 1; BUF_SAVE_MODIFF (b) = 1; - buffer_set_intervals (b, NULL); + set_buffer_intervals (b, NULL); BUF_UNCHANGED_MODIFIED (b) = 1; BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; BUF_END_UNCHANGED (b) = 0; @@ -368,7 +590,7 @@ even if it is dead. The return value is never nil. */) b->newline_cache = 0; b->width_run_cache = 0; - BSET (b, width_table, Qnil); + bset_width_table (b, Qnil); b->prevent_redisplay_optimizations_p = 1; /* Put this on the chain of all buffers including killed ones. */ @@ -377,20 +599,20 @@ even if it is dead. The return value is never nil. */) /* An ordinary buffer normally doesn't need markers to handle BEGV and ZV. */ - BSET (b, pt_marker, Qnil); - BSET (b, begv_marker, Qnil); - BSET (b, zv_marker, Qnil); + bset_pt_marker (b, Qnil); + bset_begv_marker (b, Qnil); + bset_zv_marker (b, Qnil); name = Fcopy_sequence (buffer_or_name); - string_set_intervals (name, NULL); - BSET (b, name, name); + set_string_intervals (name, NULL); + bset_name (b, name); - BSET (b, undo_list, (SREF (name, 0) != ' ') ? Qnil : Qt); + bset_undo_list (b, SREF (name, 0) != ' ' ? Qnil : Qt); reset_buffer (b); reset_buffer_local_variables (b, 1); - BSET (b, mark, Fmake_marker ()); + bset_mark (b, Fmake_marker ()); BUF_MARKERS (b) = NULL; /* Put this in the alist of all live buffers. */ @@ -437,6 +659,19 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list) return result; } +/* Set an appropriate overlay of B. */ + +static inline void +set_buffer_overlays_before (struct buffer *b, struct Lisp_Overlay *o) +{ + b->overlays_before = o; +} + +static inline void +set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o) +{ + b->overlays_after = o; +} /* Clone per-buffer values of buffer FROM. @@ -458,7 +693,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) if (offset == PER_BUFFER_VAR_OFFSET (name)) continue; - obj = PER_BUFFER_VALUE (from, offset); + obj = per_buffer_value (from, offset); if (MARKERP (obj) && XMARKER (obj)->buffer == from) { struct Lisp_Marker *m = XMARKER (obj); @@ -467,17 +702,17 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) XMARKER (obj)->insertion_type = m->insertion_type; } - PER_BUFFER_VALUE (to, offset) = obj; + set_per_buffer_value (to, offset, obj); } memcpy (to->local_flags, from->local_flags, sizeof to->local_flags); - buffer_set_overlays_before (to, copy_overlays (to, from->overlays_before)); - buffer_set_overlays_after (to, copy_overlays (to, from->overlays_after)); + set_buffer_overlays_before (to, copy_overlays (to, from->overlays_before)); + set_buffer_overlays_after (to, copy_overlays (to, from->overlays_after)); /* Get (a copy of) the alist of Lisp-level local variables of FROM and install that in TO. */ - BSET (to, local_var_alist, buffer_lisp_local_variables (from, 1)); + bset_local_var_alist (to, buffer_lisp_local_variables (from, 1)); } @@ -580,15 +815,15 @@ CLONE nil means the indirect buffer's state is reset to default values. */) b->newline_cache = 0; b->width_run_cache = 0; - BSET (b, width_table, Qnil); + bset_width_table (b, Qnil); /* Put this on the chain of all buffers including killed ones. */ b->header.next.buffer = all_buffers; all_buffers = b; name = Fcopy_sequence (name); - string_set_intervals (name, NULL); - BSET (b, name, name); + set_string_intervals (name, NULL); + bset_name (b, name); reset_buffer (b); reset_buffer_local_variables (b, 1); @@ -597,10 +832,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */) XSETBUFFER (buf, b); Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); - BSET (b, mark, Fmake_marker ()); + bset_mark (b, Fmake_marker ()); /* The multibyte status belongs to the base buffer. */ - BSET (b, enable_multibyte_characters, BVAR (b->base_buffer, enable_multibyte_characters)); + bset_enable_multibyte_characters + (b, BVAR (b->base_buffer, enable_multibyte_characters)); /* Make sure the base buffer has markers for its narrowing. */ if (NILP (BVAR (b->base_buffer, pt_marker))) @@ -608,14 +844,17 @@ CLONE nil means the indirect buffer's state is reset to default values. */) eassert (NILP (BVAR (b->base_buffer, begv_marker))); eassert (NILP (BVAR (b->base_buffer, zv_marker))); - BSET (b->base_buffer, pt_marker, - build_marker (b->base_buffer, b->base_buffer->pt, b->base_buffer->pt_byte)); + bset_pt_marker (b->base_buffer, + build_marker (b->base_buffer, b->base_buffer->pt, + b->base_buffer->pt_byte)); - BSET (b->base_buffer, begv_marker, - build_marker (b->base_buffer, b->base_buffer->begv, b->base_buffer->begv_byte)); + bset_begv_marker (b->base_buffer, + build_marker (b->base_buffer, b->base_buffer->begv, + b->base_buffer->begv_byte)); - BSET (b->base_buffer, zv_marker, - build_marker (b->base_buffer, b->base_buffer->zv, b->base_buffer->zv_byte)); + bset_zv_marker (b->base_buffer, + build_marker (b->base_buffer, b->base_buffer->zv, + b->base_buffer->zv_byte)); XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1; } @@ -623,9 +862,9 @@ CLONE nil means the indirect buffer's state is reset to default values. */) if (NILP (clone)) { /* Give the indirect buffer markers for its narrowing. */ - BSET (b, pt_marker, build_marker (b, b->pt, b->pt_byte)); - BSET (b, begv_marker, build_marker (b, b->begv, b->begv_byte)); - BSET (b, zv_marker, build_marker (b, b->zv, b->zv_byte)); + bset_pt_marker (b, build_marker (b, b->pt, b->pt_byte)); + bset_begv_marker (b, build_marker (b, b->begv, b->begv_byte)); + bset_zv_marker (b, build_marker (b, b->zv, b->zv_byte)); XMARKER (BVAR (b, zv_marker))->insertion_type = 1; } else @@ -633,11 +872,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */) struct buffer *old_b = current_buffer; clone_per_buffer_values (b->base_buffer, b); - BSET (b, filename, Qnil); - BSET (b, file_truename, Qnil); - BSET (b, display_count, make_number (0)); - BSET (b, backed_up, Qnil); - BSET (b, auto_save_file_name, Qnil); + bset_filename (b, Qnil); + bset_file_truename (b, Qnil); + bset_display_count (b, make_number (0)); + bset_backed_up (b, Qnil); + bset_auto_save_file_name (b, Qnil); set_buffer_internal_1 (b); Fset (intern ("buffer-save-without-query"), Qnil); Fset (intern ("buffer-file-number"), Qnil); @@ -686,8 +925,8 @@ delete_all_overlays (struct buffer *b) ov->next = NULL; } - buffer_set_overlays_before (b, NULL); - buffer_set_overlays_after (b, NULL); + set_buffer_overlays_before (b, NULL); + set_buffer_overlays_after (b, NULL); } /* Reinitialize everything about a buffer except its name and contents @@ -700,10 +939,9 @@ delete_all_overlays (struct buffer *b) void reset_buffer (register struct buffer *b) { - BSET (b, filename, Qnil); - BSET (b, file_truename, Qnil); - BSET (b, directory, - (current_buffer) ? BVAR (current_buffer, directory) : Qnil); + bset_filename (b, Qnil); + bset_file_truename (b, Qnil); + bset_directory (b, current_buffer ? BVAR (current_buffer, directory) : Qnil); b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); b->modtime_size = -1; XSETFASTINT (BVAR (b, save_length), 0); @@ -711,25 +949,25 @@ reset_buffer (register struct buffer *b) /* It is more conservative to start out "changed" than "unchanged". */ b->clip_changed = 0; b->prevent_redisplay_optimizations_p = 1; - BSET (b, backed_up, Qnil); + bset_backed_up (b, Qnil); BUF_AUTOSAVE_MODIFF (b) = 0; b->auto_save_failure_time = 0; - BSET (b, auto_save_file_name, Qnil); - BSET (b, read_only, Qnil); - buffer_set_overlays_before (b, NULL); - buffer_set_overlays_after (b, NULL); + bset_auto_save_file_name (b, Qnil); + bset_read_only (b, Qnil); + set_buffer_overlays_before (b, NULL); + set_buffer_overlays_after (b, NULL); b->overlay_center = BEG; - BSET (b, mark_active, Qnil); - BSET (b, point_before_scroll, Qnil); - BSET (b, file_format, Qnil); - BSET (b, auto_save_file_format, Qt); - BSET (b, last_selected_window, Qnil); - BSET (b, display_count, make_number (0)); - BSET (b, display_time, Qnil); - BSET (b, enable_multibyte_characters, - BVAR (&buffer_defaults, enable_multibyte_characters)); - BSET (b, cursor_type, BVAR (&buffer_defaults, cursor_type)); - BSET (b, extra_line_spacing, BVAR (&buffer_defaults, extra_line_spacing)); + bset_mark_active (b, Qnil); + bset_point_before_scroll (b, Qnil); + bset_file_format (b, Qnil); + bset_auto_save_file_format (b, Qt); + bset_last_selected_window (b, Qnil); + bset_display_count (b, make_number (0)); + bset_display_time (b, Qnil); + bset_enable_multibyte_characters + (b, BVAR (&buffer_defaults, enable_multibyte_characters)); + bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type)); + bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing)); b->display_error_modiff = 0; } @@ -753,10 +991,10 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) things that depend on the major mode. default-major-mode is handled at a higher level. We ignore it here. */ - BSET (b, major_mode, Qfundamental_mode); - BSET (b, keymap, Qnil); - BSET (b, mode_name, QSFundamental); - BSET (b, minor_modes, Qnil); + bset_major_mode (b, Qfundamental_mode); + bset_keymap (b, Qnil); + bset_mode_name (b, QSFundamental); + bset_minor_modes (b, Qnil); /* If the standard case table has been altered and invalidated, fix up its insides first. */ @@ -765,15 +1003,15 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) && CHAR_TABLE_P (XCHAR_TABLE (Vascii_downcase_table)->extras[2]))) Fset_standard_case_table (Vascii_downcase_table); - BSET (b, downcase_table, Vascii_downcase_table); - BSET (b, upcase_table, XCHAR_TABLE (Vascii_downcase_table)->extras[0]); - BSET (b, case_canon_table, XCHAR_TABLE (Vascii_downcase_table)->extras[1]); - BSET (b, case_eqv_table, XCHAR_TABLE (Vascii_downcase_table)->extras[2]); - BSET (b, invisibility_spec, Qt); + bset_downcase_table (b, Vascii_downcase_table); + bset_upcase_table (b, XCHAR_TABLE (Vascii_downcase_table)->extras[0]); + bset_case_canon_table (b, XCHAR_TABLE (Vascii_downcase_table)->extras[1]); + bset_case_eqv_table (b, XCHAR_TABLE (Vascii_downcase_table)->extras[2]); + bset_invisibility_spec (b, Qt); /* Reset all (or most) per-buffer variables to their defaults. */ if (permanent_too) - BSET (b, local_var_alist, Qnil); + bset_local_var_alist (b, Qnil); else { Lisp_Object tmp, prop, last = Qnil; @@ -807,7 +1045,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) } /* Delete this local variable. */ else if (NILP (last)) - BSET (b, local_var_alist, XCDR (tmp)); + bset_local_var_alist (b, XCDR (tmp)); else XSETCDR (last, XCDR (tmp)); } @@ -823,7 +1061,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) if ((idx > 0 && (permanent_too || buffer_permanent_local_flags[idx] == 0))) - PER_BUFFER_VALUE (b, offset) = PER_BUFFER_DEFAULT (offset); + set_per_buffer_value (b, offset, per_buffer_default (offset)); } } @@ -999,7 +1237,7 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer) { union Lisp_Fwd *fwd = SYMBOL_FWD (sym); if (BUFFER_OBJFWDP (fwd)) - result = PER_BUFFER_VALUE (buf, XBUFFER_OBJFWD (fwd)->offset); + result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset); else result = Fdefault_value (variable); break; @@ -1079,7 +1317,7 @@ No argument or nil as argument means use current buffer as BUFFER. */) && SYMBOLP (PER_BUFFER_SYMBOL (offset))) { Lisp_Object sym = PER_BUFFER_SYMBOL (offset); - Lisp_Object val = PER_BUFFER_VALUE (buf, offset); + Lisp_Object val = per_buffer_value (buf, offset); result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val), result); } @@ -1284,7 +1522,7 @@ This does not change the name of the visited file (if any). */) error ("Buffer name `%s' is in use", SDATA (newname)); } - BSET (current_buffer, name, newname); + bset_name (current_buffer, newname); /* Catch redisplay's attention. Unless we do this, the mode lines for any windows displaying current_buffer will stay unchanged. */ @@ -1429,7 +1667,7 @@ No argument or nil as argument means do this for the current buffer. */) } if (EQ (BVAR (XBUFFER (real_buffer), undo_list), Qt)) - BSET (XBUFFER (real_buffer), undo_list, Qnil); + bset_undo_list (XBUFFER (real_buffer), Qnil); return Qnil; } @@ -1689,7 +1927,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) m = next; } BUF_MARKERS (b) = NULL; - buffer_set_intervals (b, NULL); + set_buffer_intervals (b, NULL); /* Perhaps we should explicitly free the interval tree here... */ } @@ -1701,7 +1939,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) swap_out_buffer_local_variables (b); reset_buffer_local_variables (b, 1); - BSET (b, name, Qnil); + bset_name (b, Qnil); BLOCK_INPUT; if (b->base_buffer) @@ -1725,9 +1963,9 @@ cleaning up all windows currently displaying the buffer to be killed. */) free_region_cache (b->width_run_cache); b->width_run_cache = 0; } - BSET (b, width_table, Qnil); + bset_width_table (b, Qnil); UNBLOCK_INPUT; - BSET (b, undo_list, Qnil); + bset_undo_list (b, Qnil); /* Run buffer-list-update-hook. */ if (!NILP (Vrun_hooks)) @@ -1768,8 +2006,8 @@ record_buffer (Lisp_Object buffer) Vinhibit_quit = tem; /* Update buffer list of selected frame. */ - FSET (f, buffer_list, Fcons (buffer, Fdelq (buffer, f->buffer_list))); - FSET (f, buried_buffer_list, Fdelq (buffer, f->buried_buffer_list)); + fset_buffer_list (f, Fcons (buffer, Fdelq (buffer, f->buffer_list))); + fset_buried_buffer_list (f, Fdelq (buffer, f->buried_buffer_list)); /* Run buffer-list-update-hook. */ if (!NILP (Vrun_hooks)) @@ -1806,9 +2044,9 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal, Vinhibit_quit = tem; /* Update buffer lists of selected frame. */ - FSET (f, buffer_list, Fdelq (buffer, f->buffer_list)); - FSET (f, buried_buffer_list, - Fcons (buffer, Fdelq (buffer, f->buried_buffer_list))); + fset_buffer_list (f, Fdelq (buffer, f->buffer_list)); + fset_buried_buffer_list + (f, Fcons (buffer, Fdelq (buffer, f->buried_buffer_list))); /* Run buffer-list-update-hook. */ if (!NILP (Vrun_hooks)) @@ -1908,7 +2146,7 @@ set_buffer_internal_1 (register struct buffer *b) /* Put the undo list back in the base buffer, so that it appears that an indirect buffer shares the undo list of its base. */ if (old_buf->base_buffer) - BSET (old_buf->base_buffer, undo_list, BVAR (old_buf, undo_list)); + bset_undo_list (old_buf->base_buffer, BVAR (old_buf, undo_list)); /* If the old current buffer has markers to record PT, BEGV and ZV when it is not current, update them now. */ @@ -1918,7 +2156,7 @@ set_buffer_internal_1 (register struct buffer *b) /* Get the undo list from the base buffer, so that it appears that an indirect buffer shares the undo list of its base. */ if (b->base_buffer) - BSET (b, undo_list, BVAR (b->base_buffer, undo_list)); + bset_undo_list (b, BVAR (b->base_buffer, undo_list)); /* If the new current buffer has markers to record PT, BEGV and ZV when it is not current, fetch them now. */ @@ -2116,8 +2354,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, #define swapfield_(field, type) \ do { \ type tmp##field = BVAR (other_buffer, field); \ - BSET (other_buffer, field, BVAR (current_buffer, field)); \ - BSET (current_buffer, field, tmp##field); \ + bset_##field (other_buffer, BVAR (current_buffer, field)); \ + bset_##field (current_buffer, tmp##field); \ } while (0) swapfield (own_text, struct buffer_text); @@ -2157,8 +2395,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, swapfield_ (pt_marker, Lisp_Object); swapfield_ (begv_marker, Lisp_Object); swapfield_ (zv_marker, Lisp_Object); - BSET (current_buffer, point_before_scroll, Qnil); - BSET (other_buffer, point_before_scroll, Qnil); + bset_point_before_scroll (current_buffer, Qnil); + bset_point_before_scroll (other_buffer, Qnil); current_buffer->text->modiff++; other_buffer->text->modiff++; current_buffer->text->chars_modiff++; other_buffer->text->chars_modiff++; @@ -2247,7 +2485,7 @@ current buffer is cleared. */) /* Don't record these buffer changes. We will put a special undo entry instead. */ - BSET (current_buffer, undo_list, Qt); + bset_undo_list (current_buffer, Qt); /* If the cached position is for this buffer, clear it out. */ clear_charpos_cache (current_buffer); @@ -2269,7 +2507,7 @@ current buffer is cleared. */) to calculate the old correspondences. */ set_intervals_multibyte (0); - BSET (current_buffer, enable_multibyte_characters, Qnil); + bset_enable_multibyte_characters (current_buffer, Qnil); Z = Z_BYTE; BEGV = BEGV_BYTE; @@ -2407,7 +2645,7 @@ current buffer is cleared. */) /* Do this first, so that chars_in_text asks the right question. set_intervals_multibyte needs it too. */ - BSET (current_buffer, enable_multibyte_characters, Qt); + bset_enable_multibyte_characters (current_buffer, Qt); GPT_BYTE = advance_to_char_boundary (GPT_BYTE); GPT = chars_in_text (BEG_ADDR, GPT_BYTE - BEG_BYTE) + BEG; @@ -2465,11 +2703,11 @@ current buffer is cleared. */) if (!EQ (old_undo, Qt)) { /* Represent all the above changes by a special undo entry. */ - BSET (current_buffer, undo_list, - Fcons (list3 (Qapply, - intern ("set-buffer-multibyte"), - NILP (flag) ? Qt : Qnil), - old_undo)); + bset_undo_list (current_buffer, + Fcons (list3 (Qapply, + intern ("set-buffer-multibyte"), + NILP (flag) ? Qt : Qnil), + old_undo)); } UNGCPRO; @@ -3236,7 +3474,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) if (prev) prev->next = next; else - buffer_set_overlays_before (buf, next); + set_buffer_overlays_before (buf, next); /* Search thru overlays_after for where to put it. */ other_prev = NULL; @@ -3258,7 +3496,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) if (other_prev) other_prev->next = tail; else - buffer_set_overlays_after (buf, tail); + set_buffer_overlays_after (buf, tail); tail = prev; } else @@ -3294,7 +3532,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) if (prev) prev->next = next; else - buffer_set_overlays_after (buf, next); + set_buffer_overlays_after (buf, next); /* Search thru overlays_before for where to put it. */ other_prev = NULL; @@ -3316,7 +3554,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) if (other_prev) other_prev->next = tail; else - buffer_set_overlays_before (buf, tail); + set_buffer_overlays_before (buf, tail); tail = prev; } } @@ -3421,7 +3659,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) beforep = tail; } if (!parent) - buffer_set_overlays_before (current_buffer, tail->next); + set_buffer_overlays_before (current_buffer, tail->next); else parent->next = tail->next; tail = tail->next; @@ -3467,7 +3705,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) beforep = tail; } if (!parent) - buffer_set_overlays_after (current_buffer, tail->next); + set_buffer_overlays_after (current_buffer, tail->next); else parent->next = tail->next; tail = tail->next; @@ -3481,14 +3719,14 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) if (beforep) { beforep->next = current_buffer->overlays_before; - buffer_set_overlays_before (current_buffer, before_list); + set_buffer_overlays_before (current_buffer, before_list); } recenter_overlay_lists (current_buffer, current_buffer->overlay_center); if (afterp) { afterp->next = current_buffer->overlays_after; - buffer_set_overlays_after (current_buffer, after_list); + set_buffer_overlays_after (current_buffer, after_list); } recenter_overlay_lists (current_buffer, current_buffer->overlay_center); } @@ -3565,7 +3803,7 @@ fix_overlays_before (struct buffer *bp, ptrdiff_t prev, ptrdiff_t pos) if (!right_pair) { found->next = bp->overlays_before; - buffer_set_overlays_before (bp, found); + set_buffer_overlays_before (bp, found); } else { @@ -3643,13 +3881,13 @@ for the rear of the overlay advance when text is inserted there { if (b->overlays_after) XOVERLAY (overlay)->next = b->overlays_after; - buffer_set_overlays_after (b, XOVERLAY (overlay)); + set_buffer_overlays_after (b, XOVERLAY (overlay)); } else { if (b->overlays_before) XOVERLAY (overlay)->next = b->overlays_before; - buffer_set_overlays_before (b, XOVERLAY (overlay)); + set_buffer_overlays_before (b, XOVERLAY (overlay)); } /* This puts it in the right list, and in the right order. */ @@ -3714,8 +3952,8 @@ unchain_both (struct buffer *b, Lisp_Object overlay) { struct Lisp_Overlay *ov = XOVERLAY (overlay); - buffer_set_overlays_before (b, unchain_overlay (b->overlays_before, ov)); - buffer_set_overlays_after (b, unchain_overlay (b->overlays_after, ov)); + set_buffer_overlays_before (b, unchain_overlay (b->overlays_before, ov)); + set_buffer_overlays_after (b, unchain_overlay (b->overlays_after, ov)); eassert (XOVERLAY (overlay)->next == NULL); } @@ -3810,12 +4048,12 @@ buffer. */) if (n_end < b->overlay_center) { XOVERLAY (overlay)->next = b->overlays_after; - buffer_set_overlays_after (b, XOVERLAY (overlay)); + set_buffer_overlays_after (b, XOVERLAY (overlay)); } else { XOVERLAY (overlay)->next = b->overlays_before; - buffer_set_overlays_before (b, XOVERLAY (overlay)); + set_buffer_overlays_before (b, XOVERLAY (overlay)); } /* This puts it in the right list, and in the right order. */ @@ -4911,8 +5149,8 @@ init_buffer_once (void) /* No one will share the text with these buffers, but let's play it safe. */ buffer_defaults.indirections = 0; buffer_local_symbols.indirections = 0; - buffer_set_intervals (&buffer_defaults, NULL); - buffer_set_intervals (&buffer_local_symbols, NULL); + set_buffer_intervals (&buffer_defaults, NULL); + set_buffer_intervals (&buffer_local_symbols, NULL); XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); XSETBUFFER (Vbuffer_defaults, &buffer_defaults); XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); @@ -4922,55 +5160,55 @@ init_buffer_once (void) /* Must do these before making the first buffer! */ /* real setup is done in bindings.el */ - BSET (&buffer_defaults, mode_line_format, build_pure_c_string ("%-")); - BSET (&buffer_defaults, header_line_format, Qnil); - BSET (&buffer_defaults, abbrev_mode, Qnil); - BSET (&buffer_defaults, overwrite_mode, Qnil); - BSET (&buffer_defaults, case_fold_search, Qt); - BSET (&buffer_defaults, auto_fill_function, Qnil); - BSET (&buffer_defaults, selective_display, Qnil); - BSET (&buffer_defaults, selective_display_ellipses, Qt); - BSET (&buffer_defaults, abbrev_table, Qnil); - BSET (&buffer_defaults, display_table, Qnil); - BSET (&buffer_defaults, undo_list, Qnil); - BSET (&buffer_defaults, mark_active, Qnil); - BSET (&buffer_defaults, file_format, Qnil); - BSET (&buffer_defaults, auto_save_file_format, Qt); - buffer_set_overlays_before (&buffer_defaults, NULL); - buffer_set_overlays_after (&buffer_defaults, NULL); + bset_mode_line_format (&buffer_defaults, build_pure_c_string ("%-")); + bset_header_line_format (&buffer_defaults, Qnil); + bset_abbrev_mode (&buffer_defaults, Qnil); + bset_overwrite_mode (&buffer_defaults, Qnil); + bset_case_fold_search (&buffer_defaults, Qt); + bset_auto_fill_function (&buffer_defaults, Qnil); + bset_selective_display (&buffer_defaults, Qnil); + bset_selective_display_ellipses (&buffer_defaults, Qt); + bset_abbrev_table (&buffer_defaults, Qnil); + bset_display_table (&buffer_defaults, Qnil); + bset_undo_list (&buffer_defaults, Qnil); + bset_mark_active (&buffer_defaults, Qnil); + bset_file_format (&buffer_defaults, Qnil); + bset_auto_save_file_format (&buffer_defaults, Qt); + set_buffer_overlays_before (&buffer_defaults, NULL); + set_buffer_overlays_after (&buffer_defaults, NULL); buffer_defaults.overlay_center = BEG; XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8); - BSET (&buffer_defaults, truncate_lines, Qnil); - BSET (&buffer_defaults, word_wrap, Qnil); - BSET (&buffer_defaults, ctl_arrow, Qt); - BSET (&buffer_defaults, bidi_display_reordering, Qt); - BSET (&buffer_defaults, bidi_paragraph_direction, Qnil); - BSET (&buffer_defaults, cursor_type, Qt); - BSET (&buffer_defaults, extra_line_spacing, Qnil); - BSET (&buffer_defaults, cursor_in_non_selected_windows, Qt); - - BSET (&buffer_defaults, enable_multibyte_characters, Qt); - BSET (&buffer_defaults, buffer_file_coding_system, Qnil); + bset_truncate_lines (&buffer_defaults, Qnil); + bset_word_wrap (&buffer_defaults, Qnil); + bset_ctl_arrow (&buffer_defaults, Qt); + bset_bidi_display_reordering (&buffer_defaults, Qt); + bset_bidi_paragraph_direction (&buffer_defaults, Qnil); + bset_cursor_type (&buffer_defaults, Qt); + bset_extra_line_spacing (&buffer_defaults, Qnil); + bset_cursor_in_non_selected_windows (&buffer_defaults, Qt); + + bset_enable_multibyte_characters (&buffer_defaults, Qt); + bset_buffer_file_coding_system (&buffer_defaults, Qnil); XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); - BSET (&buffer_defaults, cache_long_line_scans, Qnil); - BSET (&buffer_defaults, file_truename, Qnil); + bset_cache_long_line_scans (&buffer_defaults, Qnil); + bset_file_truename (&buffer_defaults, Qnil); XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0); - BSET (&buffer_defaults, left_fringe_width, Qnil); - BSET (&buffer_defaults, right_fringe_width, Qnil); - BSET (&buffer_defaults, fringes_outside_margins, Qnil); - BSET (&buffer_defaults, scroll_bar_width, Qnil); - BSET (&buffer_defaults, vertical_scroll_bar_type, Qt); - BSET (&buffer_defaults, indicate_empty_lines, Qnil); - BSET (&buffer_defaults, indicate_buffer_boundaries, Qnil); - BSET (&buffer_defaults, fringe_indicator_alist, Qnil); - BSET (&buffer_defaults, fringe_cursor_alist, Qnil); - BSET (&buffer_defaults, scroll_up_aggressively, Qnil); - BSET (&buffer_defaults, scroll_down_aggressively, Qnil); - BSET (&buffer_defaults, display_time, Qnil); + bset_left_fringe_width (&buffer_defaults, Qnil); + bset_right_fringe_width (&buffer_defaults, Qnil); + bset_fringes_outside_margins (&buffer_defaults, Qnil); + bset_scroll_bar_width (&buffer_defaults, Qnil); + bset_vertical_scroll_bar_type (&buffer_defaults, Qt); + bset_indicate_empty_lines (&buffer_defaults, Qnil); + bset_indicate_buffer_boundaries (&buffer_defaults, Qnil); + bset_fringe_indicator_alist (&buffer_defaults, Qnil); + bset_fringe_cursor_alist (&buffer_defaults, Qnil); + bset_scroll_up_aggressively (&buffer_defaults, Qnil); + bset_scroll_down_aggressively (&buffer_defaults, Qnil); + bset_display_time (&buffer_defaults, Qnil); /* Assign the local-flags to the slots that have default values. The local flag is a bit that is used in the buffer @@ -4982,24 +5220,24 @@ init_buffer_once (void) /* 0 means not a lisp var, -1 means always local, else mask */ memset (&buffer_local_flags, 0, sizeof buffer_local_flags); - BSET (&buffer_local_flags, filename, make_number (-1)); - BSET (&buffer_local_flags, directory, make_number (-1)); - BSET (&buffer_local_flags, backed_up, make_number (-1)); - BSET (&buffer_local_flags, save_length, make_number (-1)); - BSET (&buffer_local_flags, auto_save_file_name, make_number (-1)); - BSET (&buffer_local_flags, read_only, make_number (-1)); - BSET (&buffer_local_flags, major_mode, make_number (-1)); - BSET (&buffer_local_flags, mode_name, make_number (-1)); - BSET (&buffer_local_flags, undo_list, make_number (-1)); - BSET (&buffer_local_flags, mark_active, make_number (-1)); - BSET (&buffer_local_flags, point_before_scroll, make_number (-1)); - BSET (&buffer_local_flags, file_truename, make_number (-1)); - BSET (&buffer_local_flags, invisibility_spec, make_number (-1)); - BSET (&buffer_local_flags, file_format, make_number (-1)); - BSET (&buffer_local_flags, auto_save_file_format, make_number (-1)); - BSET (&buffer_local_flags, display_count, make_number (-1)); - BSET (&buffer_local_flags, display_time, make_number (-1)); - BSET (&buffer_local_flags, enable_multibyte_characters, make_number (-1)); + bset_filename (&buffer_local_flags, make_number (-1)); + bset_directory (&buffer_local_flags, make_number (-1)); + bset_backed_up (&buffer_local_flags, make_number (-1)); + bset_save_length (&buffer_local_flags, make_number (-1)); + bset_auto_save_file_name (&buffer_local_flags, make_number (-1)); + bset_read_only (&buffer_local_flags, make_number (-1)); + bset_major_mode (&buffer_local_flags, make_number (-1)); + bset_mode_name (&buffer_local_flags, make_number (-1)); + bset_undo_list (&buffer_local_flags, make_number (-1)); + bset_mark_active (&buffer_local_flags, make_number (-1)); + bset_point_before_scroll (&buffer_local_flags, make_number (-1)); + bset_file_truename (&buffer_local_flags, make_number (-1)); + bset_invisibility_spec (&buffer_local_flags, make_number (-1)); + bset_file_format (&buffer_local_flags, make_number (-1)); + bset_auto_save_file_format (&buffer_local_flags, make_number (-1)); + bset_display_count (&buffer_local_flags, make_number (-1)); + bset_display_time (&buffer_local_flags, make_number (-1)); + bset_enable_multibyte_characters (&buffer_local_flags, make_number (-1)); idx = 1; XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx; @@ -5055,7 +5293,7 @@ init_buffer_once (void) QSFundamental = build_pure_c_string ("Fundamental"); Qfundamental_mode = intern_c_string ("fundamental-mode"); - BSET (&buffer_defaults, major_mode, Qfundamental_mode); + bset_major_mode (&buffer_defaults, Qfundamental_mode); Qmode_class = intern_c_string ("mode-class"); @@ -5118,13 +5356,13 @@ init_buffer (void) len++; } - BSET (current_buffer, directory, make_unibyte_string (pwd, len)); + bset_directory (current_buffer, make_unibyte_string (pwd, len)); if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters))) /* At this moment, we still don't know how to decode the directory name. So, we keep the bytes in multibyte form so that ENCODE_FILE correctly gets the original bytes. */ - BSET (current_buffer, directory, - string_to_multibyte (BVAR (current_buffer, directory))); + bset_directory + (current_buffer, string_to_multibyte (BVAR (current_buffer, directory))); /* Add /: to the front of the name if it would otherwise be treated as magic. */ @@ -5135,11 +5373,12 @@ init_buffer (void) However, it is not necessary to turn / into /:/. So avoid doing that. */ && strcmp ("/", SSDATA (BVAR (current_buffer, directory)))) - BSET (current_buffer, directory, - concat2 (build_string ("/:"), BVAR (current_buffer, directory))); + bset_directory + (current_buffer, + concat2 (build_string ("/:"), BVAR (current_buffer, directory))); temp = get_minibuffer (0); - BSET (XBUFFER (temp), directory, BVAR (current_buffer, directory)); + bset_directory (XBUFFER (temp), BVAR (current_buffer, directory)); free (pwd); } diff --git a/src/buffer.h b/src/buffer.h index 1c9f5d972a9..de7ca7eb2e7 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -477,7 +477,6 @@ struct buffer_text /* Most code should use this macro to access Lisp fields in struct buffer. */ #define BVAR(buf, field) ((buf)->INTERNAL_FIELD (field)) -#define BSET(buf, field, value) ((buf)->INTERNAL_FIELD (field) = (value)) /* This is the structure that the buffer Lisp object points to. */ @@ -862,6 +861,104 @@ struct buffer Lisp_Object INTERNAL_FIELD (undo_list); }; +/* Most code should use these functions to set Lisp fields in struct + buffer. */ +BUFFER_INLINE void +bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (bidi_paragraph_direction) = val; +} +BUFFER_INLINE void +bset_case_canon_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (case_canon_table) = val; +} +BUFFER_INLINE void +bset_case_eqv_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (case_eqv_table) = val; +} +BUFFER_INLINE void +bset_directory (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (directory) = val; +} +BUFFER_INLINE void +bset_display_count (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (display_count) = val; +} +BUFFER_INLINE void +bset_display_time (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (display_time) = val; +} +BUFFER_INLINE void +bset_downcase_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (downcase_table) = val; +} +BUFFER_INLINE void +bset_enable_multibyte_characters (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (enable_multibyte_characters) = val; +} +BUFFER_INLINE void +bset_filename (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (filename) = val; +} +BUFFER_INLINE void +bset_keymap (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (keymap) = val; +} +BUFFER_INLINE void +bset_last_selected_window (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (last_selected_window) = val; +} +BUFFER_INLINE void +bset_local_var_alist (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (local_var_alist) = val; +} +BUFFER_INLINE void +bset_mark_active (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (mark_active) = val; +} +BUFFER_INLINE void +bset_point_before_scroll (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (point_before_scroll) = val; +} +BUFFER_INLINE void +bset_read_only (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (read_only) = val; +} +BUFFER_INLINE void +bset_truncate_lines (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (truncate_lines) = val; +} +BUFFER_INLINE void +bset_undo_list (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (undo_list) = val; +} +BUFFER_INLINE void +bset_upcase_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (upcase_table) = val; +} +BUFFER_INLINE void +bset_width_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (width_table) = val; +} + /* Chain of all buffers, including killed ones. */ @@ -949,7 +1046,7 @@ extern Lisp_Object Qfirst_change_hook; /* Get text properties of B. */ BUFFER_INLINE INTERVAL -buffer_get_intervals (struct buffer *b) +buffer_intervals (struct buffer *b) { eassert (b->text != NULL); return b->text->intervals; @@ -958,26 +1055,12 @@ buffer_get_intervals (struct buffer *b) /* Set text properties of B to I. */ BUFFER_INLINE void -buffer_set_intervals (struct buffer *b, INTERVAL i) +set_buffer_intervals (struct buffer *b, INTERVAL i) { eassert (b->text != NULL); b->text->intervals = i; } -/* Set an appropriate overlay of B. */ - -BUFFER_INLINE void -buffer_set_overlays_before (struct buffer *b, struct Lisp_Overlay *o) -{ - b->overlays_before = o; -} - -BUFFER_INLINE void -buffer_set_overlays_after (struct buffer *b, struct Lisp_Overlay *o) -{ - b->overlays_after = o; -} - /* Non-zero if current buffer has overlays. */ BUFFER_INLINE int @@ -1116,18 +1199,36 @@ extern int last_per_buffer_idx; #define PER_BUFFER_IDX(OFFSET) \ XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags)) -/* Return the default value of the per-buffer variable at offset - OFFSET in the buffer structure. */ +/* Functions to get and set default value of the per-buffer + variable at offset OFFSET in the buffer structure. */ + +BUFFER_INLINE Lisp_Object +per_buffer_default (int offset) +{ + return *(Lisp_Object *)(offset + (char *) &buffer_defaults); +} + +BUFFER_INLINE void +set_per_buffer_default (int offset, Lisp_Object value) +{ + *(Lisp_Object *)(offset + (char *) &buffer_defaults) = value; +} -#define PER_BUFFER_DEFAULT(OFFSET) \ - (*(Lisp_Object *)((OFFSET) + (char *) &buffer_defaults)) +/* Functions to get and set buffer-local value of the per-buffer + variable at offset OFFSET in the buffer structure. */ + +BUFFER_INLINE Lisp_Object +per_buffer_value (struct buffer *b, int offset) +{ + return *(Lisp_Object *)(offset + (char *) b); +} -/* Return the buffer-local value of the per-buffer variable at offset - OFFSET in the buffer structure. */ +BUFFER_INLINE void +set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value) +{ + *(Lisp_Object *)(offset + (char *) b) = value; +} -#define PER_BUFFER_VALUE(BUFFER, OFFSET) \ - (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) - /* Downcase a character C, or make no change if that cannot be done. */ BUFFER_INLINE int downcase (int c) diff --git a/src/callint.c b/src/callint.c index e0133864674..36a59e812f2 100644 --- a/src/callint.c +++ b/src/callint.c @@ -372,7 +372,7 @@ invoke it. If KEYS is omitted or nil, the return value of Vthis_command = save_this_command; Vthis_original_command = save_this_original_command; Vreal_this_command = save_real_this_command; - KSET (current_kboard, Vlast_command, save_last_command); + kset_last_command (current_kboard, save_last_command); temporarily_switch_to_single_kboard (NULL); return unbind_to (speccount, apply1 (function, specs)); @@ -843,7 +843,7 @@ invoke it. If KEYS is omitted or nil, the return value of Vthis_command = save_this_command; Vthis_original_command = save_this_original_command; Vreal_this_command = save_real_this_command; - KSET (current_kboard, Vlast_command, save_last_command); + kset_last_command (current_kboard, save_last_command); { Lisp_Object val; diff --git a/src/callproc.c b/src/callproc.c index 10a80168fb2..4bf1da04e1a 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -65,10 +65,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "nsterm.h" #endif -#ifndef USE_CRT_DLL -extern char **environ; -#endif - #ifdef HAVE_SETPGID #if !defined (USG) #undef setpgrp diff --git a/src/casetab.c b/src/casetab.c index 4b29c091ca9..a163d5204f8 100644 --- a/src/casetab.c +++ b/src/casetab.c @@ -128,13 +128,13 @@ set_case_table (Lisp_Object table, int standard) up = Fmake_char_table (Qcase_table, Qnil); map_char_table (set_identity, Qnil, table, up); map_char_table (shuffle, Qnil, table, up); - XCHAR_TABLE (table)->extras[0] = up; + set_char_table_extras (table, 0, up); } if (NILP (canon)) { canon = Fmake_char_table (Qcase_table, Qnil); - XCHAR_TABLE (table)->extras[1] = canon; + set_char_table_extras (table, 1, canon); map_char_table (set_canon, Qnil, table, table); } @@ -143,11 +143,11 @@ set_case_table (Lisp_Object table, int standard) eqv = Fmake_char_table (Qcase_table, Qnil); map_char_table (set_identity, Qnil, canon, eqv); map_char_table (shuffle, Qnil, canon, eqv); - XCHAR_TABLE (table)->extras[2] = eqv; + set_char_table_extras (table, 2, eqv); } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (canon)->extras[2] = eqv; + set_char_table_extras (canon, 2, eqv); if (standard) { @@ -158,10 +158,10 @@ set_case_table (Lisp_Object table, int standard) } else { - BSET (current_buffer, downcase_table, table); - BSET (current_buffer, upcase_table, up); - BSET (current_buffer, case_canon_table, canon); - BSET (current_buffer, case_eqv_table, eqv); + bset_downcase_table (current_buffer, table); + bset_upcase_table (current_buffer, up); + bset_case_canon_table (current_buffer, canon); + bset_case_eqv_table (current_buffer, eqv); } return table; @@ -260,7 +260,7 @@ init_casetab_once (void) down = Fmake_char_table (Qcase_table, Qnil); Vascii_downcase_table = down; - XCHAR_TABLE (down)->purpose = Qcase_table; + set_char_table_purpose (down, Qcase_table); for (i = 0; i < 128; i++) { @@ -268,10 +268,10 @@ init_casetab_once (void) CHAR_TABLE_SET (down, i, make_number (c)); } - XCHAR_TABLE (down)->extras[1] = Fcopy_sequence (down); + set_char_table_extras (down, 1, Fcopy_sequence (down)); up = Fmake_char_table (Qcase_table, Qnil); - XCHAR_TABLE (down)->extras[0] = up; + set_char_table_extras (down, 0, up); for (i = 0; i < 128; i++) { @@ -281,7 +281,7 @@ init_casetab_once (void) CHAR_TABLE_SET (up, i, make_number (c)); } - XCHAR_TABLE (down)->extras[2] = Fcopy_sequence (up); + set_char_table_extras (down, 2, Fcopy_sequence (up)); /* Fill in what isn't filled in. */ set_case_table (down, 1); diff --git a/src/category.c b/src/category.c index 13c6e46d283..1c9085fd558 100644 --- a/src/category.c +++ b/src/category.c @@ -32,7 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define CATEGORY_INLINE EXTERN_INLINE -#include <ctype.h> #include <setjmp.h> #include "lisp.h" #include "character.h" @@ -41,6 +40,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "category.h" #include "keymap.h" +/* This setter is used only in this file, so it can be private. */ +static inline void +bset_category_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (category_table) = val; +} + /* The version number of the latest category table. Each category table has a unique version number. It is assigned a new number also when it is modified. When a regular expression is compiled @@ -71,11 +77,12 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set) EMACS_UINT hash; if (NILP (XCHAR_TABLE (table)->extras[1])) - XCHAR_TABLE (table)->extras[1] - = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), - make_float (DEFAULT_REHASH_SIZE), - make_float (DEFAULT_REHASH_THRESHOLD), - Qnil, Qnil, Qnil); + set_char_table_extras + (table, 1, + make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), + make_float (DEFAULT_REHASH_SIZE), + make_float (DEFAULT_REHASH_THRESHOLD), + Qnil, Qnil, Qnil)); h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); i = hash_lookup (h, category_set, &hash); if (i >= 0) @@ -136,7 +143,7 @@ the current buffer's category table. */) error ("Category `%c' is already defined", (int) XFASTINT (category)); if (!NILP (Vpurify_flag)) docstring = Fpurecopy (docstring); - CATEGORY_DOCSTRING (table, XFASTINT (category)) = docstring; + SET_CATEGORY_DOCSTRING (table, XFASTINT (category), docstring); return Qnil; } @@ -238,10 +245,10 @@ copy_category_table (Lisp_Object table) table = copy_char_table (table); if (! NILP (XCHAR_TABLE (table)->defalt)) - XCHAR_TABLE (table)->defalt - = Fcopy_sequence (XCHAR_TABLE (table)->defalt); - XCHAR_TABLE (table)->extras[0] - = Fcopy_sequence (XCHAR_TABLE (table)->extras[0]); + set_char_table_defalt (table, + Fcopy_sequence (XCHAR_TABLE (table)->defalt)); + set_char_table_extras + (table, 0, Fcopy_sequence (XCHAR_TABLE (table)->extras[0])); map_char_table (copy_category_entry, Qnil, table, table); return table; @@ -270,9 +277,9 @@ DEFUN ("make-category-table", Fmake_category_table, Smake_category_table, int i; val = Fmake_char_table (Qcategory_table, Qnil); - XCHAR_TABLE (val)->defalt = MAKE_CATEGORY_SET; + set_char_table_defalt (val, MAKE_CATEGORY_SET); for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++) - XCHAR_TABLE (val)->contents[i] = MAKE_CATEGORY_SET; + set_char_table_contents (val, i, MAKE_CATEGORY_SET); Fset_char_table_extra_slot (val, make_number (0), Fmake_vector (make_number (95), Qnil)); return val; @@ -285,7 +292,7 @@ Return TABLE. */) { int idx; table = check_category_table (table); - BSET (current_buffer, category_table, table); + bset_category_table (current_buffer, table); /* Indicate that this buffer now has a specified category table. */ idx = PER_BUFFER_VAR_IDX (category_table); SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1); @@ -466,7 +473,7 @@ init_category_once (void) Vstandard_category_table = Fmake_char_table (Qcategory_table, Qnil); /* Set a category set which contains nothing to the default. */ - XCHAR_TABLE (Vstandard_category_table)->defalt = MAKE_CATEGORY_SET; + set_char_table_defalt (Vstandard_category_table, MAKE_CATEGORY_SET); Fset_char_table_extra_slot (Vstandard_category_table, make_number (0), Fmake_vector (make_number (95), Qnil)); } diff --git a/src/category.h b/src/category.h index f29034acff1..9fb981ed383 100644 --- a/src/category.h +++ b/src/category.h @@ -96,8 +96,12 @@ CHAR_HAS_CATEGORY (int ch, int category) #define Vstandard_category_table BVAR (&buffer_defaults, category_table) /* Return the doc string of CATEGORY in category table TABLE. */ -#define CATEGORY_DOCSTRING(table, category) \ - XVECTOR (Fchar_table_extra_slot (table, make_number (0)))->contents[(category) - ' '] +#define CATEGORY_DOCSTRING(table, category) \ + AREF (Fchar_table_extra_slot (table, make_number (0)), ((category) - ' ')) + +/* Set the doc string of CATEGORY to VALUE in category table TABLE. */ +#define SET_CATEGORY_DOCSTRING(table, category, value) \ + ASET (Fchar_table_extra_slot (table, make_number (0)), ((category) - ' '), value) /* Return the version number of category table TABLE. Not used for the moment. */ diff --git a/src/charset.c b/src/charset.c index fbbcefc4915..3e286fa947d 100644 --- a/src/charset.c +++ b/src/charset.c @@ -30,10 +30,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <unistd.h> -#include <ctype.h> #include <limits.h> #include <sys/types.h> #include <setjmp.h> +#include <c-ctype.h> #include "lisp.h" #include "character.h" #include "charset.h" @@ -446,7 +446,7 @@ read_hex (FILE *fp, int *eof, int *overflow) return 0; } n = 0; - while (isxdigit (c = getc (fp))) + while (c_isxdigit (c = getc (fp))) { if (UINT_MAX >> 4 < n) *overflow = 1; @@ -1131,7 +1131,7 @@ usage: (define-charset-internal ...) */) { new_definition_p = 0; id = XFASTINT (CHARSET_SYMBOL_ID (args[charset_arg_name])); - set_hash_value (hash_table, charset.hash_index, attrs); + set_hash_value_slot (hash_table, charset.hash_index, attrs); } else { diff --git a/src/chartab.c b/src/chartab.c index c022bc03e66..711a49ed397 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -115,8 +115,8 @@ the char-table has no extra slot. */) size = VECSIZE (struct Lisp_Char_Table) - 1 + n_extras; vector = Fmake_vector (make_number (size), init); XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE); - XCHAR_TABLE (vector)->parent = Qnil; - XCHAR_TABLE (vector)->purpose = purpose; + set_char_table_parent (vector, Qnil); + set_char_table_purpose (vector, purpose); XSETCHAR_TABLE (vector, XCHAR_TABLE (vector)); return vector; } @@ -155,21 +155,17 @@ char_table_ascii (Lisp_Object table) static Lisp_Object copy_sub_char_table (Lisp_Object table) { - Lisp_Object copy; int depth = XINT (XSUB_CHAR_TABLE (table)->depth); int min_char = XINT (XSUB_CHAR_TABLE (table)->min_char); - Lisp_Object val; + Lisp_Object copy = make_sub_char_table (depth, min_char, Qnil); int i; - copy = make_sub_char_table (depth, min_char, Qnil); /* Recursively copy any sub char-tables. */ for (i = 0; i < chartab_size[depth]; i++) { - val = XSUB_CHAR_TABLE (table)->contents[i]; - if (SUB_CHAR_TABLE_P (val)) - XSUB_CHAR_TABLE (copy)->contents[i] = copy_sub_char_table (val); - else - XSUB_CHAR_TABLE (copy)->contents[i] = val; + Lisp_Object val = XSUB_CHAR_TABLE (table)->contents[i]; + set_sub_char_table_contents + (copy, i, SUB_CHAR_TABLE_P (val) ? copy_sub_char_table (val) : val); } return copy; @@ -185,18 +181,19 @@ copy_char_table (Lisp_Object table) copy = Fmake_vector (make_number (size), Qnil); XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE); - XCHAR_TABLE (copy)->defalt = XCHAR_TABLE (table)->defalt; - XCHAR_TABLE (copy)->parent = XCHAR_TABLE (table)->parent; - XCHAR_TABLE (copy)->purpose = XCHAR_TABLE (table)->purpose; + set_char_table_defalt (copy, XCHAR_TABLE (table)->defalt); + set_char_table_parent (copy, XCHAR_TABLE (table)->parent); + set_char_table_purpose (copy, XCHAR_TABLE (table)->purpose); for (i = 0; i < chartab_size[0]; i++) - XCHAR_TABLE (copy)->contents[i] - = (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) - ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) - : XCHAR_TABLE (table)->contents[i]); - XCHAR_TABLE (copy)->ascii = char_table_ascii (copy); + set_char_table_contents + (copy, i, + (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) + ? copy_sub_char_table (XCHAR_TABLE (table)->contents[i]) + : XCHAR_TABLE (table)->contents[i])); + set_char_table_ascii (copy, char_table_ascii (copy)); size -= VECSIZE (struct Lisp_Char_Table) - 1; for (i = 0; i < size; i++) - XCHAR_TABLE (copy)->extras[i] = XCHAR_TABLE (table)->extras[i]; + set_char_table_extras (copy, i, XCHAR_TABLE (table)->extras[i]); XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); return copy; @@ -394,7 +391,7 @@ sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop) Lisp_Object sub; if (depth == 3) - tbl->contents[i] = val; + set_sub_char_table_contents (table, i, val); else { sub = tbl->contents[i]; @@ -407,23 +404,21 @@ sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop) sub = make_sub_char_table (depth + 1, min_char + i * chartab_chars[depth], sub); - tbl->contents[i] = sub; + set_sub_char_table_contents (table, i, sub); } } sub_char_table_set (sub, c, val, is_uniprop); } } -Lisp_Object +void char_table_set (Lisp_Object table, int c, Lisp_Object val) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); if (ASCII_CHAR_P (c) && SUB_CHAR_TABLE_P (tbl->ascii)) - { - XSUB_CHAR_TABLE (tbl->ascii)->contents[c] = val; - } + set_sub_char_table_contents (tbl->ascii, c, val); else { int i = CHARTAB_IDX (c, 0, 0); @@ -433,13 +428,12 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val) if (! SUB_CHAR_TABLE_P (sub)) { sub = make_sub_char_table (1, i * chartab_chars[0], sub); - tbl->contents[i] = sub; + set_char_table_contents (table, i, sub); } sub_char_table_set (sub, c, val, UNIPROP_TABLE_P (table)); if (ASCII_CHAR_P (c)) - tbl->ascii = char_table_ascii (table); + set_char_table_ascii (table, char_table_ascii (table)); } - return val; } static void @@ -461,7 +455,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, if (c > to) break; if (from <= c && c + chars_in_block - 1 <= to) - tbl->contents[i] = val; + set_sub_char_table_contents (table, i, val); else { Lisp_Object sub = tbl->contents[i]; @@ -472,7 +466,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, else { sub = make_sub_char_table (depth + 1, c, sub); - tbl->contents[i] = sub; + set_sub_char_table_contents (table, i, sub); } } sub_char_table_set_range (sub, from, to, val, is_uniprop); @@ -481,7 +475,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, } -Lisp_Object +void char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); @@ -500,22 +494,21 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) if (c > to) break; if (from <= c && c + chartab_chars[0] - 1 <= to) - tbl->contents[i] = val; + set_char_table_contents (table, i, val); else { Lisp_Object sub = tbl->contents[i]; if (! SUB_CHAR_TABLE_P (sub)) { sub = make_sub_char_table (1, i * chartab_chars[0], sub); - tbl->contents[i] = sub; + set_char_table_contents (table, i, sub); } sub_char_table_set_range (sub, from, to, val, is_uniprop); } } if (ASCII_CHAR_P (from)) - tbl->ascii = char_table_ascii (table); + set_char_table_ascii (table, char_table_ascii (table)); } - return val; } @@ -563,7 +556,7 @@ Return PARENT. PARENT must be either nil or another char-table. */) error ("Attempt to make a chartable be its own parent"); } - XCHAR_TABLE (char_table)->parent = parent; + set_char_table_parent (char_table, parent); return parent; } @@ -594,7 +587,8 @@ DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot, || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table))) args_out_of_range (char_table, n); - return XCHAR_TABLE (char_table)->extras[XINT (n)] = value; + set_char_table_extras (char_table, XINT (n), value); + return value; } DEFUN ("char-table-range", Fchar_table_range, Schar_table_range, @@ -640,12 +634,12 @@ or a character code. Return VALUE. */) { int i; - XCHAR_TABLE (char_table)->ascii = value; + set_char_table_ascii (char_table, value); for (i = 0; i < chartab_size[0]; i++) - XCHAR_TABLE (char_table)->contents[i] = value; + set_char_table_contents (char_table, i, value); } else if (EQ (range, Qnil)) - XCHAR_TABLE (char_table)->defalt = value; + set_char_table_defalt (char_table, value); else if (CHARACTERP (range)) char_table_set (char_table, XINT (range), value); else if (CONSP (range)) @@ -693,15 +687,19 @@ optimize_sub_char_table (Lisp_Object table, Lisp_Object test) elt = XSUB_CHAR_TABLE (table)->contents[0]; if (SUB_CHAR_TABLE_P (elt)) - elt = XSUB_CHAR_TABLE (table)->contents[0] - = optimize_sub_char_table (elt, test); + { + elt = optimize_sub_char_table (elt, test); + set_sub_char_table_contents (table, 0, elt); + } optimizable = SUB_CHAR_TABLE_P (elt) ? 0 : 1; for (i = 1; i < chartab_size[depth]; i++) { this = XSUB_CHAR_TABLE (table)->contents[i]; if (SUB_CHAR_TABLE_P (this)) - this = XSUB_CHAR_TABLE (table)->contents[i] - = optimize_sub_char_table (this, test); + { + this = optimize_sub_char_table (this, test); + set_sub_char_table_contents (table, i, this); + } if (optimizable && (NILP (test) ? NILP (Fequal (this, elt)) /* defaults to `equal'. */ : EQ (test, Qeq) ? !EQ (this, elt) /* Optimize `eq' case. */ @@ -728,11 +726,11 @@ equivalent and can be merged. It defaults to `equal'. */) { elt = XCHAR_TABLE (char_table)->contents[i]; if (SUB_CHAR_TABLE_P (elt)) - XCHAR_TABLE (char_table)->contents[i] - = optimize_sub_char_table (elt, test); + set_char_table_contents + (char_table, i, optimize_sub_char_table (elt, test)); } /* Reset the `ascii' cache, in case it got optimized away. */ - XCHAR_TABLE (char_table)->ascii = char_table_ascii (char_table); + set_char_table_ascii (char_table, char_table_ascii (char_table)); return Qnil; } @@ -824,9 +822,9 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), /* This is to get a value of FROM in PARENT without checking the parent of PARENT. */ - XCHAR_TABLE (parent)->parent = Qnil; + set_char_table_parent (parent, Qnil); val = CHAR_TABLE_REF (parent, from); - XCHAR_TABLE (parent)->parent = temp; + set_char_table_parent (parent, temp); XSETCDR (range, make_number (c - 1)); val = map_sub_char_table (c_function, function, parent, arg, val, range, @@ -906,9 +904,9 @@ map_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), temp = XCHAR_TABLE (parent)->parent; /* This is to get a value of FROM in PARENT without checking the parent of PARENT. */ - XCHAR_TABLE (parent)->parent = Qnil; + set_char_table_parent (parent, Qnil); val = CHAR_TABLE_REF (parent, from); - XCHAR_TABLE (parent)->parent = temp; + set_char_table_parent (parent, temp); val = map_sub_char_table (c_function, function, parent, arg, val, range, parent); table = parent; @@ -1143,10 +1141,9 @@ uniprop_table_uncompress (Lisp_Object table, int idx) int min_char = (XINT (XSUB_CHAR_TABLE (table)->min_char) + chartab_chars[2] * idx); Lisp_Object sub = make_sub_char_table (3, min_char, Qnil); - struct Lisp_Sub_Char_Table *subtbl = XSUB_CHAR_TABLE (sub); const unsigned char *p, *pend; - XSUB_CHAR_TABLE (table)->contents[idx] = sub; + set_sub_char_table_contents (table, idx, sub); p = SDATA (val), pend = p + SBYTES (val); if (*p == 1) { @@ -1156,7 +1153,8 @@ uniprop_table_uncompress (Lisp_Object table, int idx) while (p < pend && idx < chartab_chars[2]) { int v = STRING_CHAR_ADVANCE (p); - subtbl->contents[idx++] = v > 0 ? make_number (v) : Qnil; + set_sub_char_table_contents + (sub, idx++, v > 0 ? make_number (v) : Qnil); } } else if (*p == 2) @@ -1181,7 +1179,7 @@ uniprop_table_uncompress (Lisp_Object table, int idx) } } while (count-- > 0) - subtbl->contents[idx++] = make_number (v); + set_sub_char_table_contents (sub, idx++, make_number (v)); } } /* It seems that we don't need this function because C code won't need @@ -1284,7 +1282,7 @@ uniprop_encode_value_numeric (Lisp_Object table, Lisp_Object value) args[0] = XCHAR_TABLE (table)->extras[4]; args[1] = Fmake_vector (make_number (1), value); - XCHAR_TABLE (table)->extras[4] = Fvconcat (2, args); + set_char_table_extras (table, 4, Fvconcat (2, args)); } return make_number (i); } @@ -1346,7 +1344,7 @@ uniprop_table (Lisp_Object prop) : ! NILP (val)) return Qnil; /* Prepare ASCII values in advance for CHAR_TABLE_REF. */ - XCHAR_TABLE (table)->ascii = char_table_ascii (table); + set_char_table_ascii (table, char_table_ascii (table)); return table; } diff --git a/src/cmds.c b/src/cmds.c index 24778fae6e3..b416135ee9e 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -301,7 +301,7 @@ At the end, it runs `post-self-insert-hook'. */) added be explicit calls to undo-boundary. */ && EQ (BVAR (current_buffer, undo_list), last_undo_boundary)) /* Remove the undo_boundary that was just pushed. */ - BSET (current_buffer, undo_list, XCDR (BVAR (current_buffer, undo_list))); + bset_undo_list (current_buffer, XCDR (BVAR (current_buffer, undo_list))); /* Barf if the key that invoked this was not a character. */ if (!CHARACTERP (last_command_event)) diff --git a/src/coding.c b/src/coding.c index c601a18b26e..971686dc180 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7112,7 +7112,7 @@ decode_coding (struct coding_system *coding) record_first_change (); undo_list = BVAR (current_buffer, undo_list); - BSET (current_buffer, undo_list, Qt); + bset_undo_list (current_buffer, Qt); } coding->consumed = coding->consumed_char = 0; @@ -7209,7 +7209,7 @@ decode_coding (struct coding_system *coding) decode_eol (coding); if (BUFFERP (coding->dst_object)) { - BSET (current_buffer, undo_list, undo_list); + bset_undo_list (current_buffer, undo_list); record_insert (coding->dst_pos, coding->produced_char); } return coding->result; @@ -7577,8 +7577,8 @@ make_conversion_work_buffer (int multibyte) doesn't compile new regexps. */ Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); Ferase_buffer (); - BSET (current_buffer, undo_list, Qt); - BSET (current_buffer, enable_multibyte_characters, multibyte ? Qt : Qnil); + bset_undo_list (current_buffer, Qt); + bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil); set_buffer_internal (current); return workbuf; } @@ -9302,10 +9302,10 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; terminal_coding->src_multibyte = 1; terminal_coding->dst_multibyte = 0; - if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK) - TSET (term, charset_list, coding_charset_list (terminal_coding)); - else - TSET (term, charset_list, Fcons (make_number (charset_ascii), Qnil)); + tset_charset_list + (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK + ? coding_charset_list (terminal_coding) + : Fcons (make_number (charset_ascii), Qnil))); return Qnil; } diff --git a/src/data.c b/src/data.c index e6342caadf1..fa40f14ccba 100644 --- a/src/data.c +++ b/src/data.c @@ -580,7 +580,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, else { swap_in_symval_forwarding (sym, blv); - valcontents = BLV_VALUE (blv); + valcontents = blv_value (blv); } break; } @@ -884,7 +884,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents) return *XOBJFWD (valcontents)->objvar; case Lisp_Fwd_Buffer_Obj: - return PER_BUFFER_VALUE (current_buffer, + return per_buffer_value (current_buffer, XBUFFER_OBJFWD (valcontents)->offset); case Lisp_Fwd_Kboard_Obj: @@ -956,7 +956,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva b = XBUFFER (lbuf); if (! PER_BUFFER_VALUE_P (b, idx)) - PER_BUFFER_VALUE (b, offset) = newval; + set_per_buffer_value (b, offset, newval); } } break; @@ -974,7 +974,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva if (buf == NULL) buf = current_buffer; - PER_BUFFER_VALUE (buf, offset) = newval; + set_per_buffer_value (buf, offset, newval); } break; @@ -1001,16 +1001,16 @@ swap_in_global_binding (struct Lisp_Symbol *symbol) /* Unload the previously loaded binding. */ if (blv->fwd) - SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); + set_blv_value (blv, do_symval_forwarding (blv->fwd)); /* Select the global binding in the symbol. */ - blv->valcell = blv->defcell; + set_blv_valcell (blv, blv->defcell); if (blv->fwd) store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL); /* Indicate that the global binding is set up now. */ - blv->where = Qnil; - SET_BLV_FOUND (blv, 0); + set_blv_where (blv, Qnil); + set_blv_found (blv, 0); } /* Set up the buffer-local symbol SYMBOL for validity in the current buffer. @@ -1038,7 +1038,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ /* Unload the previously loaded binding. */ tem1 = blv->valcell; if (blv->fwd) - SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); + set_blv_value (blv, do_symval_forwarding (blv->fwd)); /* Choose the new binding. */ { Lisp_Object var; @@ -1046,7 +1046,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ if (blv->frame_local) { tem1 = assq_no_quit (var, XFRAME (selected_frame)->param_alist); - blv->where = selected_frame; + set_blv_where (blv, selected_frame); } else { @@ -1058,9 +1058,9 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ tem1 = blv->defcell; /* Load the new binding. */ - blv->valcell = tem1; + set_blv_valcell (blv, tem1); if (blv->fwd) - store_symval_forwarding (blv->fwd, BLV_VALUE (blv), NULL); + store_symval_forwarding (blv->fwd, blv_value (blv), NULL); } } @@ -1087,7 +1087,7 @@ find_symbol_value (Lisp_Object symbol) { struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); swap_in_symval_forwarding (sym, blv); - return blv->fwd ? do_symval_forwarding (blv->fwd) : BLV_VALUE (blv); + return blv->fwd ? do_symval_forwarding (blv->fwd) : blv_value (blv); } /* FALLTHROUGH */ case SYMBOL_FORWARDED: @@ -1212,7 +1212,7 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register /* Write out `realvalue' to the old loaded binding. */ if (blv->fwd) - SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); + set_blv_value (blv, do_symval_forwarding (blv->fwd)); /* Find the new binding. */ XSETSYMBOL (symbol, sym); /* May have changed via aliasing. */ @@ -1220,7 +1220,7 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register (blv->frame_local ? XFRAME (where)->param_alist : BVAR (XBUFFER (where), local_var_alist))); - blv->where = where; + set_blv_where (blv, where); blv->found = 1; if (NILP (tem1)) @@ -1250,17 +1250,18 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register bindings, not for frame-local bindings. */ eassert (!blv->frame_local); tem1 = Fcons (symbol, XCDR (blv->defcell)); - BSET (XBUFFER (where), local_var_alist, - Fcons (tem1, BVAR (XBUFFER (where), local_var_alist))); + bset_local_var_alist + (XBUFFER (where), + Fcons (tem1, BVAR (XBUFFER (where), local_var_alist))); } } /* Record which binding is now loaded. */ - blv->valcell = tem1; + set_blv_valcell (blv, tem1); } /* Store the new value in the cons cell. */ - SET_BLV_VALUE (blv, newval); + set_blv_value (blv, newval); if (blv->fwd) { @@ -1345,7 +1346,7 @@ default_value (Lisp_Object symbol) { int offset = XBUFFER_OBJFWD (valcontents)->offset; if (PER_BUFFER_IDX (offset) != 0) - return PER_BUFFER_DEFAULT (offset); + return per_buffer_default (offset); } /* For other variables, get the current value. */ @@ -1432,7 +1433,7 @@ for this variable. */) int offset = XBUFFER_OBJFWD (valcontents)->offset; int idx = PER_BUFFER_IDX (offset); - PER_BUFFER_DEFAULT (offset) = value; + set_per_buffer_default (offset, value); /* If this variable is not always local in all buffers, set it in the buffers that don't nominally have a local value. */ @@ -1442,7 +1443,7 @@ for this variable. */) FOR_EACH_BUFFER (b) if (!PER_BUFFER_VALUE_P (b, idx)) - PER_BUFFER_VALUE (b, offset) = value; + set_per_buffer_value (b, offset, value); } return value; } @@ -1516,12 +1517,12 @@ make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd))); eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd))); blv->fwd = forwarded ? valcontents.fwd : NULL; - blv->where = Qnil; + set_blv_where (blv, Qnil); blv->frame_local = 0; blv->local_if_set = 0; - blv->defcell = tem; - blv->valcell = tem; - SET_BLV_FOUND (blv, 0); + set_blv_defcell (blv, tem); + set_blv_valcell (blv, tem); + set_blv_found (blv, 0); return blv; } @@ -1690,17 +1691,16 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) default value. */ find_symbol_value (variable); - BSET (current_buffer, local_var_alist, - Fcons (Fcons (variable, XCDR (blv->defcell)), - BVAR (current_buffer, local_var_alist))); + bset_local_var_alist + (current_buffer, + Fcons (Fcons (variable, XCDR (blv->defcell)), + BVAR (current_buffer, local_var_alist))); /* Make sure symbol does not think it is set up for this buffer; force it to look once again for this buffer's value. */ if (current_buffer == XBUFFER (blv->where)) - blv->where = Qnil; - /* blv->valcell = blv->defcell; - * SET_BLV_FOUND (blv, 0); */ - blv->found = 0; + set_blv_where (blv, Qnil); + set_blv_found (blv, 0); } /* If the symbol forwards into a C variable, then load the binding @@ -1742,8 +1742,8 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) if (idx > 0) { SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0); - PER_BUFFER_VALUE (current_buffer, offset) - = PER_BUFFER_DEFAULT (offset); + set_per_buffer_value (current_buffer, offset, + per_buffer_default (offset)); } } return variable; @@ -1760,8 +1760,9 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) XSETSYMBOL (variable, sym); /* Propagate variable indirection. */ tem = Fassq (variable, BVAR (current_buffer, local_var_alist)); if (!NILP (tem)) - BSET (current_buffer, local_var_alist, - Fdelq (tem, BVAR (current_buffer, local_var_alist))); + bset_local_var_alist + (current_buffer, + Fdelq (tem, BVAR (current_buffer, local_var_alist))); /* If the symbol is set up with the current buffer's binding loaded, recompute its value. We have to do it now, or else @@ -1770,9 +1771,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) Lisp_Object buf; XSETBUFFER (buf, current_buffer); if (EQ (buf, blv->where)) { - blv->where = Qnil; - /* blv->valcell = blv->defcell; - * SET_BLV_FOUND (blv, 0); */ + set_blv_where (blv, Qnil); blv->found = 0; find_symbol_value (variable); } @@ -1894,11 +1893,11 @@ BUFFER defaults to the current buffer. */) if (EQ (variable, XCAR (elt))) { eassert (!blv->frame_local); - eassert (BLV_FOUND (blv) || !EQ (blv->where, tmp)); + eassert (blv_found (blv) || !EQ (blv->where, tmp)); return Qt; } } - eassert (!BLV_FOUND (blv) || !EQ (blv->where, tmp)); + eassert (!blv_found (blv) || !EQ (blv->where, tmp)); return Qnil; } case SYMBOL_FORWARDED: @@ -1988,7 +1987,7 @@ If the current binding is global (the default), the value is nil. */) if (!NILP (Flocal_variable_p (variable, Qnil))) return Fcurrent_buffer (); else if (sym->redirect == SYMBOL_LOCALIZED - && BLV_FOUND (SYMBOL_BLV (sym))) + && blv_found (SYMBOL_BLV (sym))) return SYMBOL_BLV (sym)->where; else return Qnil; diff --git a/src/dispnew.c b/src/dispnew.c index b82761f8cad..8db4f93dc70 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <signal.h> #include <stdio.h> -#include <ctype.h> #include <setjmp.h> #include <unistd.h> @@ -622,7 +621,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y are invalidated below. */ if (INTEGERP (w->window_end_vpos) && XFASTINT (w->window_end_vpos) >= i) - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); while (i < matrix->nrows) matrix->rows[i++].enabled_p = 0; @@ -879,7 +878,7 @@ clear_window_matrices (struct window *w, int desired_p) else { clear_glyph_matrix (w->current_matrix); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); } } @@ -1888,14 +1887,14 @@ adjust_frame_glyphs_initially (void) int top_margin = FRAME_TOP_MARGIN (sf); /* Do it for the root window. */ - WSET (root, top_line, make_number (top_margin)); - WSET (root, total_lines, make_number (frame_lines - 1 - top_margin)); - WSET (root, total_cols, make_number (frame_cols)); + wset_top_line (root, make_number (top_margin)); + wset_total_lines (root, make_number (frame_lines - 1 - top_margin)); + wset_total_cols (root, make_number (frame_cols)); /* Do it for the mini-buffer window. */ - WSET (mini, top_line, make_number (frame_lines - 1)); - WSET (mini, total_lines, make_number (1)); - WSET (mini, total_cols, make_number (frame_cols)); + wset_top_line (mini, make_number (frame_lines - 1)); + wset_total_lines (mini, make_number (1)); + wset_total_cols (mini, make_number (frame_cols)); adjust_frame_glyphs (sf); glyphs_initialized_initially_p = 1; @@ -2167,10 +2166,10 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f) if (NILP (f->menu_bar_window)) { Lisp_Object frame; - FSET (f, menu_bar_window, make_window ()); + fset_menu_bar_window (f, make_window ()); w = XWINDOW (f->menu_bar_window); XSETFRAME (frame, f); - WSET (w, frame, frame); + wset_frame (w, frame); w->pseudo_window_p = 1; } else @@ -2178,10 +2177,10 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f) /* Set window dimensions to frame dimensions and allocate or adjust glyph matrices of W. */ - WSET (w, top_line, make_number (0)); - WSET (w, left_col, make_number (0)); - WSET (w, total_lines, make_number (FRAME_MENU_BAR_LINES (f))); - WSET (w, total_cols, make_number (FRAME_TOTAL_COLS (f))); + wset_top_line (w, make_number (0)); + wset_left_col (w, make_number (0)); + wset_total_lines (w, make_number (FRAME_MENU_BAR_LINES (f))); + wset_total_cols (w, make_number (FRAME_TOTAL_COLS (f))); allocate_matrices_for_window_redisplay (w); } #endif /* not USE_X_TOOLKIT && not USE_GTK */ @@ -2195,19 +2194,19 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f) if (NILP (f->tool_bar_window)) { Lisp_Object frame; - FSET (f, tool_bar_window, make_window ()); + fset_tool_bar_window (f, make_window ()); w = XWINDOW (f->tool_bar_window); XSETFRAME (frame, f); - WSET (w, frame, frame); + wset_frame (w, frame); w->pseudo_window_p = 1; } else w = XWINDOW (f->tool_bar_window); - WSET (w, top_line, make_number (FRAME_MENU_BAR_LINES (f))); - WSET (w, left_col, make_number (0)); - WSET (w, total_lines, make_number (FRAME_TOOL_BAR_LINES (f))); - WSET (w, total_cols, make_number (FRAME_TOTAL_COLS (f))); + wset_top_line (w, make_number (FRAME_MENU_BAR_LINES (f))); + wset_left_col (w, make_number (0)); + wset_total_lines (w, make_number (FRAME_TOOL_BAR_LINES (f))); + wset_total_cols (w, make_number (FRAME_TOTAL_COLS (f))); allocate_matrices_for_window_redisplay (w); } #endif @@ -2273,7 +2272,7 @@ free_glyphs (struct frame *f) free_glyph_matrix (w->desired_matrix); free_glyph_matrix (w->current_matrix); w->desired_matrix = w->current_matrix = NULL; - FSET (f, menu_bar_window, Qnil); + fset_menu_bar_window (f, Qnil); } /* Free the tool bar window and its glyph matrices. */ @@ -2283,7 +2282,7 @@ free_glyphs (struct frame *f) free_glyph_matrix (w->desired_matrix); free_glyph_matrix (w->current_matrix); w->desired_matrix = w->current_matrix = NULL; - FSET (f, tool_bar_window, Qnil); + fset_tool_bar_window (f, Qnil); } /* Release frame glyph matrices. Reset fields to zero in @@ -3221,8 +3220,8 @@ update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p) /* Swap tool-bar strings. We swap because we want to reuse strings. */ tem = f->current_tool_bar_string; - FSET (f, current_tool_bar_string, f->desired_tool_bar_string); - FSET (f, desired_tool_bar_string, tem); + fset_current_tool_bar_string (f, f->desired_tool_bar_string); + fset_desired_tool_bar_string (f, tem); } } @@ -5745,7 +5744,7 @@ change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int FrameCols (FRAME_TTY (f)) = newwidth; if (WINDOWP (f->tool_bar_window)) - WSET (XWINDOW (f->tool_bar_window), total_cols, make_number (newwidth)); + wset_total_cols (XWINDOW (f->tool_bar_window), make_number (newwidth)); } FRAME_LINES (f) = newheight; diff --git a/src/doc.c b/src/doc.c index d17e90f11c0..ed311d918d7 100644 --- a/src/doc.c +++ b/src/doc.c @@ -22,11 +22,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/file.h> /* Must be after sys/types.h for USG*/ -#include <ctype.h> #include <setjmp.h> #include <fcntl.h> #include <unistd.h> +#include <c-ctype.h> + #include "lisp.h" #include "character.h" #include "buffer.h" @@ -597,9 +598,9 @@ the same file name is found in the `doc-directory'. */) { ptrdiff_t len; - while (*beg && isspace (*beg)) ++beg; + while (*beg && c_isspace (*beg)) ++beg; - for (end = beg; *end && ! isspace (*end); ++end) + for (end = beg; *end && ! c_isspace (*end); ++end) if (*end == '/') beg = end+1; /* skip directory part */ len = end - beg; diff --git a/src/doprnt.c b/src/doprnt.c index 63f05cb74e2..b36e946005d 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -102,7 +102,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <ctype.h> #include <setjmp.h> #include <float.h> #include <unistd.h> diff --git a/src/dosfns.c b/src/dosfns.c index e3adf25d79f..21676f4b4f5 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -473,7 +473,7 @@ x_set_title (struct frame *f, Lisp_Object name) update_mode_lines = 1; - FSET (f, title, name); + fset_title (f, name); if (NILP (name)) name = f->name; diff --git a/src/editfns.c b/src/editfns.c index 5ac012c8378..fa57edead28 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -44,7 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/resource.h> #endif -#include <ctype.h> #include <float.h> #include <limits.h> #include <intprops.h> @@ -59,10 +58,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "window.h" #include "blockinput.h" -#ifndef USE_CRT_DLL -extern char **environ; -#endif - #define TM_YEAR_BASE 1900 #ifdef WINDOWSNT @@ -882,7 +877,7 @@ save_excursion_restore (Lisp_Object info) info = XCDR (info); tem = XCAR (info); tem1 = BVAR (current_buffer, mark_active); - BSET (current_buffer, mark_active, tem); + bset_mark_active (current_buffer, tem); /* If mark is active now, and either was not active or was at a different place, run the activate hook. */ @@ -2816,13 +2811,15 @@ determines whether case is significant or ignored. */) static Lisp_Object subst_char_in_region_unwind (Lisp_Object arg) { - return BSET (current_buffer, undo_list, arg); + bset_undo_list (current_buffer, arg); + return arg; } static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object arg) { - return BSET (current_buffer, filename, arg); + bset_filename (current_buffer, arg); + return arg; } DEFUN ("subst-char-in-region", Fsubst_char_in_region, @@ -2896,11 +2893,11 @@ Both characters must have the same length of multi-byte form. */) { record_unwind_protect (subst_char_in_region_unwind, BVAR (current_buffer, undo_list)); - BSET (current_buffer, undo_list, Qt); + bset_undo_list (current_buffer, Qt); /* Don't do file-locking. */ record_unwind_protect (subst_char_in_region_unwind_1, BVAR (current_buffer, filename)); - BSET (current_buffer, filename, Qnil); + bset_filename (current_buffer, Qnil); } if (pos_byte < GPT_BYTE) @@ -2982,7 +2979,7 @@ Both characters must have the same length of multi-byte form. */) INC_POS (pos_byte_next); if (! NILP (noundo)) - BSET (current_buffer, undo_list, tem); + bset_undo_list (current_buffer, tem); UNGCPRO; } @@ -3937,7 +3934,7 @@ usage: (format STRING &rest OBJECTS) */) /* If this argument has text properties, record where in the result string it appears. */ - if (string_get_intervals (args[n])) + if (string_intervals (args[n])) info[n].intervals = arg_intervals = 1; continue; @@ -4281,7 +4278,7 @@ usage: (format STRING &rest OBJECTS) */) arguments has text properties, set up text properties of the result string. */ - if (string_get_intervals (args[0]) || arg_intervals) + if (string_intervals (args[0]) || arg_intervals) { Lisp_Object len, new_len, props; struct gcpro gcpro1; @@ -4531,7 +4528,7 @@ Transposing beyond buffer boundaries is an error. */) Lisp_Object buf; XSETBUFFER (buf, current_buffer); - cur_intv = buffer_get_intervals (current_buffer); + cur_intv = buffer_intervals (current_buffer); validate_region (&startr1, &endr1); validate_region (&startr2, &endr2); diff --git a/src/emacs.c b/src/emacs.c index 92552521413..a039e89d48f 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -638,10 +638,6 @@ argmatch (char **argv, int argc, const char *sstr, const char *lstr, static void malloc_initialize_hook (void) { -#ifndef USE_CRT_DLL - extern char **environ; -#endif - if (initialized) { if (!malloc_using_checking) diff --git a/src/eval.c b/src/eval.c index f5f6fe7a808..c7a35fc91af 100644 --- a/src/eval.c +++ b/src/eval.c @@ -133,7 +133,27 @@ Lisp_Object inhibit_lisp_code; static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); static int interactive_p (int); static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); - + +/* Functions to set Lisp_Object slots of struct specbinding. */ + +static inline void +set_specpdl_symbol (Lisp_Object symbol) +{ + specpdl_ptr->symbol = symbol; +} + +static inline void +set_specpdl_old_value (Lisp_Object oldval) +{ + specpdl_ptr->old_value = oldval; +} + +static inline void +set_specpdl_saved_value (Lisp_Object savedval) +{ + specpdl_ptr->saved_value = savedval; +} + void init_eval_once (void) { @@ -2230,7 +2250,19 @@ eval_sub (Lisp_Object form) goto retry; } if (EQ (funcar, Qmacro)) - val = eval_sub (apply1 (Fcdr (fun), original_args)); + { + ptrdiff_t count = SPECPDL_INDEX (); + extern Lisp_Object Qlexical_binding; + Lisp_Object exp; + /* Bind lexical-binding during expansion of the macro, so the + macro can know reliably if the code it outputs will be + interpreted using lexical-binding or not. */ + specbind (Qlexical_binding, + NILP (Vinternal_interpreter_environment) ? Qnil : Qt); + exp = apply1 (Fcdr (fun), original_args); + unbind_to (count, Qnil); + val = eval_sub (exp); + } else if (EQ (funcar, Qlambda) || EQ (funcar, Qclosure)) val = apply_lambda (fun, original_args); @@ -3183,8 +3215,8 @@ specbind (Lisp_Object symbol, Lisp_Object value) case SYMBOL_PLAINVAL: /* The most common case is that of a non-constant symbol with a trivial value. Make that as fast as we can. */ - specpdl_ptr->symbol = symbol; - specpdl_ptr->old_value = SYMBOL_VAL (sym); + set_specpdl_symbol (symbol); + set_specpdl_old_value (SYMBOL_VAL (sym)); specpdl_ptr->func = NULL; specpdl_ptr->saved_value = Qnil; ++specpdl_ptr; @@ -3197,7 +3229,7 @@ specbind (Lisp_Object symbol, Lisp_Object value) { Lisp_Object ovalue = find_symbol_value (symbol); specpdl_ptr->func = 0; - specpdl_ptr->old_value = ovalue; + set_specpdl_old_value (ovalue); eassert (sym->redirect != SYMBOL_LOCALIZED || (EQ (SYMBOL_BLV (sym)->where, @@ -3214,12 +3246,12 @@ specbind (Lisp_Object symbol, Lisp_Object value) if (!NILP (Flocal_variable_p (symbol, Qnil))) { eassert (sym->redirect != SYMBOL_LOCALIZED - || (BLV_FOUND (SYMBOL_BLV (sym)) + || (blv_found (SYMBOL_BLV (sym)) && EQ (cur_buf, SYMBOL_BLV (sym)->where))); where = cur_buf; } else if (sym->redirect == SYMBOL_LOCALIZED - && BLV_FOUND (SYMBOL_BLV (sym))) + && blv_found (SYMBOL_BLV (sym))) where = SYMBOL_BLV (sym)->where; else where = Qnil; @@ -3231,7 +3263,7 @@ specbind (Lisp_Object symbol, Lisp_Object value) let_shadows_buffer_binding_p which is itself only used in set_internal for local_if_set. */ eassert (NILP (where) || EQ (where, cur_buf)); - specpdl_ptr->symbol = Fcons (symbol, Fcons (where, cur_buf)); + set_specpdl_symbol (Fcons (symbol, Fcons (where, cur_buf))); /* If SYMBOL is a per-buffer variable which doesn't have a buffer-local value here, make the `let' change the global @@ -3248,7 +3280,7 @@ specbind (Lisp_Object symbol, Lisp_Object value) } } else - specpdl_ptr->symbol = symbol; + set_specpdl_symbol (symbol); specpdl_ptr++; do_specbind (sym, specpdl_ptr - 1, value); @@ -3266,9 +3298,9 @@ record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) if (specpdl_ptr == specpdl + specpdl_size) grow_specpdl (); specpdl_ptr->func = function; - specpdl_ptr->symbol = Qnil; - specpdl_ptr->old_value = arg; - specpdl_ptr->saved_value = Qnil; + set_specpdl_symbol (Qnil); + set_specpdl_old_value (arg); + set_specpdl_saved_value (Qnil); specpdl_ptr++; } diff --git a/src/fileio.c b/src/fileio.c index eba157ea042..2f4a2ad2314 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -30,7 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <pwd.h> #endif -#include <ctype.h> #include <errno.h> #ifdef HAVE_LIBSELINUX @@ -38,6 +37,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <selinux/context.h> #endif +#include <c-ctype.h> + #include "lisp.h" #include "intervals.h" #include "character.h" @@ -67,12 +68,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z') #endif #ifdef WINDOWSNT -#define IS_DRIVE(x) isalpha ((unsigned char) (x)) +#define IS_DRIVE(x) c_isalpha (x) #endif /* Need to lower-case the drive letter, or else expanded filenames will sometimes compare unequal, because `expand-file-name' doesn't always down-case the drive letter. */ -#define DRIVE_LETTER(x) (tolower ((unsigned char) (x))) +#define DRIVE_LETTER(x) c_tolower (x) #endif #include "systime.h" @@ -364,7 +365,7 @@ Given a Unix syntax file name, returns a string ending in slash. */) r += 2; } - if (getdefdir (toupper ((unsigned char) *beg) - 'A' + 1, r)) + if (getdefdir (c_toupper (*beg) - 'A' + 1, r)) { if (!IS_DIRECTORY_SEP (res[strlen (res) - 1])) strcat (res, "/"); @@ -1053,7 +1054,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) if (!IS_DIRECTORY_SEP (nm[0])) { adir = alloca (MAXPATHLEN + 1); - if (!getdefdir (toupper (drive) - 'A' + 1, adir)) + if (!getdefdir (c_toupper (drive) - 'A' + 1, adir)) adir = NULL; } if (!adir) @@ -1129,7 +1130,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) adir = alloca (MAXPATHLEN + 1); if (drive) { - if (!getdefdir (toupper (drive) - 'A' + 1, adir)) + if (!getdefdir (c_toupper (drive) - 'A' + 1, adir)) newdir = "/"; } else @@ -1635,7 +1636,7 @@ those `/' is discarded. */) else { o = p; - while (p != endp && (isalnum (*p) || *p == '_')) p++; + while (p != endp && (c_isalnum (*p) || *p == '_')) p++; s = p; } @@ -1698,7 +1699,7 @@ those `/' is discarded. */) else { o = p; - while (p != endp && (isalnum (*p) || *p == '_')) p++; + while (p != endp && (c_isalnum (*p) || *p == '_')) p++; s = p; } @@ -3145,12 +3146,12 @@ decide_coding_unwind (Lisp_Object unwind_data) set_buffer_internal (XBUFFER (buffer)); adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE); adjust_overlays_for_delete (BEG, Z - BEG); - buffer_set_intervals (current_buffer, NULL); + set_buffer_intervals (current_buffer, NULL); TEMP_SET_PT_BOTH (BEG, BEG_BYTE); /* Now we are safe to change the buffer's multibyteness directly. */ - BSET (current_buffer, enable_multibyte_characters, multibyte); - BSET (current_buffer, undo_list, undo_list); + bset_enable_multibyte_characters (current_buffer, multibyte); + bset_undo_list (current_buffer, undo_list); return Qnil; } @@ -3486,16 +3487,16 @@ variable `last-coding-system-used' to the coding system actually used. */) buf = XBUFFER (workbuf); delete_all_overlays (buf); - BSET (buf, directory, BVAR (current_buffer, directory)); - BSET (buf, read_only, Qnil); - BSET (buf, filename, Qnil); - BSET (buf, undo_list, Qt); + bset_directory (buf, BVAR (current_buffer, directory)); + bset_read_only (buf, Qnil); + bset_filename (buf, Qnil); + bset_undo_list (buf, Qt); eassert (buf->overlays_before == NULL); eassert (buf->overlays_after == NULL); set_buffer_internal (buf); Ferase_buffer (); - BSET (buf, enable_multibyte_characters, Qnil); + bset_enable_multibyte_characters (buf, Qnil); insert_1_both ((char *) read_buf, nread, nread, 0, 0, 0); TEMP_SET_PT_BOTH (BEG, BEG_BYTE); @@ -4104,8 +4105,8 @@ variable `last-coding-system-used' to the coding system actually used. */) unwind_data = Fcons (BVAR (current_buffer, enable_multibyte_characters), Fcons (BVAR (current_buffer, undo_list), Fcurrent_buffer ())); - BSET (current_buffer, enable_multibyte_characters, Qnil); - BSET (current_buffer, undo_list, Qt); + bset_enable_multibyte_characters (current_buffer, Qnil); + bset_undo_list (current_buffer, Qt); record_unwind_protect (decide_coding_unwind, unwind_data); if (inserted > 0 && ! NILP (Vset_auto_coding_function)) @@ -4153,7 +4154,7 @@ variable `last-coding-system-used' to the coding system actually used. */) && NILP (replace)) /* Visiting a file with these coding system makes the buffer unibyte. */ - BSET (current_buffer, enable_multibyte_characters, Qnil); + bset_enable_multibyte_characters (current_buffer, Qnil); } coding.dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); @@ -4196,13 +4197,13 @@ variable `last-coding-system-used' to the coding system actually used. */) if (!NILP (visit)) { if (!EQ (BVAR (current_buffer, undo_list), Qt) && !nochange) - BSET (current_buffer, undo_list, Qnil); + bset_undo_list (current_buffer, Qnil); if (NILP (handler)) { current_buffer->modtime = mtime; current_buffer->modtime_size = st.st_size; - BSET (current_buffer, filename, orig_filename); + bset_filename (current_buffer, orig_filename); } SAVE_MODIFF = MODIFF; @@ -4247,7 +4248,7 @@ variable `last-coding-system-used' to the coding system actually used. */) /* Save old undo list and don't record undo for decoding. */ old_undo = BVAR (current_buffer, undo_list); - BSET (current_buffer, undo_list, Qt); + bset_undo_list (current_buffer, Qt); if (NILP (replace)) { @@ -4339,7 +4340,7 @@ variable `last-coding-system-used' to the coding system actually used. */) if (NILP (visit)) { - BSET (current_buffer, undo_list, old_undo); + bset_undo_list (current_buffer, old_undo); if (CONSP (old_undo) && inserted != old_inserted) { /* Adjust the last undo record for the size change during @@ -4354,7 +4355,7 @@ variable `last-coding-system-used' to the coding system actually used. */) else /* If undo_list was Qt before, keep it that way. Otherwise start with an empty undo_list. */ - BSET (current_buffer, undo_list, EQ (old_undo, Qt) ? Qt : Qnil); + bset_undo_list (current_buffer, EQ (old_undo, Qt) ? Qt : Qnil); unbind_to (count1, Qnil); } @@ -4594,7 +4595,7 @@ This calls `write-region-annotate-functions' at the start, and { SAVE_MODIFF = MODIFF; XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); - BSET (current_buffer, filename, visit_file); + bset_filename (current_buffer, visit_file); } UNGCPRO; return val; @@ -4810,7 +4811,7 @@ This calls `write-region-annotate-functions' at the start, and { SAVE_MODIFF = MODIFF; XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); - BSET (current_buffer, filename, visit_file); + bset_filename (current_buffer, visit_file); update_mode_lines++; } else if (quietly) diff --git a/src/fns.c b/src/fns.c index 12dca917e62..79f8e233fb5 100644 --- a/src/fns.c +++ b/src/fns.c @@ -628,7 +628,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args, ptrdiff_t thislen_byte = SBYTES (this); memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); - if (string_get_intervals (this)) + if (string_intervals (this)) { textprops[num_textprops].argnum = argnum; textprops[num_textprops].from = 0; @@ -640,7 +640,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args, /* Copy a single-byte string to a multibyte string. */ else if (STRINGP (this) && STRINGP (val)) { - if (string_get_intervals (this)) + if (string_intervals (this)) { textprops[num_textprops].argnum = argnum; textprops[num_textprops].from = 0; @@ -1060,7 +1060,7 @@ If you're not sure, whether to use `string-as-multibyte' or str_as_multibyte (SDATA (new_string), nbytes, SBYTES (string), NULL); string = new_string; - string_set_intervals (string, NULL); + set_string_intervals (string, NULL); } return string; } @@ -2150,8 +2150,8 @@ ARRAY is a vector, string, char-table, or bool-vector. */) int i; for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++) - XCHAR_TABLE (array)->contents[i] = item; - XCHAR_TABLE (array)->defalt = item; + set_char_table_contents (array, i, item); + set_char_table_defalt (array, item); } else if (STRINGP (array)) { @@ -3663,7 +3663,7 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size, /* Set up the free list. */ for (i = 0; i < sz - 1; ++i) - set_hash_next (h, i, make_number (i + 1)); + set_hash_next_slot (h, i, make_number (i + 1)); h->next_free = make_number (0); XSET_HASH_TABLE (table, h); @@ -3760,17 +3760,17 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) } #endif - h->key_and_value = larger_vector (h->key_and_value, - 2 * (new_size - old_size), -1); - h->next = larger_vector (h->next, new_size - old_size, -1); - h->hash = larger_vector (h->hash, new_size - old_size, -1); - h->index = Fmake_vector (make_number (index_size), Qnil); + set_hash_key_and_value (h, larger_vector (h->key_and_value, + 2 * (new_size - old_size), -1)); + set_hash_next (h, larger_vector (h->next, new_size - old_size, -1)); + set_hash_hash (h, larger_vector (h->hash, new_size - old_size, -1)); + set_hash_index (h, Fmake_vector (make_number (index_size), Qnil)); /* Update the free list. Do it so that new entries are added at the end of the free list. This makes some operations like maphash faster. */ for (i = old_size; i < new_size - 1; ++i) - set_hash_next (h, i, make_number (i + 1)); + set_hash_next_slot (h, i, make_number (i + 1)); if (!NILP (h->next_free)) { @@ -3781,7 +3781,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) !NILP (next)) last = next; - set_hash_next (h, XFASTINT (last), make_number (old_size)); + set_hash_next_slot (h, XFASTINT (last), make_number (old_size)); } else XSETFASTINT (h->next_free, old_size); @@ -3792,8 +3792,8 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) { EMACS_UINT hash_code = XUINT (HASH_HASH (h, i)); ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index); - set_hash_next (h, i, HASH_INDEX (h, start_of_bucket)); - set_hash_index (h, start_of_bucket, make_number (i)); + set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket)); + set_hash_index_slot (h, start_of_bucket, make_number (i)); } } } @@ -3852,16 +3852,16 @@ hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, /* Store key/value in the key_and_value vector. */ i = XFASTINT (h->next_free); h->next_free = HASH_NEXT (h, i); - set_hash_key (h, i, key); - set_hash_value (h, i, value); + set_hash_key_slot (h, i, key); + set_hash_value_slot (h, i, value); /* Remember its hash code. */ - set_hash_hash (h, i, make_number (hash)); + set_hash_hash_slot (h, i, make_number (hash)); /* Add new entry to its collision chain. */ start_of_bucket = hash % ASIZE (h->index); - set_hash_next (h, i, HASH_INDEX (h, start_of_bucket)); - set_hash_index (h, start_of_bucket, make_number (i)); + set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket)); + set_hash_index_slot (h, start_of_bucket, make_number (i)); return i; } @@ -3892,16 +3892,16 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key) { /* Take entry out of collision chain. */ if (NILP (prev)) - set_hash_index (h, start_of_bucket, HASH_NEXT (h, i)); + set_hash_index_slot (h, start_of_bucket, HASH_NEXT (h, i)); else - set_hash_next (h, XFASTINT (prev), HASH_NEXT (h, i)); + set_hash_next_slot (h, XFASTINT (prev), HASH_NEXT (h, i)); /* Clear slots in key_and_value and add the slots to the free list. */ - set_hash_key (h, i, Qnil); - set_hash_value (h, i, Qnil); - set_hash_hash (h, i, Qnil); - set_hash_next (h, i, h->next_free); + set_hash_key_slot (h, i, Qnil); + set_hash_value_slot (h, i, Qnil); + set_hash_hash_slot (h, i, Qnil); + set_hash_next_slot (h, i, h->next_free); h->next_free = make_number (i); h->count--; eassert (h->count >= 0); @@ -3927,10 +3927,10 @@ hash_clear (struct Lisp_Hash_Table *h) for (i = 0; i < size; ++i) { - set_hash_next (h, i, i < size - 1 ? make_number (i + 1) : Qnil); - set_hash_key (h, i, Qnil); - set_hash_value (h, i, Qnil); - set_hash_hash (h, i, Qnil); + set_hash_next_slot (h, i, i < size - 1 ? make_number (i + 1) : Qnil); + set_hash_key_slot (h, i, Qnil); + set_hash_value_slot (h, i, Qnil); + set_hash_hash_slot (h, i, Qnil); } for (i = 0; i < ASIZE (h->index); ++i) @@ -3994,18 +3994,18 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) { /* Take out of collision chain. */ if (NILP (prev)) - set_hash_index (h, bucket, next); + set_hash_index_slot (h, bucket, next); else - set_hash_next (h, XFASTINT (prev), next); + set_hash_next_slot (h, XFASTINT (prev), next); /* Add to free list. */ - set_hash_next (h, i, h->next_free); + set_hash_next_slot (h, i, h->next_free); h->next_free = idx; /* Clear key, value, and hash. */ - set_hash_key (h, i, Qnil); - set_hash_value (h, i, Qnil); - set_hash_hash (h, i, Qnil); + set_hash_key_slot (h, i, Qnil); + set_hash_value_slot (h, i, Qnil); + set_hash_hash_slot (h, i, Qnil); h->count--; } @@ -4512,7 +4512,7 @@ VALUE. In any case, return VALUE. */) i = hash_lookup (h, key, &hash); if (i >= 0) - set_hash_value (h, i, value); + set_hash_value_slot (h, i, value); else hash_put (h, key, value, hash); diff --git a/src/font.c b/src/font.c index c3040b8aa3f..5b9e4f1cfcf 100644 --- a/src/font.c +++ b/src/font.c @@ -23,9 +23,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <float.h> #include <stdio.h> -#include <ctype.h> #include <setjmp.h> +#include <c-ctype.h> + #include "lisp.h" #include "character.h" #include "buffer.h" @@ -1079,7 +1080,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font) p = f[XLFD_POINT_INDEX]; if (*p == '[') point_size = parse_matrix (p); - else if (isdigit (*p)) + else if (c_isdigit (*p)) point_size = atoi (p), point_size /= 10; if (point_size >= 0) ASET (font, FONT_SIZE_INDEX, make_float (point_size)); @@ -1346,7 +1347,7 @@ font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font) { int decimal = 0, size_found = 1; for (q = p + 1; *q && *q != ':'; q++) - if (! isdigit (*q)) + if (! c_isdigit (*q)) { if (*q != '.' || decimal) { @@ -1474,7 +1475,7 @@ font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font) /* Scan backwards from the end, looking for a size. */ for (p = name + len - 1; p >= name; p--) - if (!isdigit (*p)) + if (!c_isdigit (*p)) break; if ((p < name + len - 1) && ((p + 1 == name) || *p == ' ')) diff --git a/src/font.h b/src/font.h index 3e9af6df235..6e9387f7632 100644 --- a/src/font.h +++ b/src/font.h @@ -284,8 +284,11 @@ struct font /* Beyond here, there should be no more Lisp_Object components. */ - /* Maximum bound width over all existing characters of the font. On - X window, this is same as (font->max_bounds.width). */ + /* Minimum and maximum glyph widths, in pixels. Some font backends, + such as xft, lack the information to easily compute minimum and + maximum widths over all characters; in that case, these values + are approximate. */ + int min_width; int max_width; /* By which pixel size the font is opened. */ @@ -301,13 +304,10 @@ struct font /* Average width of glyphs in the font. If the font itself doesn't have that information but has glyphs of ASCII characters, the - value is the average with of those glyphs. Otherwise, the value + value is the average width of those glyphs. Otherwise, the value is 0. */ int average_width; - /* Minimum glyph width (in pixels). */ - int min_width; - /* Ascent and descent of the font (in pixels). */ int ascent, descent; diff --git a/src/fontset.c b/src/fontset.c index 3c7e931d121..c39d68a8ecf 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -1916,7 +1916,7 @@ format is the same as above. */) if (!EQ (fontset, Vdefault_fontset)) { tables[1] = Fmake_char_table (Qnil, Qnil); - XCHAR_TABLE (tables[0])->extras[0] = tables[1]; + set_char_table_extras (tables[0], 0, tables[1]); fontsets[1] = Vdefault_fontset; } @@ -1979,7 +1979,7 @@ format is the same as above. */) if (c <= MAX_5_BYTE_CHAR) char_table_set_range (tables[k], c, to, alist); else - XCHAR_TABLE (tables[k])->defalt = alist; + set_char_table_defalt (tables[k], alist); /* At last, change each elements to font names. */ for (; CONSP (alist); alist = XCDR (alist)) diff --git a/src/frame.c b/src/frame.c index ea682835a87..a00f44a1e5a 100644 --- a/src/frame.c +++ b/src/frame.c @@ -19,11 +19,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> +#define FRAME_INLINE EXTERN_INLINE + #include <stdio.h> -#include <ctype.h> #include <errno.h> #include <limits.h> #include <setjmp.h> + +#include <c-ctype.h> + #include "lisp.h" #include "character.h" #ifdef HAVE_X_WINDOWS @@ -125,6 +129,18 @@ static Lisp_Object Qdelete_frame_functions; static void x_report_frame_params (struct frame *, Lisp_Object *); #endif +/* These setters are used only in this file, so they can be private. */ +static inline void +fset_buffer_predicate (struct frame *f, Lisp_Object val) +{ + f->buffer_predicate = val; +} +static inline void +fset_minibuffer_window (struct frame *f, Lisp_Object val) +{ + f->minibuffer_window = val; +} + static void set_menu_bar_lines_1 (Lisp_Object window, int n) @@ -132,8 +148,8 @@ set_menu_bar_lines_1 (Lisp_Object window, int n) struct window *w = XWINDOW (window); w->last_modified = 0; - WSET (w, top_line, make_number (XFASTINT (w->top_line) + n)); - WSET (w, total_lines, make_number (XFASTINT (w->total_lines) - n)); + wset_top_line (w, make_number (XFASTINT (w->top_line) + n)); + wset_total_lines (w, make_number (XFASTINT (w->total_lines) - n)); /* Handle just the top child in a vertical split. */ if (!NILP (w->vchild)) @@ -269,7 +285,7 @@ make_frame (int mini_p) /* Initialize Lisp data. Note that allocate_frame initializes all Lisp data to nil, so do it only for slots which should not be nil. */ - FSET (f, tool_bar_position, Qtop); + fset_tool_bar_position (f, Qtop); /* Initialize non-Lisp data. Note that allocate_frame zeroes out all non-Lisp data, so do it only for slots which should not be zero. @@ -289,20 +305,20 @@ make_frame (int mini_p) if (mini_p) { mini_window = make_window (); - WSET (XWINDOW (root_window), next, mini_window); - WSET (XWINDOW (mini_window), prev, root_window); + wset_next (XWINDOW (root_window), mini_window); + wset_prev (XWINDOW (mini_window), root_window); XWINDOW (mini_window)->mini = 1; - WSET (XWINDOW (mini_window), frame, frame); - FSET (f, minibuffer_window, mini_window); + wset_frame (XWINDOW (mini_window), frame); + fset_minibuffer_window (f, mini_window); } else { mini_window = Qnil; - WSET (XWINDOW (root_window), next, Qnil); - FSET (f, minibuffer_window, Qnil); + wset_next (XWINDOW (root_window), Qnil); + fset_minibuffer_window (f, Qnil); } - WSET (XWINDOW (root_window), frame, frame); + wset_frame (XWINDOW (root_window), frame); /* 10 is arbitrary, just so that there is "something there." @@ -311,21 +327,21 @@ make_frame (int mini_p) SET_FRAME_COLS (f, 10); FRAME_LINES (f) = 10; - WSET (XWINDOW (root_window), total_cols, make_number (10)); - WSET (XWINDOW (root_window), total_lines, make_number (mini_p ? 9 : 10)); + wset_total_cols (XWINDOW (root_window), make_number (10)); + wset_total_lines (XWINDOW (root_window), make_number (mini_p ? 9 : 10)); if (mini_p) { - WSET (XWINDOW (mini_window), total_cols, make_number (10)); - WSET (XWINDOW (mini_window), top_line, make_number (9)); - WSET (XWINDOW (mini_window), total_lines, make_number (1)); + wset_total_cols (XWINDOW (mini_window), make_number (10)); + wset_top_line (XWINDOW (mini_window), make_number (9)); + wset_total_lines (XWINDOW (mini_window), make_number (1)); } /* Choose a buffer for the frame's root window. */ { Lisp_Object buf; - WSET (XWINDOW (root_window), buffer, Qt); + wset_buffer (XWINDOW (root_window), Qt); buf = Fcurrent_buffer (); /* If buf is a 'hidden' buffer (i.e. one whose name starts with a space), try to find another one. */ @@ -339,12 +355,12 @@ make_frame (int mini_p) etc. Running Lisp functions at this point surely ends in a SEGV. */ set_window_buffer (root_window, buf, 0, 0); - FSET (f, buffer_list, Fcons (buf, Qnil)); + fset_buffer_list (f, Fcons (buf, Qnil)); } if (mini_p) { - WSET (XWINDOW (mini_window), buffer, Qt); + wset_buffer (XWINDOW (mini_window), Qt); set_window_buffer (mini_window, (NILP (Vminibuffer_list) ? get_minibuffer (0) @@ -352,8 +368,8 @@ make_frame (int mini_p) 0, 0); } - FSET (f, root_window, root_window); - FSET (f, selected_window, root_window); + fset_root_window (f, root_window); + fset_selected_window (f, root_window); /* Make sure this window seems more recently used than a newly-created, never-selected window. */ XWINDOW (f->selected_window)->use_time = ++window_select_count; @@ -393,8 +409,8 @@ make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lis XSETFRAME (frame_dummy, f); GCPRO1 (frame_dummy); /* If there's no minibuffer frame to use, create one. */ - KSET (kb, Vdefault_minibuffer_frame, - call1 (intern ("make-initial-minibuffer-frame"), display)); + kset_default_minibuffer_frame + (kb, call1 (intern ("make-initial-minibuffer-frame"), display)); UNGCPRO; } @@ -402,7 +418,7 @@ make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lis = XFRAME (KVAR (kb, Vdefault_minibuffer_frame))->minibuffer_window; } - FSET (f, minibuffer_window, mini_window); + fset_minibuffer_window (f, mini_window); /* Make the chosen minibuffer window display the proper minibuffer, unless it is already showing a minibuffer. */ @@ -439,11 +455,12 @@ make_minibuffer_frame (void) Avoid infinite looping on the window chain by marking next pointer as nil. */ - mini_window = FSET (f, minibuffer_window, f->root_window); + mini_window = f->root_window; + fset_minibuffer_window (f, mini_window); XWINDOW (mini_window)->mini = 1; - WSET (XWINDOW (mini_window), next, Qnil); - WSET (XWINDOW (mini_window), prev, Qnil); - WSET (XWINDOW (mini_window), frame, frame); + wset_next (XWINDOW (mini_window), Qnil); + wset_prev (XWINDOW (mini_window), Qnil); + wset_frame (XWINDOW (mini_window), frame); /* Put the proper buffer in that window. */ @@ -482,7 +499,7 @@ make_initial_frame (void) Vframe_list = Fcons (frame, Vframe_list); tty_frame_count = 1; - FSET (f, name, build_pure_c_string ("F1")); + fset_name (f, build_pure_c_string ("F1")); f->visible = 1; f->async_visible = 1; @@ -523,7 +540,7 @@ make_terminal_frame (struct terminal *terminal) XSETFRAME (frame, f); Vframe_list = Fcons (frame, Vframe_list); - FSET (f, name, make_formatted_string (name, "F%"pMd, ++tty_frame_count)); + fset_name (f, make_formatted_string (name, "F%"pMd, ++tty_frame_count)); f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ f->async_visible = 1; /* Don't let visible be cleared later. */ @@ -693,7 +710,7 @@ affects all frames on the same terminal device. */) /* Make the frame face alist be frame-specific, so that each frame could change its face definitions independently. */ - FSET (f, face_alist, Fcopy_alist (sf->face_alist)); + fset_face_alist (f, Fcopy_alist (sf->face_alist)); /* Simple Fcopy_alist isn't enough, because we need the contents of the vectors which are the CDRs of associations in face_alist to be copied as well. */ @@ -847,7 +864,7 @@ to that frame. */) (Lisp_Object event) { /* Preserve prefix arg that the command loop just cleared. */ - KSET (current_kboard, Vprefix_arg, Vcurrent_prefix_arg); + kset_prefix_arg (current_kboard, Vcurrent_prefix_arg); Frun_hooks (1, &Qmouse_leave_buffer_hook); return do_switch_frame (event, 0, 0, Qnil); } @@ -1280,7 +1297,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* Mark all the windows that used to be on FRAME as deleted, and then remove the reference to them. */ delete_all_child_windows (f->root_window); - FSET (f, root_window, Qnil); + fset_root_window (f, Qnil); Vframe_list = Fdelq (frame, Vframe_list); FRAME_SET_VISIBLE (f, 0); @@ -1289,7 +1306,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) garbage collection. The frame object itself may not be garbage collected until much later, because recent_keys and other data structures can still refer to it. */ - FSET (f, menu_bar_vector, Qnil); + fset_menu_bar_vector (f, Qnil); free_font_driver_list (f); xfree (f->namebuf); @@ -1441,11 +1458,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force) if (NILP (frame_with_minibuf)) abort (); - KSET (kb, Vdefault_minibuffer_frame, frame_with_minibuf); + kset_default_minibuffer_frame (kb, frame_with_minibuf); } else /* No frames left on this kboard--say no minibuffer either. */ - KSET (kb, Vdefault_minibuffer_frame, Qnil); + kset_default_minibuffer_frame (kb, Qnil); } /* Cause frame titles to update--necessary if we now have just one frame. */ @@ -1683,7 +1700,7 @@ make_frame_visible_1 (Lisp_Object window) w = XWINDOW (window); if (!NILP (w->buffer)) - BSET (XBUFFER (w->buffer), display_time, Fcurrent_time ()); + bset_display_time (XBUFFER (w->buffer), Fcurrent_time ()); if (!NILP (w->vchild)) make_frame_visible_1 (w->vchild); @@ -1917,7 +1934,7 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */) f = XFRAME (frame); - FSET (f, focus_frame, focus_frame); + fset_focus_frame (f, focus_frame); if (FRAME_TERMINAL (f)->frame_rehighlight_hook) (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f); @@ -1982,10 +1999,10 @@ frames_discard_buffer (Lisp_Object buffer) FOR_EACH_FRAME (tail, frame) { - FSET (XFRAME (frame), buffer_list, - Fdelq (buffer, XFRAME (frame)->buffer_list)); - FSET (XFRAME (frame), buried_buffer_list, - Fdelq (buffer, XFRAME (frame)->buried_buffer_list)); + fset_buffer_list + (XFRAME (frame), Fdelq (buffer, XFRAME (frame)->buffer_list)); + fset_buried_buffer_list + (XFRAME (frame), Fdelq (buffer, XFRAME (frame)->buried_buffer_list)); } } @@ -2052,7 +2069,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name) error ("Frame names of the form F<num> are usurped by Emacs"); } - FSET (f, name, name); + fset_name (f, name); update_mode_lines = 1; } @@ -2069,7 +2086,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) for (; CONSP (val); val = XCDR (val)) if (!NILP (Fbuffer_live_p (XCAR (val)))) list = Fcons (XCAR (val), list); - FSET (f, buffer_list, Fnreverse (list)); + fset_buffer_list (f, Fnreverse (list)); return; } if (EQ (prop, Qburied_buffer_list)) @@ -2078,7 +2095,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) for (; CONSP (val); val = XCDR (val)) if (!NILP (Fbuffer_live_p (XCAR (val)))) list = Fcons (XCAR (val), list); - FSET (f, buried_buffer_list, Fnreverse (list)); + fset_buried_buffer_list (f, Fnreverse (list)); return; } @@ -2096,7 +2113,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) case SYMBOL_PLAINVAL: case SYMBOL_FORWARDED: break; case SYMBOL_LOCALIZED: { struct Lisp_Buffer_Local_Value *blv = sym->val.blv; - if (blv->frame_local && BLV_FOUND (blv) && XFRAME (blv->where) == f) + if (blv->frame_local && blv_found (blv) && XFRAME (blv->where) == f) swap_in_global_binding (sym); break; } @@ -2115,7 +2132,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) /* Update the frame parameter alist. */ old_alist_elt = Fassq (prop, f->param_alist); if (EQ (old_alist_elt, Qnil)) - FSET (f, param_alist, Fcons (Fcons (prop, val), f->param_alist)); + fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); else Fsetcdr (old_alist_elt, val); @@ -2123,7 +2140,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) in addition to the alist. */ if (EQ (prop, Qbuffer_predicate)) - FSET (f, buffer_predicate, val); + fset_buffer_predicate (f, val); if (! FRAME_WINDOW_P (f)) { @@ -2143,7 +2160,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) error ("Can't change the surrogate minibuffer of a frame with its own minibuffer"); /* Install the chosen minibuffer window, with proper buffer. */ - FSET (f, minibuffer_window, val); + fset_minibuffer_window (f, val); } } @@ -3271,7 +3288,7 @@ x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu new_value = Qnil; while (*p0) { - while (*p1 && ! isspace (*p1) && *p1 != ',') p1++; + while (*p1 && ! c_isspace (*p1) && *p1 != ',') p1++; if (p0 < p1) new_value = Fcons (Fintern (make_string (p0, p1 - p0), Qnil), new_value); @@ -3279,7 +3296,7 @@ x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu { int c; - while ((c = *++p1) && isspace (c)); + while ((c = *++p1) && c_isspace (c)); } p0 = p1; } diff --git a/src/frame.h b/src/frame.h index e07974fb4d2..92fbda42c70 100644 --- a/src/frame.h +++ b/src/frame.h @@ -25,6 +25,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "dispextern.h" +INLINE_HEADER_BEGIN +#ifndef FRAME_INLINE +# define FRAME_INLINE INLINE +#endif + /* Miscellanea. */ @@ -80,10 +85,6 @@ struct terminal; struct font_driver_list; -/* Most code should use this macro to set Lisp field in struct frame. */ - -#define FSET(f, field, value) ((f)->field = (value)) - struct frame { struct vectorlike_header header; @@ -499,6 +500,109 @@ struct frame unsigned long foreground_pixel; }; +/* Most code should use these functions to set Lisp fields in struct frame. */ + +FRAME_INLINE void +fset_buffer_list (struct frame *f, Lisp_Object val) +{ + f->buffer_list = val; +} +FRAME_INLINE void +fset_buried_buffer_list (struct frame *f, Lisp_Object val) +{ + f->buried_buffer_list = val; +} +FRAME_INLINE void +fset_condemned_scroll_bars (struct frame *f, Lisp_Object val) +{ + f->condemned_scroll_bars = val; +} +FRAME_INLINE void +fset_current_tool_bar_string (struct frame *f, Lisp_Object val) +{ + f->current_tool_bar_string = val; +} +FRAME_INLINE void +fset_desired_tool_bar_string (struct frame *f, Lisp_Object val) +{ + f->desired_tool_bar_string = val; +} +FRAME_INLINE void +fset_face_alist (struct frame *f, Lisp_Object val) +{ + f->face_alist = val; +} +FRAME_INLINE void +fset_focus_frame (struct frame *f, Lisp_Object val) +{ + f->focus_frame = val; +} +FRAME_INLINE void +fset_icon_name (struct frame *f, Lisp_Object val) +{ + f->icon_name = val; +} +FRAME_INLINE void +fset_menu_bar_items (struct frame *f, Lisp_Object val) +{ + f->menu_bar_items = val; +} +FRAME_INLINE void +fset_menu_bar_vector (struct frame *f, Lisp_Object val) +{ + f->menu_bar_vector = val; +} +FRAME_INLINE void +fset_menu_bar_window (struct frame *f, Lisp_Object val) +{ + f->menu_bar_window = val; +} +FRAME_INLINE void +fset_name (struct frame *f, Lisp_Object val) +{ + f->name = val; +} +FRAME_INLINE void +fset_param_alist (struct frame *f, Lisp_Object val) +{ + f->param_alist = val; +} +FRAME_INLINE void +fset_root_window (struct frame *f, Lisp_Object val) +{ + f->root_window = val; +} +FRAME_INLINE void +fset_scroll_bars (struct frame *f, Lisp_Object val) +{ + f->scroll_bars = val; +} +FRAME_INLINE void +fset_selected_window (struct frame *f, Lisp_Object val) +{ + f->selected_window = val; +} +FRAME_INLINE void +fset_title (struct frame *f, Lisp_Object val) +{ + f->title = val; +} +FRAME_INLINE void +fset_tool_bar_items (struct frame *f, Lisp_Object val) +{ + f->tool_bar_items = val; +} +FRAME_INLINE void +fset_tool_bar_position (struct frame *f, Lisp_Object val) +{ + f->tool_bar_position = val; +} +FRAME_INLINE void +fset_tool_bar_window (struct frame *f, Lisp_Object val) +{ + f->tool_bar_window = val; +} + #define FRAME_KBOARD(f) ((f)->terminal->kboard) /* Return a pointer to the image cache of frame F. */ @@ -1146,4 +1250,6 @@ extern void set_frame_menubar (FRAME_PTR, int, int); #endif /* HAVE_WINDOW_SYSTEM */ +INLINE_HEADER_END + #endif /* not EMACS_FRAME_H */ diff --git a/src/gnutls.c b/src/gnutls.c index 5189f2098cf..a2573f6bd99 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -830,7 +830,7 @@ one trustfile (usually a CA bundle). */) XPROCESS (proc)->gnutls_state = NULL; XPROCESS (proc)->gnutls_x509_cred = NULL; XPROCESS (proc)->gnutls_anon_cred = NULL; - PSET (XPROCESS (proc), gnutls_cred_type, type); + pset_gnutls_cred_type (XPROCESS (proc), type); GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY; GNUTLS_LOG (1, max_log_level, "allocating credentials"); diff --git a/src/gtkutil.c b/src/gtkutil.c index 194a1044952..2941605d448 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -24,7 +24,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <signal.h> #include <stdio.h> #include <setjmp.h> -#include <ctype.h> + +#include <c-ctype.h> + #include "lisp.h" #include "xterm.h" #include "blockinput.h" @@ -2016,7 +2018,7 @@ xg_get_file_name (FRAME_PTR f, #if USE_NEW_GTK_FONT_CHOOSER -extern Lisp_Object Qnormal; +extern Lisp_Object Qxft, Qnormal; extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold; extern Lisp_Object Qbold, Qextra_bold, Qultra_bold; extern Lisp_Object Qoblique, Qitalic; @@ -2072,7 +2074,7 @@ xg_get_font (FRAME_PTR f, const char *default_name) if (p) { char *ep = p+1; - while (isdigit (*ep)) + while (c_isdigit (*ep)) ++ep; if (*ep == '\0') *p = ' '; } @@ -2099,7 +2101,7 @@ xg_get_font (FRAME_PTR f, const char *default_name) if (desc) { - Lisp_Object args[8]; + Lisp_Object args[10]; const char *name = pango_font_description_get_family (desc); gint size = pango_font_description_get_size (desc); PangoWeight weight = pango_font_description_get_weight (desc); @@ -2117,6 +2119,9 @@ xg_get_font (FRAME_PTR f, const char *default_name) args[6] = QCslant; args[7] = XG_STYLE_TO_SYMBOL (style); + args[8] = QCtype; + args[9] = Qxft; + font = Ffont_spec (8, args); pango_font_description_free (desc); @@ -2259,7 +2264,7 @@ xg_mark_data (void) { FRAME_PTR f = XFRAME (frame); - if (FRAME_X_OUTPUT (f) && FRAME_GTK_OUTER_WIDGET (f)) + if (FRAME_X_P (f) && FRAME_GTK_OUTER_WIDGET (f)) { struct xg_frame_tb_info *tbinfo = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)), diff --git a/src/image.c b/src/image.c index 8a318c2f6ec..f2778165ece 100644 --- a/src/image.c +++ b/src/image.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <math.h> -#include <ctype.h> #include <unistd.h> #ifdef HAVE_PNG @@ -33,6 +32,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <setjmp.h> +#include <c-ctype.h> + /* This makes the fields of a Display accessible, in Xlib header files. */ #define XLIB_ILLEGAL_ACCESS @@ -2405,12 +2406,12 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) loop: /* Skip white space. */ - while (*s < end && (c = *(*s)++, isspace (c))) + while (*s < end && (c = *(*s)++, c_isspace (c))) ; if (*s >= end) c = 0; - else if (isdigit (c)) + else if (c_isdigit (c)) { int value = 0, digit; @@ -2422,7 +2423,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) while (*s < end) { c = *(*s)++; - if (isdigit (c)) + if (c_isdigit (c)) digit = c - '0'; else if (c >= 'a' && c <= 'f') digit = c - 'a' + 10; @@ -2433,11 +2434,11 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) value = 16 * value + digit; } } - else if (isdigit (c)) + else if (c_isdigit (c)) { value = c - '0'; while (*s < end - && (c = *(*s)++, isdigit (c))) + && (c = *(*s)++, c_isdigit (c))) value = 8 * value + c - '0'; } } @@ -2445,7 +2446,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) { value = c - '0'; while (*s < end - && (c = *(*s)++, isdigit (c))) + && (c = *(*s)++, c_isdigit (c))) value = 10 * value + c - '0'; } @@ -2454,11 +2455,11 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) *ival = value; c = XBM_TK_NUMBER; } - else if (isalpha (c) || c == '_') + else if (c_isalpha (c) || c == '_') { *sval++ = c; while (*s < end - && (c = *(*s)++, (isalnum (c) || c == '_'))) + && (c = *(*s)++, (c_isalnum (c) || c == '_'))) *sval++ = c; *sval = 0; if (*s < end) @@ -3661,16 +3662,17 @@ xpm_scan (const unsigned char **s, while (*s < end) { /* Skip white-space. */ - while (*s < end && (c = *(*s)++, isspace (c))) + while (*s < end && (c = *(*s)++, c_isspace (c))) ; /* gnus-pointer.xpm uses '-' in its identifier. sb-dir-plus.xpm uses '+' in its identifier. */ - if (isalpha (c) || c == '_' || c == '-' || c == '+') + if (c_isalpha (c) || c == '_' || c == '-' || c == '+') { *beg = *s - 1; while (*s < end - && (c = **s, isalnum (c) || c == '_' || c == '-' || c == '+')) + && (c = **s, c_isalnum (c) + || c == '_' || c == '-' || c == '+')) ++*s; *len = *s - *beg; return XPM_TK_IDENT; @@ -5014,7 +5016,7 @@ pbm_scan_number (unsigned char **s, unsigned char *end) while (*s < end) { /* Skip white-space. */ - while (*s < end && (c = *(*s)++, isspace (c))) + while (*s < end && (c = *(*s)++, c_isspace (c))) ; if (c == '#') @@ -5023,11 +5025,11 @@ pbm_scan_number (unsigned char **s, unsigned char *end) while (*s < end && (c = *(*s)++, c != '\n')) ; } - else if (isdigit (c)) + else if (c_isdigit (c)) { /* Read decimal number. */ val = c - '0'; - while (*s < end && (c = *(*s)++, isdigit (c))) + while (*s < end && (c = *(*s)++, c_isdigit (c))) val = 10 * val + c - '0'; break; } @@ -8554,7 +8556,7 @@ gs_load (struct frame *f, struct image *img) don't either. Let the Lisp loader use `unwind-protect' instead. */ printnum1 = FRAME_X_WINDOW (f); printnum2 = img->pixmap; - window_and_pixmap_id + window_and_pixmap_id = make_formatted_string (buffer, "%"pMu" %"pMu, printnum1, printnum2); printnum1 = FRAME_FOREGROUND_PIXEL (f); diff --git a/src/indent.c b/src/indent.c index 881e5d7ddaf..160b8c7479e 100644 --- a/src/indent.c +++ b/src/indent.c @@ -141,7 +141,7 @@ recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab) struct Lisp_Vector *widthtab; if (!VECTORP (BVAR (buf, width_table))) - BSET (buf, width_table, Fmake_vector (make_number (256), make_number (0))); + bset_width_table (buf, Fmake_vector (make_number (256), make_number (0))); widthtab = XVECTOR (BVAR (buf, width_table)); if (widthtab->header.size != 256) abort (); @@ -166,7 +166,7 @@ width_run_cache_on_off (void) { free_region_cache (current_buffer->width_run_cache); current_buffer->width_run_cache = 0; - BSET (current_buffer, width_table, Qnil); + bset_width_table (current_buffer, Qnil); } } else @@ -336,7 +336,7 @@ current_column (void) /* If the buffer has overlays, text properties, or multibyte characters, use a more general algorithm. */ - if (buffer_get_intervals (current_buffer) + if (buffer_intervals (current_buffer) || buffer_has_overlays () || Z != Z_BYTE) return current_column_1 (); @@ -2003,7 +2003,7 @@ whether or not it is currently displayed in some window. */) old_buffer = w->buffer; old_charpos = XMARKER (w->pointm)->charpos; old_bytepos = XMARKER (w->pointm)->bytepos; - WSET (w, buffer, Fcurrent_buffer ()); + wset_buffer (w, Fcurrent_buffer ()); set_marker_both (w->pointm, w->buffer, BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer)); } @@ -2146,7 +2146,7 @@ whether or not it is currently displayed in some window. */) if (BUFFERP (old_buffer)) { - WSET (w, buffer, old_buffer); + wset_buffer (w, old_buffer); set_marker_both (w->pointm, w->buffer, old_charpos, old_bytepos); } diff --git a/src/insdel.c b/src/insdel.c index 14d2dab084d..1dceb67bffa 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -844,10 +844,10 @@ insert_1_both (const char *string, PT + nchars, PT_BYTE + nbytes, before_markers); - if (buffer_get_intervals (current_buffer)) + if (buffer_intervals (current_buffer)) offset_intervals (current_buffer, PT, nchars); - if (!inherit && buffer_get_intervals (current_buffer)) + if (!inherit && buffer_intervals (current_buffer)) set_text_properties (make_number (PT), make_number (PT + nchars), Qnil, Qnil, Qnil); @@ -976,7 +976,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, offset_intervals (current_buffer, PT, nchars); - intervals = string_get_intervals (string); + intervals = string_intervals (string); /* Get the intervals for the part of the string we are inserting. */ if (nbytes < SBYTES (string)) intervals = copy_intervals (intervals, pos, nchars); @@ -1017,7 +1017,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes) adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes, GPT, GPT_BYTE, 0); - if (buffer_get_intervals (current_buffer)) + if (buffer_intervals (current_buffer)) { offset_intervals (current_buffer, GPT - nchars, nchars); graft_intervals_into_buffer (NULL, GPT - nchars, nchars, @@ -1157,11 +1157,11 @@ insert_from_buffer_1 (struct buffer *buf, PT_BYTE + outgoing_nbytes, 0); - if (buffer_get_intervals (current_buffer)) + if (buffer_intervals (current_buffer)) offset_intervals (current_buffer, PT, nchars); /* Get the intervals for the part of the string we are inserting. */ - intervals = buffer_get_intervals (buf); + intervals = buffer_intervals (buf); if (nchars < BUF_Z (buf) - BUF_BEG (buf)) { if (buf == current_buffer && PT <= from) @@ -1226,7 +1226,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, else if (len < nchars_del) adjust_overlays_for_delete (from, nchars_del - len); - if (buffer_get_intervals (current_buffer)) + if (buffer_intervals (current_buffer)) offset_intervals (current_buffer, from, len - nchars_del); if (from < PT) @@ -1412,7 +1412,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, /* Get the intervals for the part of the string we are inserting-- not including the combined-before bytes. */ - intervals = string_get_intervals (new); + intervals = string_intervals (new); /* Insert those intervals. */ graft_intervals_into_buffer (intervals, from, inschars, current_buffer, inherit); @@ -1792,7 +1792,7 @@ modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end, if (! preserve_chars_modiff) CHARS_MODIFF = MODIFF; - BSET (buffer, point_before_scroll, Qnil); + bset_point_before_scroll (buffer, Qnil); if (buffer != old_buffer) set_buffer_internal (old_buffer); @@ -1822,7 +1822,7 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end, if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) ++windows_or_buffers_changed; - if (buffer_get_intervals (current_buffer)) + if (buffer_intervals (current_buffer)) { if (preserve_ptr) { diff --git a/src/intervals.c b/src/intervals.c index 09949bbbd45..0a85e20e5d9 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -59,10 +59,41 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object); static INTERVAL merge_interval_right (INTERVAL); static INTERVAL reproduce_tree (INTERVAL, INTERVAL); -static INTERVAL reproduce_tree_obj (INTERVAL, Lisp_Object); /* Utility functions for intervals. */ +/* Use these functions to set Lisp_Object + or pointer slots of struct interval. */ + +static inline void +set_interval_object (INTERVAL i, Lisp_Object obj) +{ + eassert (BUFFERP (obj) || STRINGP (obj)); + i->up_obj = 1; + i->up.obj = obj; +} + +static inline void +set_interval_left (INTERVAL i, INTERVAL left) +{ + i->left = left; +} + +static inline void +set_interval_right (INTERVAL i, INTERVAL right) +{ + i->right = right; +} + +/* Make the parent of D be whatever the parent of S is, regardless + of the type. This is used when balancing an interval tree. */ + +static inline void +copy_interval_parent (INTERVAL d, INTERVAL s) +{ + d->up = s->up; + d->up_obj = s->up_obj; +} /* Create the root interval of some object, a buffer or string. */ @@ -80,18 +111,18 @@ create_root_interval (Lisp_Object parent) new->total_length = (BUF_Z (XBUFFER (parent)) - BUF_BEG (XBUFFER (parent))); eassert (0 <= TOTAL_LENGTH (new)); - buffer_set_intervals (XBUFFER (parent), new); + set_buffer_intervals (XBUFFER (parent), new); new->position = BEG; } else if (STRINGP (parent)) { new->total_length = SCHARS (parent); eassert (0 <= TOTAL_LENGTH (new)); - string_set_intervals (parent, new); + set_string_intervals (parent, new); new->position = 0; } - interval_set_object (new, parent); + set_interval_object (new, parent); return new; } @@ -105,7 +136,7 @@ copy_properties (register INTERVAL source, register INTERVAL target) return; COPY_INTERVAL_CACHE (source, target); - interval_set_plist (target, Fcopy_sequence (source->plist)); + set_interval_plist (target, Fcopy_sequence (source->plist)); } /* Merge the properties of interval SOURCE into the properties @@ -141,7 +172,7 @@ merge_properties (register INTERVAL source, register INTERVAL target) if (NILP (val)) { val = XCAR (o); - interval_set_plist (target, Fcons (sym, Fcons (val, target->plist))); + set_interval_plist (target, Fcons (sym, Fcons (val, target->plist))); } o = XCDR (o); } @@ -323,21 +354,21 @@ rotate_right (INTERVAL interval) if (! ROOT_INTERVAL_P (interval)) { if (AM_LEFT_CHILD (interval)) - interval_set_left (INTERVAL_PARENT (interval), B); + set_interval_left (INTERVAL_PARENT (interval), B); else - interval_set_right (INTERVAL_PARENT (interval), B); + set_interval_right (INTERVAL_PARENT (interval), B); } - interval_copy_parent (B, interval); + copy_interval_parent (B, interval); /* Make B the parent of A */ i = B->right; - interval_set_right (B, interval); - interval_set_parent (interval, B); + set_interval_right (B, interval); + set_interval_parent (interval, B); /* Make A point to c */ - interval_set_left (interval, i); + set_interval_left (interval, i); if (i) - interval_set_parent (i, interval); + set_interval_parent (i, interval); /* A's total length is decreased by the length of B and its left child. */ interval->total_length -= B->total_length - LEFT_TOTAL_LENGTH (interval); @@ -370,21 +401,21 @@ rotate_left (INTERVAL interval) if (! ROOT_INTERVAL_P (interval)) { if (AM_LEFT_CHILD (interval)) - interval_set_left (INTERVAL_PARENT (interval), B); + set_interval_left (INTERVAL_PARENT (interval), B); else - interval_set_right (INTERVAL_PARENT (interval), B); + set_interval_right (INTERVAL_PARENT (interval), B); } - interval_copy_parent (B, interval); + copy_interval_parent (B, interval); /* Make B the parent of A */ i = B->left; - interval_set_left (B, interval); - interval_set_parent (interval, B); + set_interval_left (B, interval); + set_interval_parent (interval, B); /* Make A point to c */ - interval_set_right (interval, i); + set_interval_right (interval, i); if (i) - interval_set_parent (i, interval); + set_interval_parent (i, interval); /* A's total length is decreased by the length of B and its right child. */ interval->total_length -= B->total_length - RIGHT_TOTAL_LENGTH (interval); @@ -456,9 +487,9 @@ balance_possible_root_interval (register INTERVAL interval) if (have_parent) { if (BUFFERP (parent)) - buffer_set_intervals (XBUFFER (parent), interval); + set_buffer_intervals (XBUFFER (parent), interval); else if (STRINGP (parent)) - string_set_intervals (parent, interval); + set_string_intervals (parent, interval); } return interval; @@ -494,9 +525,9 @@ buffer_balance_intervals (struct buffer *b) INTERVAL i; eassert (b != NULL); - i = buffer_get_intervals (b); + i = buffer_intervals (b); if (i) - buffer_set_intervals (b, balance_an_interval (i)); + set_buffer_intervals (b, balance_an_interval (i)); } /* Split INTERVAL into two pieces, starting the second piece at @@ -520,20 +551,20 @@ split_interval_right (INTERVAL interval, ptrdiff_t offset) ptrdiff_t new_length = LENGTH (interval) - offset; new->position = position + offset; - interval_set_parent (new, interval); + set_interval_parent (new, interval); if (NULL_RIGHT_CHILD (interval)) { - interval_set_right (interval, new); + set_interval_right (interval, new); new->total_length = new_length; eassert (0 <= TOTAL_LENGTH (new)); } else { /* Insert the new node between INTERVAL and its right child. */ - interval_set_right (new, interval->right); - interval_set_parent (interval->right, new); - interval_set_right (interval, new); + set_interval_right (new, interval->right); + set_interval_parent (interval->right, new); + set_interval_right (interval, new); new->total_length = new_length + new->right->total_length; eassert (0 <= TOTAL_LENGTH (new)); balance_an_interval (new); @@ -565,20 +596,20 @@ split_interval_left (INTERVAL interval, ptrdiff_t offset) new->position = interval->position; interval->position = interval->position + offset; - interval_set_parent (new, interval); + set_interval_parent (new, interval); if (NULL_LEFT_CHILD (interval)) { - interval_set_left (interval, new); + set_interval_left (interval, new); new->total_length = new_length; eassert (0 <= TOTAL_LENGTH (new)); } else { /* Insert the new node between INTERVAL and its left child. */ - interval_set_left (new, interval->left); - interval_set_parent (new->left, new); - interval_set_left (interval, new); + set_interval_left (new, interval->left); + set_interval_parent (new->left, new); + set_interval_left (interval, new); new->total_length = new_length + new->left->total_length; eassert (0 <= TOTAL_LENGTH (new)); balance_an_interval (new); @@ -953,20 +984,20 @@ adjust_intervals_for_insertion (INTERVAL tree, RESET_INTERVAL (&newi); pleft = prev ? prev->plist : Qnil; pright = i ? i->plist : Qnil; - interval_set_plist (&newi, merge_properties_sticky (pleft, pright)); + set_interval_plist (&newi, merge_properties_sticky (pleft, pright)); if (! prev) /* i.e. position == BEG */ { if (! intervals_equal (i, &newi)) { i = split_interval_left (i, length); - interval_set_plist (i, newi.plist); + set_interval_plist (i, newi.plist); } } else if (! intervals_equal (prev, &newi)) { prev = split_interval_right (prev, position - prev->position); - interval_set_plist (prev, newi.plist); + set_interval_plist (prev, newi.plist); if (i && intervals_equal (prev, i)) merge_interval_right (prev); } @@ -1191,8 +1222,8 @@ delete_node (register INTERVAL i) this->total_length += migrate_amt; } eassert (0 <= TOTAL_LENGTH (this)); - interval_set_left (this, migrate); - interval_set_parent (migrate, this); + set_interval_left (this, migrate); + set_interval_parent (migrate, this); return i->right; } @@ -1217,12 +1248,12 @@ delete_interval (register INTERVAL i) GET_INTERVAL_OBJECT (owner, i); parent = delete_node (i); if (parent) - interval_set_object (parent, owner); + set_interval_object (parent, owner); if (BUFFERP (owner)) - buffer_set_intervals (XBUFFER (owner), parent); + set_buffer_intervals (XBUFFER (owner), parent); else if (STRINGP (owner)) - string_set_intervals (owner, parent); + set_string_intervals (owner, parent); else abort (); @@ -1232,15 +1263,15 @@ delete_interval (register INTERVAL i) parent = INTERVAL_PARENT (i); if (AM_LEFT_CHILD (i)) { - interval_set_left (parent, delete_node (i)); + set_interval_left (parent, delete_node (i)); if (parent->left) - interval_set_parent (parent->left, parent); + set_interval_parent (parent->left, parent); } else { - interval_set_right (parent, delete_node (i)); + set_interval_right (parent, delete_node (i)); if (parent->right) - interval_set_parent (parent->right, parent); + set_interval_parent (parent->right, parent); } } @@ -1321,8 +1352,8 @@ static void adjust_intervals_for_deletion (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length) { - register ptrdiff_t left_to_delete = length; - register INTERVAL tree = buffer_get_intervals (buffer); + ptrdiff_t left_to_delete = length; + INTERVAL tree = buffer_intervals (buffer); Lisp_Object parent; ptrdiff_t offset; @@ -1337,7 +1368,7 @@ adjust_intervals_for_deletion (struct buffer *buffer, if (length == TOTAL_LENGTH (tree)) { - buffer_set_intervals (buffer, NULL); + set_buffer_intervals (buffer, NULL); return; } @@ -1354,10 +1385,10 @@ adjust_intervals_for_deletion (struct buffer *buffer, { left_to_delete -= interval_deletion_adjustment (tree, start - offset, left_to_delete); - tree = buffer_get_intervals (buffer); + tree = buffer_intervals (buffer); if (left_to_delete == tree->total_length) { - buffer_set_intervals (buffer, NULL); + set_buffer_intervals (buffer, NULL); return; } } @@ -1371,11 +1402,11 @@ adjust_intervals_for_deletion (struct buffer *buffer, void offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length) { - if (!buffer_get_intervals (buffer) || length == 0) + if (!buffer_intervals (buffer) || length == 0) return; if (length > 0) - adjust_intervals_for_insertion (buffer_get_intervals (buffer), + adjust_intervals_for_insertion (buffer_intervals (buffer), start, length); else { @@ -1498,6 +1529,26 @@ merge_interval_left (register INTERVAL i) abort (); } +/* Create a copy of SOURCE but with the default value of UP. */ + +static INTERVAL +reproduce_interval (INTERVAL source) +{ + register INTERVAL target = make_interval (); + + target->total_length = source->total_length; + target->position = source->position; + + copy_properties (source, target); + + if (! NULL_LEFT_CHILD (source)) + set_interval_left (target, reproduce_tree (source->left, target)); + if (! NULL_RIGHT_CHILD (source)) + set_interval_right (target, reproduce_tree (source->right, target)); + + return target; +} + /* Make an exact copy of interval tree SOURCE which descends from PARENT. This is done by recursing through SOURCE, copying the current interval and its properties, and then adjusting @@ -1506,33 +1557,17 @@ merge_interval_left (register INTERVAL i) static INTERVAL reproduce_tree (INTERVAL source, INTERVAL parent) { - register INTERVAL t = make_interval (); - - memcpy (t, source, sizeof *t); - copy_properties (source, t); - interval_set_parent (t, parent); - if (! NULL_LEFT_CHILD (source)) - interval_set_left (t, reproduce_tree (source->left, t)); - if (! NULL_RIGHT_CHILD (source)) - interval_set_right (t, reproduce_tree (source->right, t)); - - return t; + INTERVAL target = reproduce_interval (source); + set_interval_parent (target, parent); + return target; } static INTERVAL reproduce_tree_obj (INTERVAL source, Lisp_Object parent) { - register INTERVAL t = make_interval (); - - memcpy (t, source, sizeof *t); - copy_properties (source, t); - interval_set_object (t, parent); - if (! NULL_LEFT_CHILD (source)) - interval_set_left (t, reproduce_tree (source->left, t)); - if (! NULL_RIGHT_CHILD (source)) - interval_set_right (t, reproduce_tree (source->right, t)); - - return t; + INTERVAL target = reproduce_interval (source); + set_interval_object (target, parent); + return target; } /* Insert the intervals of SOURCE into BUFFER at POSITION. @@ -1577,12 +1612,10 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position, ptrdiff_t length, struct buffer *buffer, int inherit) { - register INTERVAL under, over, this; - register INTERVAL tree; + INTERVAL tree = buffer_intervals (buffer); + INTERVAL under, over, this; ptrdiff_t over_used; - tree = buffer_get_intervals (buffer); - /* If the new text has no properties, then with inheritance it becomes part of whatever interval it was inserted into. To prevent inheritance, we must clear out the properties @@ -1611,9 +1644,9 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position, Lisp_Object buf; XSETBUFFER (buf, buffer); - buffer_set_intervals (buffer, reproduce_tree_obj (source, buf)); - buffer_get_intervals (buffer)->position = BUF_BEG (buffer); - eassert (buffer_get_intervals (buffer)->up_obj == 1); + set_buffer_intervals (buffer, reproduce_tree_obj (source, buf)); + buffer_intervals (buffer)->position = BUF_BEG (buffer); + eassert (buffer_intervals (buffer)->up_obj == 1); return; } else if (!tree) @@ -1854,7 +1887,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) int have_overlays; ptrdiff_t original_position; - BSET (current_buffer, point_before_scroll, Qnil); + bset_point_before_scroll (current_buffer, Qnil); if (charpos == PT) return; @@ -1871,7 +1904,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) /* If we have no text properties and overlays, then we can do it quickly. */ - if (!buffer_get_intervals (current_buffer) && ! have_overlays) + if (!buffer_intervals (current_buffer) && ! have_overlays) { temp_set_point_both (current_buffer, charpos, bytepos); return; @@ -1880,7 +1913,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) /* Set TO to the interval containing the char after CHARPOS, and TOPREV to the interval containing the char before CHARPOS. Either one may be null. They may be equal. */ - to = find_interval (buffer_get_intervals (current_buffer), charpos); + to = find_interval (buffer_intervals (current_buffer), charpos); if (charpos == BEGV) toprev = 0; else if (to && to->position == charpos) @@ -1894,7 +1927,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) and FROMPREV to the interval containing the char before PT. Either one may be null. They may be equal. */ /* We could cache this and save time. */ - from = find_interval (buffer_get_intervals (current_buffer), buffer_point); + from = find_interval (buffer_intervals (current_buffer), buffer_point); if (buffer_point == BEGV) fromprev = 0; else if (from && from->position == PT) @@ -2000,7 +2033,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) /* Set TO to the interval containing the char after CHARPOS, and TOPREV to the interval containing the char before CHARPOS. Either one may be null. They may be equal. */ - to = find_interval (buffer_get_intervals (current_buffer), charpos); + to = find_interval (buffer_intervals (current_buffer), charpos); if (charpos == BEGV) toprev = 0; else if (to && to->position == charpos) @@ -2133,11 +2166,11 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val, INTERVAL i, prev, next; if (NILP (object)) - i = find_interval (buffer_get_intervals (current_buffer), pos); + i = find_interval (buffer_intervals (current_buffer), pos); else if (BUFFERP (object)) - i = find_interval (buffer_get_intervals (XBUFFER (object)), pos); + i = find_interval (buffer_intervals (XBUFFER (object)), pos); else if (STRINGP (object)) - i = find_interval (string_get_intervals (object), pos); + i = find_interval (string_intervals (object), pos); else abort (); @@ -2264,13 +2297,13 @@ void copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, ptrdiff_t position, ptrdiff_t length) { - INTERVAL interval_copy = copy_intervals (buffer_get_intervals (buffer), + INTERVAL interval_copy = copy_intervals (buffer_intervals (buffer), position, length); if (!interval_copy) return; - interval_set_object (interval_copy, string); - string_set_intervals (string, interval_copy); + set_interval_object (interval_copy, string); + set_string_intervals (string, interval_copy); } /* Return 1 if strings S1 and S2 have identical properties; 0 otherwise. @@ -2283,8 +2316,8 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2) ptrdiff_t pos = 0; ptrdiff_t end = SCHARS (s1); - i1 = find_interval (string_get_intervals (s1), 0); - i2 = find_interval (string_get_intervals (s2), 0); + i1 = find_interval (string_intervals (s1), 0); + i2 = find_interval (string_intervals (s2), 0); while (pos < end) { @@ -2409,13 +2442,13 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag, { if ((i)->left) { - interval_set_plist (i, i->left->plist); + set_interval_plist (i, i->left->plist); (i)->left->total_length = 0; delete_interval ((i)->left); } else { - interval_set_plist (i, i->right->plist); + set_interval_plist (i, i->right->plist); (i)->right->total_length = 0; delete_interval ((i)->right); } @@ -2429,7 +2462,7 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag, void set_intervals_multibyte (int multi_flag) { - INTERVAL i = buffer_get_intervals (current_buffer); + INTERVAL i = buffer_intervals (current_buffer); if (i) set_intervals_multibyte_1 (i, multi_flag, BEG, BEG_BYTE, Z, Z_BYTE); diff --git a/src/intervals.h b/src/intervals.h index a5166c6376f..01e72d7c9db 100644 --- a/src/intervals.h +++ b/src/intervals.h @@ -137,47 +137,16 @@ struct interval or pointer slots of struct interval. */ INTERVALS_INLINE void -interval_set_parent (INTERVAL i, INTERVAL parent) +set_interval_parent (INTERVAL i, INTERVAL parent) { i->up_obj = 0; i->up.interval = parent; } INTERVALS_INLINE void -interval_set_object (INTERVAL i, Lisp_Object obj) -{ - eassert (BUFFERP (obj) || STRINGP (obj)); - i->up_obj = 1; - i->up.obj = obj; -} - -INTERVALS_INLINE void -interval_set_left (INTERVAL i, INTERVAL left) -{ - i->left = left; -} - -INTERVALS_INLINE void -interval_set_right (INTERVAL i, INTERVAL right) -{ - i->right = right; -} - -INTERVALS_INLINE Lisp_Object -interval_set_plist (INTERVAL i, Lisp_Object plist) +set_interval_plist (INTERVAL i, Lisp_Object plist) { i->plist = plist; - return plist; -} - -/* Make the parent of D be whatever the parent of S is, regardless - of the type. This is used when balancing an interval tree. */ - -INTERVALS_INLINE void -interval_copy_parent (INTERVAL d, INTERVAL s) -{ - d->up = s->up; - d->up_obj = s->up_obj; } /* Get the parent interval, if any, otherwise a null pointer. Useful @@ -191,11 +160,11 @@ interval_copy_parent (INTERVAL d, INTERVAL s) { \ (i)->total_length = (i)->position = 0; \ (i)->left = (i)->right = NULL; \ - interval_set_parent (i, NULL); \ + set_interval_parent (i, NULL); \ (i)->write_protect = 0; \ (i)->visible = 0; \ (i)->front_sticky = (i)->rear_sticky = 0; \ - interval_set_plist (i, Qnil); \ + set_interval_plist (i, Qnil); \ } /* Copy the cached property values of interval FROM to interval TO. */ diff --git a/src/keyboard.c b/src/keyboard.c index 4d0c98f3529..868d0c8d2c1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -18,6 +18,9 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> + +#define KEYBOARD_INLINE EXTERN_INLINE + #include <signal.h> #include <stdio.h> #include <setjmp.h> @@ -469,6 +472,53 @@ static void handle_user_signal (int); static char *find_user_signal_name (int); static int store_user_signal_events (void); +/* These setters are used only in this file, so they can be private. */ +static inline void +kset_echo_string (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (echo_string) = val; +} +static inline void +kset_kbd_queue (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (kbd_queue) = val; +} +static inline void +kset_keyboard_translate_table (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vkeyboard_translate_table) = val; +} +static inline void +kset_last_prefix_arg (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vlast_prefix_arg) = val; +} +static inline void +kset_last_repeatable_command (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vlast_repeatable_command) = val; +} +static inline void +kset_local_function_key_map (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vlocal_function_key_map) = val; +} +static inline void +kset_overriding_terminal_local_map (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Voverriding_terminal_local_map) = val; +} +static inline void +kset_real_last_command (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vreal_last_command) = val; +} +static inline void +kset_system_key_syms (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (system_key_syms) = val; +} + /* Add C to the echo string, if echoing is going on. C can be a character, which is printed prettily ("M-C-x" and all that @@ -551,8 +601,9 @@ echo_char (Lisp_Object c) else if (STRINGP (echo_string)) echo_string = concat2 (echo_string, build_string (" ")); - KSET (current_kboard, echo_string, - concat2 (echo_string, make_string (buffer, ptr - buffer))); + kset_echo_string + (current_kboard, + concat2 (echo_string, make_string (buffer, ptr - buffer))); echo_now (); } @@ -597,8 +648,9 @@ echo_dash (void) /* Put a dash at the end of the buffer temporarily, but make it go away when the next character is added. */ - KSET (current_kboard, echo_string, - concat2 (KVAR (current_kboard, echo_string), build_string ("-"))); + kset_echo_string + (current_kboard, + concat2 (KVAR (current_kboard, echo_string), build_string ("-"))); echo_now (); } @@ -660,7 +712,7 @@ cancel_echoing (void) { current_kboard->immediate_echo = 0; current_kboard->echo_after_prompt = -1; - KSET (current_kboard, echo_string, Qnil); + kset_echo_string (current_kboard, Qnil); ok_to_echo_at_next_pause = NULL; echo_kboard = NULL; echo_message_buffer = Qnil; @@ -684,9 +736,9 @@ static void echo_truncate (ptrdiff_t nchars) { if (STRINGP (KVAR (current_kboard, echo_string))) - KSET (current_kboard, echo_string, - Fsubstring (KVAR (current_kboard, echo_string), - make_number (0), make_number (nchars))); + kset_echo_string (current_kboard, + Fsubstring (KVAR (current_kboard, echo_string), + make_number (0), make_number (nchars))); truncate_echo_area (nchars); } @@ -1016,8 +1068,8 @@ cmd_error (Lisp_Object data) Vstandard_input = Qt; Vexecuting_kbd_macro = Qnil; executing_kbd_macro = Qnil; - KSET (current_kboard, Vprefix_arg, Qnil); - KSET (current_kboard, Vlast_prefix_arg, Qnil); + kset_prefix_arg (current_kboard, Qnil); + kset_last_prefix_arg (current_kboard, Qnil); cancel_echoing (); /* Avoid unquittable loop if data contains a circular list. */ @@ -1338,8 +1390,8 @@ command_loop_1 (void) #endif int already_adjusted = 0; - KSET (current_kboard, Vprefix_arg, Qnil); - KSET (current_kboard, Vlast_prefix_arg, Qnil); + kset_prefix_arg (current_kboard, Qnil); + kset_last_prefix_arg (current_kboard, Qnil); Vdeactivate_mark = Qnil; waiting_for_input = 0; cancel_echoing (); @@ -1371,10 +1423,10 @@ command_loop_1 (void) } /* Do this after running Vpost_command_hook, for consistency. */ - KSET (current_kboard, Vlast_command, Vthis_command); - KSET (current_kboard, Vreal_last_command, Vreal_this_command); + kset_last_command (current_kboard, Vthis_command); + kset_real_last_command (current_kboard, Vreal_this_command); if (!CONSP (last_command_event)) - KSET (current_kboard, Vlast_repeatable_command, Vreal_this_command); + kset_last_repeatable_command (current_kboard, Vreal_this_command); while (1) { @@ -1546,7 +1598,7 @@ command_loop_1 (void) keys = Fkey_description (keys, Qnil); bitch_at_user (); message_with_string ("%s is undefined", keys, 0); - KSET (current_kboard, defining_kbd_macro, Qnil); + kset_defining_kbd_macro (current_kboard, Qnil); update_mode_lines = 1; /* If this is a down-mouse event, don't reset prefix-arg; pass it to the command run by the up event. */ @@ -1556,10 +1608,10 @@ command_loop_1 (void) = parse_modifiers (EVENT_HEAD (last_command_event)); int modifiers = XINT (XCAR (XCDR (breakdown))); if (!(modifiers & down_modifier)) - KSET (current_kboard, Vprefix_arg, Qnil); + kset_prefix_arg (current_kboard, Qnil); } else - KSET (current_kboard, Vprefix_arg, Qnil); + kset_prefix_arg (current_kboard, Qnil); } else { @@ -1596,7 +1648,7 @@ command_loop_1 (void) unbind_to (scount, Qnil); #endif } - KSET (current_kboard, Vlast_prefix_arg, Vcurrent_prefix_arg); + kset_last_prefix_arg (current_kboard, Vcurrent_prefix_arg); safe_run_hooks (Qpost_command_hook); @@ -1627,10 +1679,10 @@ command_loop_1 (void) if (NILP (KVAR (current_kboard, Vprefix_arg)) || CONSP (last_command_event)) { - KSET (current_kboard, Vlast_command, Vthis_command); - KSET (current_kboard, Vreal_last_command, Vreal_this_command); + kset_last_command (current_kboard, Vthis_command); + kset_real_last_command (current_kboard, Vreal_this_command); if (!CONSP (last_command_event)) - KSET (current_kboard, Vlast_repeatable_command, Vreal_this_command); + kset_last_repeatable_command (current_kboard, Vreal_this_command); cancel_echoing (); this_command_key_count = 0; this_command_key_count_reset = 0; @@ -2573,7 +2625,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, abort (); } if (!CONSP (last)) - KSET (kb, kbd_queue, Fcons (c, Qnil)); + kset_kbd_queue (kb, Fcons (c, Qnil)); else XSETCDR (last, Fcons (c, Qnil)); kb->kbd_queue_has_data = 1; @@ -2745,8 +2797,8 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, if (!CONSP (KVAR (current_kboard, kbd_queue))) abort (); c = XCAR (KVAR (current_kboard, kbd_queue)); - KSET (current_kboard, kbd_queue, - XCDR (KVAR (current_kboard, kbd_queue))); + kset_kbd_queue (current_kboard, + XCDR (KVAR (current_kboard, kbd_queue))); if (NILP (KVAR (current_kboard, kbd_queue))) current_kboard->kbd_queue_has_data = 0; input_pending = readable_events (0); @@ -2813,7 +2865,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, abort (); } if (!CONSP (last)) - KSET (kb, kbd_queue, Fcons (c, Qnil)); + kset_kbd_queue (kb, Fcons (c, Qnil)); else XSETCDR (last, Fcons (c, Qnil)); kb->kbd_queue_has_data = 1; @@ -3071,7 +3123,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, cancel_echoing (); ok_to_echo_at_next_pause = saved_ok_to_echo; - KSET (current_kboard, echo_string, saved_echo_string); + kset_echo_string (current_kboard, saved_echo_string); current_kboard->echo_after_prompt = saved_echo_after_prompt; if (saved_immediate_echo) echo_now (); @@ -3542,9 +3594,9 @@ kbd_buffer_store_event_hold (register struct input_event *event, if (single_kboard && kb != current_kboard) { - KSET (kb, kbd_queue, - Fcons (make_lispy_switch_frame (event->frame_or_window), - Fcons (make_number (c), Qnil))); + kset_kbd_queue + (kb, Fcons (make_lispy_switch_frame (event->frame_or_window), + Fcons (make_number (c), Qnil))); kb->kbd_queue_has_data = 1; for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) { @@ -5416,7 +5468,7 @@ make_lispy_event (struct input_event *event) /* We need to use an alist rather than a vector as the cache since we can't make a vector long enough. */ if (NILP (KVAR (current_kboard, system_key_syms))) - KSET (current_kboard, system_key_syms, Fcons (Qnil, Qnil)); + kset_system_key_syms (current_kboard, Fcons (Qnil, Qnil)); return modify_event_symbol (event->code, event->modifiers, Qfunction_key, @@ -8739,11 +8791,11 @@ read_char_minibuf_menu_prompt (int commandflag, is not used on replay. */ orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); - KSET (current_kboard, defining_kbd_macro, Qnil); + kset_defining_kbd_macro (current_kboard, Qnil); do obj = read_char (commandflag, 0, 0, Qt, 0, NULL); while (BUFFERP (obj)); - KSET (current_kboard, defining_kbd_macro, orig_defn_macro); + kset_defining_kbd_macro (current_kboard, orig_defn_macro); if (!INTEGERP (obj)) return obj; @@ -9099,7 +9151,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, /* Install the string STR as the beginning of the string of echoing, so that it serves as a prompt for the next character. */ - KSET (current_kboard, echo_string, prompt); + kset_echo_string (current_kboard, prompt); current_kboard->echo_after_prompt = SCHARS (prompt); echo_now (); } @@ -9345,15 +9397,17 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, if (!NILP (delayed_switch_frame)) { - KSET (interrupted_kboard, kbd_queue, - Fcons (delayed_switch_frame, - KVAR (interrupted_kboard, kbd_queue))); + kset_kbd_queue + (interrupted_kboard, + Fcons (delayed_switch_frame, + KVAR (interrupted_kboard, kbd_queue))); delayed_switch_frame = Qnil; } while (t > 0) - KSET (interrupted_kboard, kbd_queue, - Fcons (keybuf[--t], KVAR (interrupted_kboard, kbd_queue))); + kset_kbd_queue + (interrupted_kboard, + Fcons (keybuf[--t], KVAR (interrupted_kboard, kbd_queue))); /* If the side queue is non-empty, ensure it begins with a switch-frame, so we'll replay it in the right context. */ @@ -9365,9 +9419,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, { Lisp_Object frame; XSETFRAME (frame, interrupted_frame); - KSET (interrupted_kboard, kbd_queue, - Fcons (make_lispy_switch_frame (frame), - KVAR (interrupted_kboard, kbd_queue))); + kset_kbd_queue + (interrupted_kboard, + Fcons (make_lispy_switch_frame (frame), + KVAR (interrupted_kboard, kbd_queue))); } mock_input = 0; orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); @@ -10261,7 +10316,7 @@ a special event, so ignore the prefix argument and don't clear it. */) { prefixarg = KVAR (current_kboard, Vprefix_arg); Vcurrent_prefix_arg = prefixarg; - KSET (current_kboard, Vprefix_arg, Qnil); + kset_prefix_arg (current_kboard, Qnil); } else prefixarg = Qnil; @@ -11200,11 +11255,8 @@ The `posn-' functions access elements of such lists. */) if (WINDOWP (frame_or_window)) { - struct window *w; - - CHECK_LIVE_WINDOW (frame_or_window); + struct window *w = decode_valid_window (frame_or_window); - w = XWINDOW (frame_or_window); XSETINT (x, (XINT (x) + WINDOW_LEFT_EDGE_X (w) + (NILP (whole) @@ -11259,30 +11311,30 @@ The `posn-' functions access elements of such lists. */) void init_kboard (KBOARD *kb) { - KSET (kb, Voverriding_terminal_local_map, Qnil); - KSET (kb, Vlast_command, Qnil); - KSET (kb, Vreal_last_command, Qnil); - KSET (kb, Vkeyboard_translate_table, Qnil); - KSET (kb, Vlast_repeatable_command, Qnil); - KSET (kb, Vprefix_arg, Qnil); - KSET (kb, Vlast_prefix_arg, Qnil); - KSET (kb, kbd_queue, Qnil); + kset_overriding_terminal_local_map (kb, Qnil); + kset_last_command (kb, Qnil); + kset_real_last_command (kb, Qnil); + kset_keyboard_translate_table (kb, Qnil); + kset_last_repeatable_command (kb, Qnil); + kset_prefix_arg (kb, Qnil); + kset_last_prefix_arg (kb, Qnil); + kset_kbd_queue (kb, Qnil); kb->kbd_queue_has_data = 0; kb->immediate_echo = 0; - KSET (kb, echo_string, Qnil); + kset_echo_string (kb, Qnil); kb->echo_after_prompt = -1; kb->kbd_macro_buffer = 0; kb->kbd_macro_bufsize = 0; - KSET (kb, defining_kbd_macro, Qnil); - KSET (kb, Vlast_kbd_macro, Qnil); + kset_defining_kbd_macro (kb, Qnil); + kset_last_kbd_macro (kb, Qnil); kb->reference_count = 0; - KSET (kb, Vsystem_key_alist, Qnil); - KSET (kb, system_key_syms, Qnil); - KSET (kb, Vwindow_system, Qt); /* Unset. */ - KSET (kb, Vinput_decode_map, Fmake_sparse_keymap (Qnil)); - KSET (kb, Vlocal_function_key_map, Fmake_sparse_keymap (Qnil)); + kset_system_key_alist (kb, Qnil); + kset_system_key_syms (kb, Qnil); + kset_window_system (kb, Qt); /* Unset. */ + kset_input_decode_map (kb, Fmake_sparse_keymap (Qnil)); + kset_local_function_key_map (kb, Fmake_sparse_keymap (Qnil)); Fset_keymap_parent (KVAR (kb, Vlocal_function_key_map), Vfunction_key_map); - KSET (kb, Vdefault_minibuffer_frame, Qnil); + kset_default_minibuffer_frame (kb, Qnil); } /* @@ -11358,7 +11410,7 @@ init_keyboard (void) init_kboard (current_kboard); /* A value of nil for Vwindow_system normally means a tty, but we also use it for the initial terminal since there is no window system there. */ - KSET (current_kboard, Vwindow_system, Qnil); + kset_window_system (current_kboard, Qnil); if (!noninteractive) { diff --git a/src/keyboard.h b/src/keyboard.h index f83643d6f6e..91484b3649b 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -19,10 +19,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "systime.h" /* for EMACS_TIME, Time */ #include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ +INLINE_HEADER_BEGIN +#ifndef KEYBOARD_INLINE +# define KEYBOARD_INLINE INLINE +#endif + /* Most code should use this macro to access Lisp fields in struct kboard. */ #define KVAR(kboard, field) ((kboard)->INTERNAL_FIELD (field)) -#define KSET(kboard, field, value) ((kboard)->INTERNAL_FIELD (field) = (value)) /* Each KBOARD represents one logical input stream from which Emacs gets input. If we are using ordinary terminals, it has one KBOARD @@ -173,6 +177,47 @@ struct kboard char echo_after_prompt; }; +KEYBOARD_INLINE void +kset_default_minibuffer_frame (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vdefault_minibuffer_frame) = val; +} +KEYBOARD_INLINE void +kset_defining_kbd_macro (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (defining_kbd_macro) = val; +} +KEYBOARD_INLINE void +kset_input_decode_map (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vinput_decode_map) = val; +} +KEYBOARD_INLINE void +kset_last_command (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vlast_command) = val; +} +KEYBOARD_INLINE void +kset_last_kbd_macro (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vlast_kbd_macro) = val; +} +KEYBOARD_INLINE void +kset_prefix_arg (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vprefix_arg) = val; +} +KEYBOARD_INLINE void +kset_system_key_alist (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vsystem_key_alist) = val; +} +KEYBOARD_INLINE void +kset_window_system (struct kboard *kb, Lisp_Object val) +{ + kb->INTERNAL_FIELD (Vwindow_system) = val; +} + /* Temporarily used before a frame has been opened. */ extern KBOARD *initial_kboard; @@ -510,3 +555,5 @@ extern void mark_kboards (void); #ifdef WINDOWSNT extern const char *const lispy_function_keys[]; #endif + +INLINE_HEADER_END diff --git a/src/keymap.c b/src/keymap.c index c550b37c1d6..21f7dcb5d37 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1854,7 +1854,7 @@ If KEYMAP is nil, that means no local keymap. */) if (!NILP (keymap)) keymap = get_keymap (keymap, 1, 1); - BSET (current_buffer, keymap, keymap); + bset_keymap (current_buffer, keymap); return Qnil; } diff --git a/src/lisp.h b/src/lisp.h index 2a75dfcbc7d..5c7e8dc2f82 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -934,7 +934,7 @@ enum 8-bit European characters. Do not check validity of CT. */ #define CHAR_TABLE_SET(CT, IDX, VAL) \ (ASCII_CHAR_P (IDX) && SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \ - ? XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX] = VAL \ + ? set_sub_char_table_contents (XCHAR_TABLE (CT)->ascii, IDX, VAL) \ : char_table_set (CT, IDX, VAL)) enum CHARTAB_SIZE_BITS @@ -947,8 +947,6 @@ enum CHARTAB_SIZE_BITS extern const int chartab_size[4]; -struct Lisp_Sub_Char_Table; - struct Lisp_Char_Table { /* HEADER.SIZE is the vector's size field, which also holds the @@ -997,6 +995,7 @@ struct Lisp_Sub_Char_Table /* Minimum character covered by the sub char-table. */ Lisp_Object min_char; + /* Use set_sub_char_table_contents to set this. */ Lisp_Object contents[1]; }; @@ -1478,14 +1477,6 @@ struct Lisp_Buffer_Local_Value Lisp_Object valcell; }; -#define BLV_FOUND(blv) \ - (eassert ((blv)->found == !EQ ((blv)->defcell, (blv)->valcell)), (blv)->found) -#define SET_BLV_FOUND(blv, v) \ - (eassert ((v) == !EQ ((blv)->defcell, (blv)->valcell)), (blv)->found = (v)) - -#define BLV_VALUE(blv) (XCDR ((blv)->valcell)) -#define SET_BLV_VALUE(blv, v) (XSETCDR ((blv)->valcell, v)) - /* Like Lisp_Objfwd except that value lives in a slot in the current kboard. */ struct Lisp_Kboard_Objfwd @@ -1767,15 +1758,18 @@ typedef struct { #define CHECK_WINDOW_CONFIGURATION(x) \ CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x) -/* This macro rejects windows on the interior of the window tree as - "dead", which is what we want; this is an argument-checking macro, and - the user should never get access to interior windows. - - A window of any sort, leaf or interior, is dead if the buffer, - vchild, and hchild members are all nil. */ - -#define CHECK_LIVE_WINDOW(x) \ - CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), \ +/* A window of any sort, leaf or interior, is "valid" if one of its + buffer, vchild, or hchild members is non-nil. */ +#define CHECK_VALID_WINDOW(x) \ + CHECK_TYPE (WINDOWP (x) \ + && (!NILP (XWINDOW (x)->buffer) \ + || !NILP (XWINDOW (x)->vchild) \ + || !NILP (XWINDOW (x)->hchild)), \ + Qwindow_valid_p, x) + +/* A window is "live" if and only if it shows a buffer. */ +#define CHECK_LIVE_WINDOW(x) \ + CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), \ Qwindow_live_p, x) #define CHECK_PROCESS(x) \ @@ -2364,31 +2358,55 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) } LISP_INLINE void -set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) +set_hash_key_and_value (struct Lisp_Hash_Table *h, Lisp_Object key_and_value) +{ + h->key_and_value = key_and_value; +} + +LISP_INLINE void +set_hash_key_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) { gc_aset (h->key_and_value, 2 * idx, val); } LISP_INLINE void -set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) +set_hash_value_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) { gc_aset (h->key_and_value, 2 * idx + 1, val); } LISP_INLINE void -set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) +set_hash_next (struct Lisp_Hash_Table *h, Lisp_Object next) +{ + h->next = next; +} + +LISP_INLINE void +set_hash_next_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) { gc_aset (h->next, idx, val); } LISP_INLINE void -set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) +set_hash_hash (struct Lisp_Hash_Table *h, Lisp_Object hash) +{ + h->hash = hash; +} + +LISP_INLINE void +set_hash_hash_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) { gc_aset (h->hash, idx, val); } LISP_INLINE void -set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) +set_hash_index (struct Lisp_Hash_Table *h, Lisp_Object index) +{ + h->index = index; +} + +LISP_INLINE void +set_hash_index_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) { gc_aset (h->index, idx, val); } @@ -2420,6 +2438,52 @@ set_symbol_next (Lisp_Object sym, struct Lisp_Symbol *next) XSYMBOL (sym)->next = next; } +/* Buffer-local (also frame-local) variable access functions. */ + +LISP_INLINE int +blv_found (struct Lisp_Buffer_Local_Value *blv) +{ + eassert (blv->found == !EQ (blv->defcell, blv->valcell)); + return blv->found; +} + +LISP_INLINE void +set_blv_found (struct Lisp_Buffer_Local_Value *blv, int found) +{ + eassert (found == !EQ (blv->defcell, blv->valcell)); + blv->found = found; +} + +LISP_INLINE Lisp_Object +blv_value (struct Lisp_Buffer_Local_Value *blv) +{ + return XCDR (blv->valcell); +} + +LISP_INLINE void +set_blv_value (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val) +{ + XSETCDR (blv->valcell, val); +} + +LISP_INLINE void +set_blv_where (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val) +{ + blv->where = val; +} + +LISP_INLINE void +set_blv_defcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val) +{ + blv->defcell = val; +} + +LISP_INLINE void +set_blv_valcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val) +{ + blv->valcell = val; +} + /* Set overlay's property list. */ LISP_INLINE void @@ -2431,7 +2495,7 @@ set_overlay_plist (Lisp_Object overlay, Lisp_Object plist) /* Get text properties of S. */ LISP_INLINE INTERVAL -string_get_intervals (Lisp_Object s) +string_intervals (Lisp_Object s) { return XSTRING (s)->intervals; } @@ -2439,11 +2503,57 @@ string_get_intervals (Lisp_Object s) /* Set text properties of S to I. */ LISP_INLINE void -string_set_intervals (Lisp_Object s, INTERVAL i) +set_string_intervals (Lisp_Object s, INTERVAL i) { XSTRING (s)->intervals = i; } +/* Set a Lisp slot in TABLE to VAL. Most code should use this instead + of setting slots directly. */ + +LISP_INLINE void +set_char_table_ascii (Lisp_Object table, Lisp_Object val) +{ + XCHAR_TABLE (table)->ascii = val; +} +LISP_INLINE void +set_char_table_defalt (Lisp_Object table, Lisp_Object val) +{ + XCHAR_TABLE (table)->defalt = val; +} +LISP_INLINE void +set_char_table_parent (Lisp_Object table, Lisp_Object val) +{ + XCHAR_TABLE (table)->parent = val; +} +LISP_INLINE void +set_char_table_purpose (Lisp_Object table, Lisp_Object val) +{ + XCHAR_TABLE (table)->purpose = val; +} + +/* Set different slots in (sub)character tables. */ + +LISP_INLINE void +set_char_table_extras (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) +{ + eassert (0 <= idx && idx < CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (table))); + XCHAR_TABLE (table)->extras[idx] = val; +} + +LISP_INLINE void +set_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) +{ + eassert (0 <= idx && idx < (1 << CHARTAB_SIZE_BITS_0)); + XCHAR_TABLE (table)->contents[idx] = val; +} + +LISP_INLINE void +set_sub_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val) +{ + XSUB_CHAR_TABLE (table)->contents[idx] = val; +} + /* Defined in data.c. */ extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; @@ -2666,7 +2776,6 @@ _Noreturn void __executable_start (void); #endif extern Lisp_Object selected_frame; extern Lisp_Object Vwindow_system; -void duration_to_sec_usec (double, int *, int *); extern Lisp_Object sit_for (Lisp_Object, int, int); extern void init_display (void); extern void syms_of_display (void); @@ -2847,9 +2956,8 @@ extern Lisp_Object copy_char_table (Lisp_Object); extern Lisp_Object char_table_ref (Lisp_Object, int); extern Lisp_Object char_table_ref_and_range (Lisp_Object, int, int *, int *); -extern Lisp_Object char_table_set (Lisp_Object, int, Lisp_Object); -extern Lisp_Object char_table_set_range (Lisp_Object, int, int, - Lisp_Object); +extern void char_table_set (Lisp_Object, int, Lisp_Object); +extern void char_table_set_range (Lisp_Object, int, int, Lisp_Object); extern int char_table_translate (Lisp_Object, int); extern void map_char_table (void (*) (Lisp_Object, Lisp_Object, Lisp_Object), diff --git a/src/lread.c b/src/lread.c index 72991e92bae..e2ad03b349f 100644 --- a/src/lread.c +++ b/src/lread.c @@ -80,7 +80,7 @@ static Lisp_Object Qascii_character, Qload, Qload_file_name; Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; static Lisp_Object Qinhibit_file_name_operation; static Lisp_Object Qeval_buffer_list; -static Lisp_Object Qlexical_binding; +Lisp_Object Qlexical_binding; static Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */ /* Used instead of Qget_file_char while loading *.elc files compiled @@ -3189,8 +3189,8 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj /* Check for text properties in each interval. substitute_in_interval contains part of the logic. */ - INTERVAL root_interval = string_get_intervals (subtree); - Lisp_Object arg = Fcons (object, placeholder); + INTERVAL root_interval = string_intervals (subtree); + Lisp_Object arg = Fcons (object, placeholder); traverse_intervals_noorder (root_interval, &substitute_in_interval, arg); @@ -3211,7 +3211,7 @@ substitute_in_interval (INTERVAL interval, Lisp_Object arg) Lisp_Object object = Fcar (arg); Lisp_Object placeholder = Fcdr (arg); - SUBSTITUTE (interval->plist, interval_set_plist (interval, true_value)); + SUBSTITUTE (interval->plist, set_interval_plist (interval, true_value)); } diff --git a/src/macros.c b/src/macros.c index d74d12e6158..e81068181b9 100644 --- a/src/macros.c +++ b/src/macros.c @@ -127,7 +127,7 @@ macro before appending to it. */) message ("Appending to kbd macro..."); } - KSET (current_kboard, defining_kbd_macro, Qt); + kset_defining_kbd_macro (current_kboard, Qt); return Qnil; } @@ -137,12 +137,13 @@ macro before appending to it. */) void end_kbd_macro (void) { - KSET (current_kboard, defining_kbd_macro, Qnil); + kset_defining_kbd_macro (current_kboard, Qnil); update_mode_lines++; - KSET (current_kboard, Vlast_kbd_macro, - make_event_array ((current_kboard->kbd_macro_end - - current_kboard->kbd_macro_buffer), - current_kboard->kbd_macro_buffer)); + kset_last_kbd_macro + (current_kboard, + make_event_array ((current_kboard->kbd_macro_end + - current_kboard->kbd_macro_buffer), + current_kboard->kbd_macro_buffer)); } DEFUN ("end-kbd-macro", Fend_kbd_macro, Send_kbd_macro, 0, 2, "p", @@ -330,7 +331,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) executing_kbd_macro = final; executing_kbd_macro_index = 0; - KSET (current_kboard, Vprefix_arg, Qnil); + kset_prefix_arg (current_kboard, Qnil); if (!NILP (loopfunc)) { diff --git a/src/makefile.w32-in b/src/makefile.w32-in index 31dc94f7964..bdb292099bc 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in @@ -395,6 +395,8 @@ BLOCKINPUT_H = $(SRC)/blockinput.h \ $(ATIMER_H) BUFFER_H = $(SRC)/buffer.h \ $(SYSTIME_H) +C_CTYPE_H = $(GNU_LIB)/c-ctype.h \ + $(NT_INC)/stdbool.h CAREADLINKAT_H = $(GNU_LIB)/careadlinkat.h \ $(NT_INC)/unistd.h CHARACTER_H = $(SRC)/character.h \ @@ -441,7 +443,8 @@ LISP_H = $(SRC)/lisp.h \ $(SRC)/globals.h \ $(GNU_LIB)/intprops.h \ $(INTTYPES_H) \ - $(NT_INC)/stdalign.h + $(NT_INC)/stdalign.h \ + $(NT_INC)/stdbool.h MD5_H = $(GNU_LIB)/md5.h \ $(NT_INC)/stdint.h MENU_H = $(SRC)/menu.h \ @@ -626,6 +629,7 @@ $(BLD)/charset.$(O) : \ $(CHARSET_H) \ $(CODING_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(LISP_H) $(BLD)/chartab.$(O) : \ @@ -747,6 +751,7 @@ $(BLD)/doc.$(O) : \ $(BUFFER_H) \ $(CHARACTER_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(KEYBOARD_H) \ $(LISP_H) @@ -820,6 +825,7 @@ $(BLD)/fileio.$(O) : \ $(CHARACTER_H) \ $(CODING_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(DISPEXTERN_H) \ $(FRAME_H) \ $(INTERVALS_H) \ @@ -881,6 +887,7 @@ $(BLD)/font.$(O) : \ $(CHARACTER_H) \ $(CHARSET_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(DISPEXTERN_H) \ $(FONT_H) \ $(FRAME_H) \ @@ -916,6 +923,7 @@ $(BLD)/frame.$(O) : \ $(BUFFER_H) \ $(CHARACTER_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(DISPEXTERN_H) \ $(FONT_H) \ $(FRAME_H) \ @@ -967,6 +975,7 @@ $(BLD)/image.$(O) : \ $(CHARACTER_H) \ $(CODING_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(DISPEXTERN_H) \ $(FONT_H) \ $(FRAME_H) \ @@ -1354,6 +1363,7 @@ $(BLD)/sysdep.$(O) : \ $(BLOCKINPUT_H) \ $(CAREADLINKAT_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(DISPEXTERN_H) \ $(FRAME_H) \ $(GRP_H) \ @@ -1438,6 +1448,7 @@ $(BLD)/unexw32.$(O) : \ $(BLD)/vm-limit.$(O) : \ $(SRC)/vm-limit.c \ $(SRC)/mem-limits.h \ + $(NT_INC)/unistd.h \ $(CONFIG_H) \ $(LISP_H) @@ -1499,6 +1510,7 @@ $(BLD)/xfaces.$(O) : \ $(CHARACTER_H) \ $(CHARSET_H) \ $(CONFIG_H) \ + $(C_CTYPE_H) \ $(DISPEXTERN_H) \ $(FONT_H) \ $(FRAME_H) \ diff --git a/src/minibuf.c b/src/minibuf.c index 06ea415db62..2154d1654df 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -565,11 +565,11 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, /* Defeat (setq-default truncate-lines t), since truncated lines do not work correctly in minibuffers. (Bug#5715, etc) */ - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ if (inherit_input_method) - BSET (current_buffer, enable_multibyte_characters, enable_multibyte); + bset_enable_multibyte_characters (current_buffer, enable_multibyte); /* The current buffer's default directory is usually the right thing for our minibuffer here. However, if you're typing a command at @@ -580,7 +580,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, you think of something better to do? Find another buffer with a better directory, and use that one instead. */ if (STRINGP (ambient_dir)) - BSET (current_buffer, directory, ambient_dir); + bset_directory (current_buffer, ambient_dir); else { Lisp_Object buf_list; @@ -594,8 +594,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, other_buf = XCDR (XCAR (buf_list)); if (STRINGP (BVAR (XBUFFER (other_buf), directory))) { - BSET (current_buffer, directory, - BVAR (XBUFFER (other_buf), directory)); + bset_directory (current_buffer, + BVAR (XBUFFER (other_buf), directory)); break; } } @@ -672,7 +672,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, } clear_message (1, 1); - BSET (current_buffer, keymap, map); + bset_keymap (current_buffer, map); /* Turn on an input method stored in INPUT_METHOD if any. */ if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method))) @@ -681,7 +681,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Frun_hooks (1, &Qminibuffer_setup_hook); /* Don't allow the user to undo past this point. */ - BSET (current_buffer, undo_list, Qnil); + bset_undo_list (current_buffer, Qnil); recursive_edit_1 (); diff --git a/src/msdos.c b/src/msdos.c index bcb7fbe75e0..30435820d9e 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -520,8 +520,8 @@ dos_set_window_size (int *rows, int *cols) /* If the user specified a special video mode for these dimensions, use that mode. */ - video_mode - = Fsymbol_value (Fintern_soft (make_formatted_string + video_mode + = Fsymbol_value (Fintern_soft (make_formatted_string (video_name, "screen-dimensions-%dx%d", *rows, *cols), Qnil)); @@ -1801,7 +1801,7 @@ internal_terminal_init (void) } tty = FRAME_TTY (sf); - KSET (current_kboard, Vwindow_system, Qpc); + kset_window_system (current_kboard, Qpc); sf->output_method = output_msdos_raw; if (init_needed) { diff --git a/src/nsfns.m b/src/nsfns.m index 1b39f0257a5..e8b5d22077a 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -447,7 +447,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil)) return; - FSET (f, icon_name, arg); + fset_icon_name (f, arg); if (NILP (arg)) { @@ -539,7 +539,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) if (! NILP (Fstring_equal (name, f->name))) return; - FSET (f, name, name); + fset_name (f, name); /* title overrides explicit name */ if (! NILP (f->title)) @@ -590,7 +590,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) update_mode_lines = 1; - FSET (f, title, name); + fset_title (f, name); if (NILP (name)) name = f->name; @@ -676,7 +676,7 @@ ns_set_name_as_filename (struct frame *f) [[view window] setRepresentedFilename: fstr]; [[view window] setTitle: str]; - FSET (f, name, name); + fset_name (f, name); } [pool release]; @@ -1204,11 +1204,11 @@ This function is an internal primitive--use `make-frame' instead. */) FRAME_FONTSET (f) = -1; - FSET (f, icon_name, x_get_arg (dpyinfo, parms, Qicon_name, - "iconName", "Title", - RES_TYPE_STRING)); + fset_icon_name (f, x_get_arg (dpyinfo, parms, Qicon_name, + "iconName", "Title", + RES_TYPE_STRING)); if (! STRINGP (f->icon_name)) - FSET (f, icon_name, Qnil); + fset_icon_name (f, Qnil); FRAME_NS_DISPLAY_INFO (f) = dpyinfo; @@ -1231,12 +1231,12 @@ This function is an internal primitive--use `make-frame' instead. */) be set. */ if (EQ (name, Qunbound) || NILP (name) || ! STRINGP (name)) { - FSET (f, name, build_string ([ns_app_name UTF8String])); + fset_name (f, build_string ([ns_app_name UTF8String])); f->explicit_name = 0; } else { - FSET (f, name, name); + fset_name (f, name); f->explicit_name = 1; specbind (Qx_resource_name, name); } @@ -1391,13 +1391,13 @@ This function is an internal primitive--use `make-frame' instead. */) if (FRAME_HAS_MINIBUF_P (f) && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame)) || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame))))) - KSET (kb, Vdefault_minibuffer_frame, frame); + kset_default_minibuffer_frame (kb, frame); /* All remaining specified parameters, which have not been "used" by x_get_arg and friends, now go in the misc. alist of the frame. */ for (tem = parms; CONSP (tem); tem = XCDR (tem)) if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) - FSET (f, param_alist, Fcons (XCAR (tem), f->param_alist)); + fset_param_alist (f, Fcons (XCAR (tem), f->param_alist)); UNGCPRO; diff --git a/src/nsfont.m b/src/nsfont.m index 6f9294e082a..412a6777c64 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -236,27 +236,63 @@ ns_fallback_entity (void) } -/* Utility: get width of a char c in screen font sfont */ +/* Utility: get width of a char c in screen font SFONT */ static float ns_char_width (NSFont *sfont, int c) { - float w; - NSString *cstr = [NSString stringWithFormat: @"%c", c]; + float w = -1.0; + NSString *cstr = [NSString stringWithFormat: @"%c", c]; + #ifdef NS_IMPL_COCOA - NSGlyph glyph = [sfont glyphWithName: cstr]; - if (glyph) - { - float w = [sfont advancementForGlyph: glyph].width; - if (w >= 1.5) - return w; - } + NSGlyph glyph = [sfont glyphWithName: cstr]; + if (glyph) + w = [sfont advancementForGlyph: glyph].width; #endif + + if (w < 0.0) { NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName]; w = [cstr sizeWithAttributes: attrsDictionary].width; } - return max (w, 2.0); + + return max (w, 1.0); +} + +/* Return average width over ASCII printable characters for SFONT. */ + +static NSString *ascii_printable; + +static int +ns_ascii_average_width (NSFont *sfont) +{ + float w = -1.0; + + if (!ascii_printable) + { + char chars[96]; + int ch; + for (ch = 0; ch < 95; ch++) + chars[ch] = ' ' + ch; + chars[95] = '\0'; + + ascii_printable = [[NSString alloc] initWithFormat: @"%s", chars]; + } + +#ifdef NS_IMPL_COCOA + NSGlyph glyph = [sfont glyphWithName: ascii_printable]; + if (glyph) + w = [sfont advancementForGlyph: glyph].width; +#endif + + if (w < 0.0) + { + NSDictionary *attrsDictionary = + [NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName]; + w = [ascii_printable sizeWithAttributes: attrsDictionary].width; + } + + return lrint (w / 95.0); } @@ -885,10 +921,11 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) /* set up metrics portion of font struct */ font->ascent = lrint([sfont ascender]); font->descent = -lrint(floor(adjusted_descender)); - font->min_width = ns_char_width(sfont, '|'); font->space_width = lrint (ns_char_width (sfont, ' ')); - font->average_width = lrint (font_info->width); font->max_width = lrint (font_info->max_bounds.width); + font->min_width = font->space_width; /* Approximate. */ + font->average_width = ns_ascii_average_width (sfont); + font->height = lrint (font_info->height); font->underline_position = lrint (font_info->underpos); font->underline_thickness = lrint (font_info->underwidth); @@ -1492,4 +1529,6 @@ syms_of_nsfont (void) DEFSYM (Qmedium, "medium"); DEFVAR_LISP ("ns-reg-to-script", Vns_reg_to_script, doc: /* Internal use: maps font registry to Unicode script. */); + + ascii_printable = NULL; } diff --git a/src/nsimage.m b/src/nsimage.m index 1479294948b..8a8a3ddaae4 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -302,7 +302,7 @@ static EmacsImage *ImageList = nil; [bmRep release]; return nil; } -#define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) +#define hexchar(x) ('0' <= (x) && (x) <= '9' ? (x) - '0' : (x) - 'a' + 10) s1 = *s++; s2 = *s++; c = hexchar (s1) * 0x10 + hexchar (s2); @@ -501,4 +501,3 @@ static EmacsImage *ImageList = nil; } @end - diff --git a/src/nsmenu.m b/src/nsmenu.m index 210f4530d7a..e8a0b43a01b 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -73,7 +73,6 @@ EmacsMenu *mainMenu, *svcsMenu, *dockMenu; /* Nonzero means a menu is currently active. */ static int popup_activated_flag; -static NSModalSession popupSession; /* Nonzero means we are tracking and updating menus. */ static int trackingMenu; @@ -215,7 +214,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) if (! NILP (Vlucid_menu_bar_dirty_flag)) call0 (Qrecompute_lucid_menubar); safe_run_hooks (Qmenu_bar_update_hook); - FSET (f, menu_bar_items, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); + fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); /* Now ready to go */ items = FRAME_MENU_BAR_ITEMS (f); @@ -341,7 +340,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) } /* The menu items are different, so store them in the frame */ /* FIXME: this is not correct for single-submenu case */ - FSET (f, menu_bar_vector, menu_items); + fset_menu_bar_vector (f, menu_items); f->menu_bar_items_used = menu_items_used; /* Calls restore_menu_items, etc., as they were outside */ @@ -1365,8 +1364,6 @@ pop_down_menu (Lisp_Object arg) { EmacsDialogPanel *panel = unwind_data->dialog; popup_activated_flag = 0; - [NSApp endModalSession: popupSession]; - [panel close]; [unwind_data->pool release]; [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; @@ -1756,20 +1753,40 @@ void process_dialog (id window, Lisp_Object list) } + +- (void)timeout_handler: (NSTimer *)timedEntry +{ + timer_fired = 1; + [NSApp abortModal]; +} + - (Lisp_Object)runDialogAt: (NSPoint)p { - NSInteger ret; + NSInteger ret = 0; - /* initiate a session that will be ended by pop_down_menu */ - popupSession = [NSApp beginModalSessionForWindow: self]; - while (popup_activated_flag - && (ret = [NSApp runModalSession: popupSession]) - == NSRunContinuesResponse) + while (popup_activated_flag) { - /* Run this for timers.el, indep of atimers; might not return. - TODO: use return value to avoid calling every iteration. */ - timer_check (); - [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; + NSTimer *tmo = nil; + EMACS_TIME next_time = timer_check (); + + if (EMACS_TIME_VALID_P (next_time)) + { + double time = EMACS_TIME_TO_DOUBLE (next_time); + tmo = [NSTimer timerWithTimeInterval: time + target: self + selector: @selector (timeout_handler:) + userInfo: 0 + repeats: NO]; + [[NSRunLoop currentRunLoop] addTimer: tmo + forMode: NSModalPanelRunLoopMode]; + } + timer_fired = 0; + ret = [NSApp runModalForWindow: self]; + if (! timer_fired) + { + if (tmo != nil) [tmo invalidate]; /* Cancels timer */ + break; + } } { /* FIXME: BIG UGLY HACK!!! */ diff --git a/src/nsterm.h b/src/nsterm.h index de41929e3fd..54f4a4ec89e 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -56,7 +56,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - (void)sendEvent: (NSEvent *)theEvent; - (void)showPreferencesWindow: (id)sender; - (BOOL) openFile: (NSString *)fileName; -- (void)fd_handler: (NSTimer *) fdEntry; +- (void)fd_handler: (id)unused; - (void)timeout_handler: (NSTimer *)timedEntry; - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg; @end @@ -195,12 +195,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ NSTextField *title; NSMatrix *matrix; int rows, cols; + int timer_fired; } - initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ; - addButton: (char *)str value: (Lisp_Object)val row: (int)row; - addString: (char *)str row: (int)row; - addSplit; - (Lisp_Object)runDialogAt: (NSPoint)p; +- (void)timeout_handler: (NSTimer *)timedEntry; @end #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 @@ -448,7 +450,10 @@ struct nsfont_info struct font font; char *name; /* PostScript name, uniquely identifies on NS systems */ - float width; /* this and following metrics stored as float rather than int */ + + /* The following metrics are stored as float rather than int. */ + + float width; /* Maximum advance for the font. */ float height; float underpos; float underwidth; diff --git a/src/nsterm.m b/src/nsterm.m index 5e3c3ac777f..3ab9358467a 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -36,9 +36,15 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) #include <signal.h> #include <unistd.h> #include <setjmp.h> + +#include <c-ctype.h> #include <c-strcase.h> #include <ftoastr.h> +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + #include "lisp.h" #include "blockinput.h" #include "sysselect.h" @@ -184,17 +190,20 @@ static BOOL ns_menu_bar_is_hidden = NO; static BOOL send_appdefined = YES; static NSEvent *last_appdefined_event = 0; static NSTimer *timed_entry = 0; -static NSTimer *fd_entry = nil; static NSTimer *scroll_repeat_entry = nil; -static fd_set select_readfds, t_readfds; -static int select_nfds; +static fd_set select_readfds, select_writefds; +enum { SELECT_HAVE_READ = 1, SELECT_HAVE_WRITE = 2, SELECT_HAVE_TMO = 4 }; +static int select_nfds = 0, select_valid = 0; +static EMACS_TIME select_timeout = { 0, 0 }; +static int selfds[2] = { -1, -1 }; +static pthread_mutex_t select_mutex; +static int apploopnr = 0; static NSAutoreleasePool *outerpool; static struct input_event *emacs_event = NULL; static struct input_event *q_event_ptr = NULL; static int n_emacs_events_pending = 0; static NSMutableArray *ns_pending_files, *ns_pending_service_names, *ns_pending_service_args; -static BOOL inNsSelect = 0; static BOOL ns_do_open_file = NO; /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ @@ -252,15 +261,20 @@ static BOOL ns_do_open_file = NO; /* This is a piece of code which is common to all the event handling methods. Maybe it should even be a function. */ -#define EV_TRAILER(e) \ - { \ - XSETFRAME (emacs_event->frame_or_window, emacsframe); \ - if (e) emacs_event->timestamp = EV_TIMESTAMP (e); \ - n_emacs_events_pending++; \ - kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \ - EVENT_INIT (*emacs_event); \ - ns_send_appdefined (-1); \ - } +#define EV_TRAILER(e) \ + { \ + XSETFRAME (emacs_event->frame_or_window, emacsframe); \ + if (e) emacs_event->timestamp = EV_TIMESTAMP (e); \ + if (q_event_ptr) \ + { \ + n_emacs_events_pending++; \ + kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \ + } \ + else \ + kbd_buffer_store_event (emacs_event); \ + EVENT_INIT (*emacs_event); \ + ns_send_appdefined (-1); \ + } void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object); @@ -1018,7 +1032,7 @@ ns_frame_rehighlight (struct frame *frame) : dpyinfo->x_focus_frame); if (!FRAME_LIVE_P (dpyinfo->x_highlight_frame)) { - FSET (dpyinfo->x_focus_frame, focus_frame, Qnil); + fset_focus_frame (dpyinfo->x_focus_frame, Qnil); dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame; } } @@ -3377,14 +3391,6 @@ ns_send_appdefined (int value) timed_entry = nil; } - /* Ditto for file descriptor poller */ - if (fd_entry) - { - [fd_entry invalidate]; - [fd_entry release]; - fd_entry = nil; - } - nxev = [NSEvent otherEventWithType: NSApplicationDefined location: NSMakePoint (0, 0) modifierFlags: 0 @@ -3402,7 +3408,6 @@ ns_send_appdefined (int value) } } - static int ns_read_socket (struct terminal *terminal, int expected, struct input_event *hold_quit) @@ -3466,24 +3471,14 @@ ns_read_socket (struct terminal *terminal, int expected, /* Run and wait for events. We must always send one NX_APPDEFINED event to ourself, otherwise [NXApp run] will never exit. */ send_appdefined = YES; + ns_send_appdefined (-1); - /* If called via ns_select, this is called once with expected=1, - because we expect either the timeout or file descriptor activity. - In this case the first event through will either be real input or - one of these. read_avail_input() then calls once more with expected=0 - and in that case we need to return quickly if there is nothing. - If we're being called outside of that, it's also OK to return quickly - after one iteration through the event loop, since other terms do - this and emacs expects it. */ - if (!(inNsSelect && expected)) + if (++apploopnr != 1) { - /* Post an application defined event on the event queue. When this is - received the [NXApp run] will return, thus having processed all - events which are currently queued, if any. */ - ns_send_appdefined (-1); + abort (); } - [NSApp run]; + --apploopnr; } nevents = n_emacs_events_pending; @@ -3503,65 +3498,89 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, -------------------------------------------------------------------------- */ { int result; - double time; NSEvent *ev; - struct timespec select_timeout; + int k, nr = 0; + struct input_event event; + char c; /* NSTRACE (ns_select); */ - if (NSApp == nil || inNsSelect == 1 /* || ([NSApp isActive] == NO && - [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil - inMode:NSDefaultRunLoopMode dequeue:NO] == nil) */) + for (k = 0; readfds && k < nfds+1; k++) + if (FD_ISSET(k, readfds)) ++nr; + + if (NSApp == nil + || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0)) return pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask); - /* Save file descriptor set, which gets overwritten in calls to select () - Note, this is called from process.c, and only readfds is ever set */ - if (readfds) + [outerpool release]; + outerpool = [[NSAutoreleasePool alloc] init]; + + + send_appdefined = YES; + if (nr > 0) { - memcpy (&select_readfds, readfds, sizeof (fd_set)); + pthread_mutex_lock (&select_mutex); select_nfds = nfds; + select_valid = 0; + if (readfds) + { + select_readfds = *readfds; + select_valid += SELECT_HAVE_READ; + } + if (writefds) + { + select_writefds = *writefds; + select_valid += SELECT_HAVE_WRITE; + } + + if (timeout) + { + select_timeout = *timeout; + select_valid += SELECT_HAVE_TMO; + } + + pthread_mutex_unlock (&select_mutex); + + /* Inform fd_handler that select should be called */ + c = 'g'; + write (selfds[1], &c, 1); } - else - select_nfds = 0; - - /* Try an initial select for pending data on input files */ - select_timeout.tv_sec = select_timeout.tv_nsec = 0; - result = pselect (nfds, readfds, writefds, exceptfds, - &select_timeout, sigmask); - if (result) - return result; - - /* if (!timeout || timed_entry || fd_entry) - fprintf (stderr, "assertion failed: timeout null or timed_entry/fd_entry non-null in ns_select\n"); */ - - /* set a timeout and run the main AppKit event loop while continuing - to monitor the files */ - time = EMACS_TIME_TO_DOUBLE (*timeout); - timed_entry = [[NSTimer scheduledTimerWithTimeInterval: time - target: NSApp - selector: @selector (timeout_handler:) - userInfo: 0 - repeats: YES] /* for safe removal */ - retain]; - - /* set a periodic task to try the pselect () again */ - fd_entry = [[NSTimer scheduledTimerWithTimeInterval: 0.1 - target: NSApp - selector: @selector (fd_handler:) - userInfo: 0 - repeats: YES] - retain]; - - /* Let Application dispatch events until it receives an event of the type - NX_APPDEFINED, which should only be sent by timeout_handler. - We tell read_avail_input() that input is "expected" because we do expect - either the timeout or fd handler to fire, and if they don't, the original - call from process.c that got us here expects us to wait until some input - comes. */ - inNsSelect = 1; - gobble_input (1); + else if (nr == 0 && timeout) + { + /* No file descriptor, just a timeout, no need to wake fd_handler */ + double time = EMACS_TIME_TO_DOUBLE (*timeout); + timed_entry = [[NSTimer scheduledTimerWithTimeInterval: time + target: NSApp + selector: + @selector (timeout_handler:) + userInfo: 0 + repeats: NO] + retain]; + } + else /* No timeout and no file descriptors, can this happen? */ + { + /* Send appdefined so we exit from the loop */ + ns_send_appdefined (-1); + } + + EVENT_INIT (event); + BLOCK_INPUT; + emacs_event = &event; + if (++apploopnr != 1) + { + abort(); + } + [NSApp run]; + --apploopnr; + emacs_event = NULL; + if (nr > 0 && readfds) + { + c = 's'; + write (selfds[1], &c, 1); + } + UNBLOCK_INPUT; + ev = last_appdefined_event; - inNsSelect = 0; if (ev) { @@ -3575,25 +3594,28 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, if (t == -2) { /* The NX_APPDEFINED event we received was a timeout. */ - return 0; + result = 0; } else if (t == -1) { /* The NX_APPDEFINED event we received was the result of at least one real input event arriving. */ errno = EINTR; - return -1; + result = -1; } else { - /* Received back from pselect () in fd_handler; copy the results */ - if (readfds) - memcpy (readfds, &select_readfds, sizeof (fd_set)); - return t; + /* Received back from select () in fd_handler; copy the results */ + pthread_mutex_lock (&select_mutex); + if (readfds) *readfds = select_readfds; + if (writefds) *writefds = select_writefds; + if (timeout) *timeout = select_timeout; + pthread_mutex_unlock (&select_mutex); + result = t; } } - /* never reached, shut compiler up */ - return 0; + + return result; } @@ -3676,7 +3698,7 @@ ns_set_vertical_scroll_bar (struct window *window, { bar = XNS_SCROLL_BAR (window->vertical_scroll_bar); [bar removeFromSuperview]; - WSET (window, vertical_scroll_bar, Qnil); + wset_vertical_scroll_bar (window, Qnil); } ns_clear_frame_area (f, sb_left, top, width, height); UNBLOCK_INPUT; @@ -3687,7 +3709,7 @@ ns_set_vertical_scroll_bar (struct window *window, { ns_clear_frame_area (f, sb_left, top, width, height); bar = [[EmacsScroller alloc] initFrame: r window: win]; - WSET (window, vertical_scroll_bar, make_save_value (bar, 0)); + wset_vertical_scroll_bar (window, make_save_value (bar, 0)); } else { @@ -4024,6 +4046,21 @@ ns_term_init (Lisp_Object display_name) { baud_rate = 38400; Fset_input_interrupt_mode (Qnil); + + if (selfds[0] == -1) + { + if (pipe (selfds) == -1) + { + fprintf (stderr, "Failed to create pipe: %s\n", + emacs_strerror (errno)); + abort (); + } + + fcntl (selfds[0], F_SETFL, O_NONBLOCK|fcntl (selfds[0], F_GETFL)); + FD_ZERO (&select_readfds); + FD_ZERO (&select_writefds); + pthread_mutex_init (&select_mutex, NULL); + } ns_initialized = 1; } @@ -4039,6 +4076,11 @@ ns_term_init (Lisp_Object display_name) return NULL; [NSApp setDelegate: NSApp]; + /* Start the select thread. */ + [NSThread detachNewThreadSelector:@selector (fd_handler:) + toTarget:NSApp + withObject:nil]; + /* debugging: log all notifications */ /* [[NSNotificationCenter defaultCenter] addObserver: NSApp selector: @selector (logNotification:) @@ -4051,7 +4093,7 @@ ns_term_init (Lisp_Object display_name) terminal->kboard = xmalloc (sizeof *terminal->kboard); init_kboard (terminal->kboard); - KSET (terminal->kboard, Vwindow_system, Qns); + kset_window_system (terminal->kboard, Qns); terminal->kboard->next_kboard = all_kboards; all_kboards = terminal->kboard; /* Don't let the initial kboard remain current longer than necessary. @@ -4547,26 +4589,91 @@ not_in_argv (NSString *arg) ns_send_appdefined (-2); } -- (void)fd_handler: (NSTimer *) fdEntry +- (void)fd_handler:(id)unused /* -------------------------------------------------------------------------- Check data waiting on file descriptors and terminate if so -------------------------------------------------------------------------- */ { int result; - struct timespec select_timeout; - /* NSTRACE (fd_handler); */ + int waiting = 1, nfds; + char c; - if (select_nfds == 0) - return; + SELECT_TYPE readfds, writefds, *wfds; + EMACS_TIME timeout, *tmo; - memcpy (&t_readfds, &select_readfds, sizeof (fd_set)); + /* NSTRACE (fd_handler); */ - select_timeout.tv_sec = select_timeout.tv_nsec = 0; - result = pselect (select_nfds, &t_readfds, NULL, NULL, &select_timeout, NULL); - if (result) + for (;;) { - memcpy (&select_readfds, &t_readfds, sizeof (fd_set)); - ns_send_appdefined (result); + if (waiting) + { + SELECT_TYPE fds; + + FD_SET (selfds[0], &fds); + result = select (selfds[0]+1, &fds, NULL, NULL, NULL); + if (result > 0) + { + read (selfds[0], &c, 1); + if (c == 'g') waiting = 0; + } + } + else + { + pthread_mutex_lock (&select_mutex); + nfds = select_nfds; + + if (select_valid & SELECT_HAVE_READ) + readfds = select_readfds; + else + FD_ZERO (&readfds); + + if (select_valid & SELECT_HAVE_WRITE) + { + writefds = select_writefds; + wfds = &writefds; + } + else + wfds = NULL; + if (select_valid & SELECT_HAVE_TMO) + { + timeout = select_timeout; + tmo = &timeout; + } + else + tmo = NULL; + + pthread_mutex_unlock (&select_mutex); + + FD_SET (selfds[0], &readfds); + if (selfds[0] >= nfds) nfds = selfds[0]+1; + + result = pselect (nfds, &readfds, wfds, NULL, tmo, NULL); + + if (result == 0) + ns_send_appdefined (-2); + else if (result > 0) + { + if (FD_ISSET (selfds[0], &readfds)) + { + read (selfds[0], &c, 1); + if (c == 's') waiting = 1; + } + else + { + pthread_mutex_lock (&select_mutex); + if (select_valid & SELECT_HAVE_READ) + select_readfds = readfds; + if (select_valid & SELECT_HAVE_WRITE) + select_writefds = writefds; + if (select_valid & SELECT_HAVE_TMO) + select_timeout = timeout; + pthread_mutex_unlock (&select_mutex); + + ns_send_appdefined (result); + } + } + waiting = 1; + } } } @@ -6281,7 +6388,7 @@ not_in_argv (NSString *arg) { NSTRACE (EmacsScroller_dealloc); if (!NILP (win)) - WSET (XWINDOW (win), vertical_scroll_bar, Qnil); + wset_vertical_scroll_bar (XWINDOW (win), Qnil); [super dealloc]; } @@ -6404,8 +6511,13 @@ not_in_argv (NSString *arg) XSETINT (emacs_event->x, loc * pixel_height); XSETINT (emacs_event->y, pixel_height-20); - n_emacs_events_pending++; - kbd_buffer_store_event_hold (emacs_event, q_event_ptr); + if (q_event_ptr) + { + n_emacs_events_pending++; + kbd_buffer_store_event_hold (emacs_event, q_event_ptr); + } + else + kbd_buffer_store_event (emacs_event); EVENT_INIT (*emacs_event); ns_send_appdefined (-1); } @@ -6675,20 +6787,20 @@ ns_xlfd_to_fontname (const char *xlfd) /* undo hack in ns_fontname_to_xlfd, converting '$' to '-', '_' to ' ' also uppercase after '-' or ' ' */ - name[0] = toupper (name[0]); + name[0] = c_toupper (name[0]); for (len =strlen (name), i =0; i<len; i++) { if (name[i] == '$') { name[i] = '-'; if (i+1<len) - name[i+1] = toupper (name[i+1]); + name[i+1] = c_toupper (name[i+1]); } else if (name[i] == '_') { name[i] = ' '; if (i+1<len) - name[i+1] = toupper (name[i+1]); + name[i+1] = c_toupper (name[i+1]); } } /*fprintf (stderr, "converted '%s' to '%s'\n",xlfd,name); */ diff --git a/src/print.c b/src/print.c index 78a0707627c..e8309109f1d 100644 --- a/src/print.c +++ b/src/print.c @@ -494,14 +494,14 @@ temp_output_buffer_setup (const char *bufname) Fkill_all_local_variables (); delete_all_overlays (current_buffer); - BSET (current_buffer, directory, BVAR (old, directory)); - BSET (current_buffer, read_only, Qnil); - BSET (current_buffer, filename, Qnil); - BSET (current_buffer, undo_list, Qt); + bset_directory (current_buffer, BVAR (old, directory)); + bset_read_only (current_buffer, Qnil); + bset_filename (current_buffer, Qnil); + bset_undo_list (current_buffer, Qt); eassert (current_buffer->overlays_before == NULL); eassert (current_buffer->overlays_after == NULL); - BSET (current_buffer, enable_multibyte_characters, - BVAR (&buffer_defaults, enable_multibyte_characters)); + bset_enable_multibyte_characters + (current_buffer, BVAR (&buffer_defaults, enable_multibyte_characters)); specbind (Qinhibit_read_only, Qt); specbind (Qinhibit_modification_hooks, Qt); Ferase_buffer (); @@ -1194,7 +1194,7 @@ print_preprocess (Lisp_Object obj) { case Lisp_String: /* A string may have text properties, which can be circular. */ - traverse_intervals_noorder (string_get_intervals (obj), + traverse_intervals_noorder (string_intervals (obj), print_preprocess_string, Qnil); break; @@ -1297,7 +1297,7 @@ static Lisp_Object print_prune_string_charset (Lisp_Object string) { print_check_string_result = 0; - traverse_intervals (string_get_intervals (string), 0, + traverse_intervals (string_intervals (string), 0, print_check_string_charset_prop, string); if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) { @@ -1408,7 +1408,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag if (! EQ (Vprint_charset_text_property, Qt)) obj = print_prune_string_charset (obj); - if (string_get_intervals (obj)) + if (string_intervals (obj)) { PRINTCHAR ('#'); PRINTCHAR ('('); @@ -1499,9 +1499,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag } PRINTCHAR ('\"'); - if (string_get_intervals (obj)) + if (string_intervals (obj)) { - traverse_intervals (string_get_intervals (obj), + traverse_intervals (string_intervals (obj), 0, print_interval, printcharfun); PRINTCHAR (')'); } diff --git a/src/process.c b/src/process.c index ada673e3c34..fa138027ec1 100644 --- a/src/process.c +++ b/src/process.c @@ -20,6 +20,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> + +#define PROCESS_INLINE EXTERN_INLINE + #include <signal.h> #include <stdio.h> #include <errno.h> @@ -312,6 +315,93 @@ static struct sockaddr_and_len { /* Maximum number of bytes to send to a pty without an eof. */ static int pty_max_bytes; +/* These setters are used only in this file, so they can be private. */ +static inline void +pset_buffer (struct Lisp_Process *p, Lisp_Object val) +{ + p->buffer = val; +} +static inline void +pset_command (struct Lisp_Process *p, Lisp_Object val) +{ + p->command = val; +} +static inline void +pset_decode_coding_system (struct Lisp_Process *p, Lisp_Object val) +{ + p->decode_coding_system = val; +} +static inline void +pset_decoding_buf (struct Lisp_Process *p, Lisp_Object val) +{ + p->decoding_buf = val; +} +static inline void +pset_encode_coding_system (struct Lisp_Process *p, Lisp_Object val) +{ + p->encode_coding_system = val; +} +static inline void +pset_encoding_buf (struct Lisp_Process *p, Lisp_Object val) +{ + p->encoding_buf = val; +} +static inline void +pset_filter (struct Lisp_Process *p, Lisp_Object val) +{ + p->filter = val; +} +static inline void +pset_log (struct Lisp_Process *p, Lisp_Object val) +{ + p->log = val; +} +static inline void +pset_mark (struct Lisp_Process *p, Lisp_Object val) +{ + p->mark = val; +} +static inline void +pset_thread (struct Lisp_Process *p, Lisp_Object val) +{ + p->thread = val; +} +static inline void +pset_name (struct Lisp_Process *p, Lisp_Object val) +{ + p->name = val; +} +static inline void +pset_plist (struct Lisp_Process *p, Lisp_Object val) +{ + p->plist = val; +} +static inline void +pset_sentinel (struct Lisp_Process *p, Lisp_Object val) +{ + p->sentinel = val; +} +static inline void +pset_status (struct Lisp_Process *p, Lisp_Object val) +{ + p->status = val; +} +static inline void +pset_tty_name (struct Lisp_Process *p, Lisp_Object val) +{ + p->tty_name = val; +} +static inline void +pset_type (struct Lisp_Process *p, Lisp_Object val) +{ + p->type = val; +} +static inline void +pset_write_queue (struct Lisp_Process *p, Lisp_Object val) +{ + p->write_queue = val; +} + enum fd_bits @@ -562,7 +652,7 @@ static void update_status (struct Lisp_Process *p) { eassert (p->raw_status_new); - PSET (p, status, status_convert (p->raw_status)); + pset_status (p, status_convert (p->raw_status)); p->raw_status_new = 0; } @@ -760,9 +850,9 @@ make_process (Lisp_Object name) p = allocate_process (); /* Initialize Lisp data. Note that allocate_process initializes all Lisp data to nil, so do it only for slots which should not be nil. */ - PSET (p, status, Qrun); - PSET (p, mark, Fmake_marker ()); - PSET (p, thread, Fcurrent_thread ()); + pset_status (p, Qrun); + pset_mark (p, Fmake_marker ()); + pset_thread (p, Fcurrent_thread ()); /* Initialize non-Lisp data. Note that allocate_process zeroes out all non-Lisp data, so do it only for slots which should not be zero. */ @@ -783,7 +873,7 @@ make_process (Lisp_Object name) name1 = concat2 (name, make_formatted_string (suffix, "<%"pMd">", i)); } name = name1; - PSET (p, name, name); + pset_name (p, name); XSETPROCESS (val, p); Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist); return val; @@ -901,7 +991,7 @@ nil, indicating the current buffer's process. */) p->raw_status_new = 0; if (NETCONN1_P (p) || SERIALCONN1_P (p)) { - PSET (p, status, Fcons (Qexit, Fcons (make_number (0), Qnil))); + pset_status (p, Fcons (Qexit, Fcons (make_number (0), Qnil))); p->tick = ++process_tick; status_notify (p); redisplay_preserve_echo_area (13); @@ -930,7 +1020,7 @@ nil, indicating the current buffer's process. */) { Fkill_process (process, Qnil); /* Do this now, since remove_process will make sigchld_handler do nothing. */ - PSET (p, status, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil))); + pset_status (p, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil))); p->tick = ++process_tick; status_notify (p); redisplay_preserve_echo_area (13); @@ -1057,9 +1147,9 @@ Return BUFFER. */) if (!NILP (buffer)) CHECK_BUFFER (buffer); p = XPROCESS (process); - PSET (p, buffer, buffer); + pset_buffer (p, buffer); if (NETCONN1_P (p) || SERIALCONN1_P (p)) - PSET (p, childp, Fplist_put (p->childp, QCbuffer, buffer)); + pset_childp (p, Fplist_put (p->childp, QCbuffer, buffer)); setup_process_coding_systems (process); return buffer; } @@ -1124,9 +1214,9 @@ The string argument is normally a multibyte string, except: delete_read_fd (p->infd); } - PSET (p, filter, filter); + pset_filter (p, filter); if (NETCONN1_P (p) || SERIALCONN1_P (p)) - PSET (p, childp, Fplist_put (p->childp, QCfilter, filter)); + pset_childp (p, Fplist_put (p->childp, QCfilter, filter)); setup_process_coding_systems (process); return filter; } @@ -1153,9 +1243,9 @@ It gets two arguments: the process, and a string describing the change. */) CHECK_PROCESS (process); p = XPROCESS (process); - PSET (p, sentinel, sentinel); + pset_sentinel (p, sentinel); if (NETCONN1_P (p) || SERIALCONN1_P (p)) - PSET (p, childp, Fplist_put (p->childp, QCsentinel, sentinel)); + pset_childp (p, Fplist_put (p->childp, QCsentinel, sentinel)); return sentinel; } @@ -1324,7 +1414,7 @@ DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist, CHECK_PROCESS (process); CHECK_LIST (plist); - PSET (XPROCESS (process), plist, plist); + pset_plist (XPROCESS (process), plist); return plist; } @@ -1510,18 +1600,18 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) itself; it's all taken care of here. */ record_unwind_protect (start_process_unwind, proc); - PSET (XPROCESS (proc), childp, Qt); - PSET (XPROCESS (proc), plist, Qnil); - PSET (XPROCESS (proc), type, Qreal); - PSET (XPROCESS (proc), buffer, buffer); - PSET (XPROCESS (proc), sentinel, Qnil); - PSET (XPROCESS (proc), filter, Qnil); - PSET (XPROCESS (proc), command, Flist (nargs - 2, args + 2)); + pset_childp (XPROCESS (proc), Qt); + pset_plist (XPROCESS (proc), Qnil); + pset_type (XPROCESS (proc), Qreal); + pset_buffer (XPROCESS (proc), buffer); + pset_sentinel (XPROCESS (proc), Qnil); + pset_filter (XPROCESS (proc), Qnil); + pset_command (XPROCESS (proc), Flist (nargs - 2, args + 2)); #ifdef HAVE_GNUTLS /* AKA GNUTLS_INITSTAGE(proc). */ XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY; - PSET (XPROCESS (proc), gnutls_cred_type, Qnil); + pset_gnutls_cred_type (XPROCESS (proc), Qnil); #endif #ifdef ADAPTIVE_READ_BUFFERING @@ -1561,7 +1651,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) else if (CONSP (Vdefault_process_coding_system)) val = XCAR (Vdefault_process_coding_system); } - PSET (XPROCESS (proc), decode_coding_system, val); + pset_decode_coding_system (XPROCESS (proc), val); val = Vcoding_system_for_write; if (NILP (val)) @@ -1581,7 +1671,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) else if (CONSP (Vdefault_process_coding_system)) val = XCDR (Vdefault_process_coding_system); } - PSET (XPROCESS (proc), encode_coding_system, val); + pset_encode_coding_system (XPROCESS (proc), val); /* Note: At this moment, the above coding system may leave text-conversion or eol-conversion unspecified. They will be decided after we read output from the process and decode it by @@ -1590,9 +1680,9 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) } - PSET (XPROCESS (proc), decoding_buf, empty_unibyte_string); + pset_decoding_buf (XPROCESS (proc), empty_unibyte_string); XPROCESS (proc)->decoding_carryover = 0; - PSET (XPROCESS (proc), encoding_buf, empty_unibyte_string); + pset_encoding_buf (XPROCESS (proc), empty_unibyte_string); XPROCESS (proc)->inherit_coding_system_flag = !(NILP (buffer) || !inherit_process_coding_system); @@ -1724,9 +1814,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) /* Use volatile to protect variables from being clobbered by longjmp. */ volatile int forkin, forkout; volatile int pty_flag = 0; -#ifndef USE_CRT_DLL - extern char **environ; -#endif inchannel = outchannel = -1; @@ -1814,7 +1901,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) more portable (see USG_SUBTTY_WORKS above). */ XPROCESS (process)->pty_flag = pty_flag; - PSET (XPROCESS (process), status, Qrun); + pset_status (XPROCESS (process), Qrun); /* Delay interrupts until we have a chance to store the new fork's pid in its process structure */ @@ -2050,10 +2137,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) #ifdef HAVE_PTYS if (pty_flag) - PSET (XPROCESS (process), tty_name, build_string (pty_name)); + pset_tty_name (XPROCESS (process), build_string (pty_name)); else #endif - PSET (XPROCESS (process), tty_name, Qnil); + pset_tty_name (XPROCESS (process), Qnil); #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) /* Wait for child_setup to complete in case that vfork is @@ -2148,7 +2235,7 @@ create_pty (Lisp_Object process) more portable (see USG_SUBTTY_WORKS above). */ XPROCESS (process)->pty_flag = pty_flag; - PSET (XPROCESS (process), status, Qrun); + pset_status (XPROCESS (process), Qrun); setup_process_coding_systems (process); add_non_keyboard_read_fd (inchannel); @@ -2156,10 +2243,10 @@ create_pty (Lisp_Object process) XPROCESS (process)->pid = -2; #ifdef HAVE_PTYS if (pty_flag) - PSET (XPROCESS (process), tty_name, build_string (pty_name)); + pset_tty_name (XPROCESS (process), build_string (pty_name)); else #endif - PSET (XPROCESS (process), tty_name, Qnil); + pset_tty_name (XPROCESS (process), Qnil); } @@ -2548,7 +2635,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */) if (set_socket_option (s, option, value)) { - PSET (p, childp, Fplist_put (p->childp, option, value)); + pset_childp (p, Fplist_put (p->childp, option, value)); return Qt; } @@ -2781,18 +2868,18 @@ usage: (make-serial-process &rest ARGS) */) if (NILP (buffer)) buffer = name; buffer = Fget_buffer_create (buffer); - PSET (p, buffer, buffer); - - PSET (p, childp, contact); - PSET (p, plist, Fcopy_sequence (Fplist_get (contact, QCplist))); - PSET (p, type, Qserial); - PSET (p, sentinel, Fplist_get (contact, QCsentinel)); - PSET (p, filter, Fplist_get (contact, QCfilter)); - PSET (p, log, Qnil); + pset_buffer (p, buffer); + + pset_childp (p, contact); + pset_plist (p, Fcopy_sequence (Fplist_get (contact, QCplist))); + pset_type (p, Qserial); + pset_sentinel (p, Fplist_get (contact, QCsentinel)); + pset_filter (p, Fplist_get (contact, QCfilter)); + pset_log (p, Qnil); if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) p->kill_without_query = 1; if (tem = Fplist_get (contact, QCstop), !NILP (tem)) - PSET (p, command, Qt); + pset_command (p, Qt); p->pty_flag = 0; if (!EQ (p->command, Qt)) @@ -2821,7 +2908,7 @@ usage: (make-serial-process &rest ARGS) */) else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters))) || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))) val = Qnil; - PSET (p, decode_coding_system, val); + pset_decode_coding_system (p, val); val = Qnil; if (!NILP (tem)) @@ -2835,12 +2922,12 @@ usage: (make-serial-process &rest ARGS) */) else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters))) || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))) val = Qnil; - PSET (p, encode_coding_system, val); + pset_encode_coding_system (p, val); setup_process_coding_systems (proc); - PSET (p, decoding_buf, empty_unibyte_string); + pset_decoding_buf (p, empty_unibyte_string); p->decoding_carryover = 0; - PSET (p, encoding_buf, empty_unibyte_string); + pset_encoding_buf (p, empty_unibyte_string); p->inherit_coding_system_flag = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); @@ -3577,23 +3664,23 @@ usage: (make-network-process &rest ARGS) */) p = XPROCESS (proc); - PSET (p, childp, contact); - PSET (p, plist, Fcopy_sequence (Fplist_get (contact, QCplist))); - PSET (p, type, Qnetwork); + pset_childp (p, contact); + pset_plist (p, Fcopy_sequence (Fplist_get (contact, QCplist))); + pset_type (p, Qnetwork); - PSET (p, buffer, buffer); - PSET (p, sentinel, sentinel); - PSET (p, filter, filter); - PSET (p, log, Fplist_get (contact, QClog)); + pset_buffer (p, buffer); + pset_sentinel (p, sentinel); + pset_filter (p, filter); + pset_log (p, Fplist_get (contact, QClog)); if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) p->kill_without_query = 1; if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) - PSET (p, command, Qt); + pset_command (p, Qt); p->pid = 0; p->infd = inch; p->outfd = outch; if (is_server && socktype != SOCK_DGRAM) - PSET (p, status, Qlisten); + pset_status (p, Qlisten); /* Make the process marker point into the process buffer (if any). */ if (BUFFERP (buffer)) @@ -3607,7 +3694,7 @@ usage: (make-network-process &rest ARGS) */) /* We may get here if connect did succeed immediately. However, in that case, we still need to signal this like a non-blocking connection. */ - PSET (p, status, Qconnect); + pset_status (p, Qconnect); if ((fd_callback_info[inch].flags & NON_BLOCKING_CONNECT_FD) == 0) add_non_blocking_write_fd (inch); } @@ -3667,7 +3754,7 @@ usage: (make-network-process &rest ARGS) */) else val = Qnil; } - PSET (p, decode_coding_system, val); + pset_decode_coding_system (p, val); if (!NILP (tem)) { @@ -3701,13 +3788,13 @@ usage: (make-network-process &rest ARGS) */) else val = Qnil; } - PSET (p, encode_coding_system, val); + pset_encode_coding_system (p, val); } setup_process_coding_systems (proc); - PSET (p, decoding_buf, empty_unibyte_string); + pset_decoding_buf (p, empty_unibyte_string); p->decoding_carryover = 0; - PSET (p, encoding_buf, empty_unibyte_string); + pset_encoding_buf (p, empty_unibyte_string); p->inherit_coding_system_flag = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); @@ -4324,18 +4411,18 @@ server_accept_connection (Lisp_Object server, int channel) conv_sockaddr_to_lisp (&saddr.sa, len)); #endif - PSET (p, childp, contact); - PSET (p, plist, Fcopy_sequence (ps->plist)); - PSET (p, type, Qnetwork); + pset_childp (p, contact); + pset_plist (p, Fcopy_sequence (ps->plist)); + pset_type (p, Qnetwork); - PSET (p, buffer, buffer); - PSET (p, sentinel, ps->sentinel); - PSET (p, filter, ps->filter); - PSET (p, command, Qnil); + pset_buffer (p, buffer); + pset_sentinel (p, ps->sentinel); + pset_filter (p, ps->filter); + pset_command (p, Qnil); p->pid = 0; p->infd = s; p->outfd = s; - PSET (p, status, Qrun); + pset_status (p, Qrun); /* Client processes for accepted connections are not stopped initially. */ if (!EQ (p->filter, Qt)) @@ -4346,13 +4433,13 @@ server_accept_connection (Lisp_Object server, int channel) of the new process should reflect the settings at the time the server socket was opened; not the current settings. */ - PSET (p, decode_coding_system, ps->decode_coding_system); - PSET (p, encode_coding_system, ps->encode_coding_system); + pset_decode_coding_system (p, ps->decode_coding_system); + pset_encode_coding_system (p, ps->encode_coding_system); setup_process_coding_systems (proc); - PSET (p, decoding_buf, empty_unibyte_string); + pset_decoding_buf (p, empty_unibyte_string); p->decoding_carryover = 0; - PSET (p, encoding_buf, empty_unibyte_string); + pset_encoding_buf (p, empty_unibyte_string); p->inherit_coding_system_flag = (NILP (buffer) ? 0 : ps->inherit_coding_system_flag); @@ -5052,7 +5139,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, waitpid() will not find the process object to delete. Do it here. */ p->tick = ++process_tick; - PSET (p, status, Qfailed); + pset_status (p, Qfailed); } else kill (getpid (), SIGCHLD); @@ -5072,8 +5159,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (XPROCESS (proc)->raw_status_new) update_status (XPROCESS (proc)); if (EQ (XPROCESS (proc)->status, Qrun)) - PSET (XPROCESS (proc), status, - Fcons (Qexit, Fcons (make_number (256), Qnil))); + pset_status (XPROCESS (proc), + list2 (Qexit, make_number (256))); } } #ifdef NON_BLOCKING_CONNECT @@ -5119,13 +5206,12 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (xerrno) { p->tick = ++process_tick; - PSET (p, status, - Fcons (Qfailed, Fcons (make_number (xerrno), Qnil))); + pset_status (p, list2 (Qfailed, make_number (xerrno))); deactivate_process (proc); } else { - PSET (p, status, Qrun); + pset_status (p, Qrun); /* Execute the sentinel here. If we had relied on status_notify to do it later, it will read input from the process before calling the sentinel. */ @@ -5322,7 +5408,7 @@ read_process_output (Lisp_Object proc, register int channel) /* A new coding system might be found. */ if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) { - PSET (p, decode_coding_system, Vlast_coding_system_used); + pset_decode_coding_system (p, Vlast_coding_system_used); /* Don't call setup_coding_system for proc_decode_coding_system[channel] here. It is done in @@ -5338,8 +5424,8 @@ read_process_output (Lisp_Object proc, register int channel) if (NILP (p->encode_coding_system) && proc_encode_coding_system[p->outfd]) { - PSET (p, encode_coding_system, - coding_inherit_eol_type (Vlast_coding_system_used, Qnil)); + pset_encode_coding_system + (p, coding_inherit_eol_type (Vlast_coding_system_used, Qnil)); setup_coding_system (p->encode_coding_system, proc_encode_coding_system[p->outfd]); } @@ -5348,7 +5434,7 @@ read_process_output (Lisp_Object proc, register int channel) if (coding->carryover_bytes > 0) { if (SCHARS (p->decoding_buf) < coding->carryover_bytes) - PSET (p, decoding_buf, make_uninit_string (coding->carryover_bytes)); + pset_decoding_buf (p, make_uninit_string (coding->carryover_bytes)); memcpy (SDATA (p->decoding_buf), coding->carryover, coding->carryover_bytes); p->decoding_carryover = coding->carryover_bytes; @@ -5404,7 +5490,7 @@ read_process_output (Lisp_Object proc, register int channel) old_begv_byte = BEGV_BYTE; old_zv_byte = ZV_BYTE; - BSET (current_buffer, read_only, Qnil); + bset_read_only (current_buffer, Qnil); /* Insert new output into buffer at the current end-of-output marker, @@ -5432,12 +5518,12 @@ read_process_output (Lisp_Object proc, register int channel) similar code in the previous `if' block. */ if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) { - PSET (p, decode_coding_system, Vlast_coding_system_used); + pset_decode_coding_system (p, Vlast_coding_system_used); if (NILP (p->encode_coding_system) && proc_encode_coding_system[p->outfd]) { - PSET (p, encode_coding_system, - coding_inherit_eol_type (Vlast_coding_system_used, Qnil)); + pset_encode_coding_system + (p, coding_inherit_eol_type (Vlast_coding_system_used, Qnil)); setup_coding_system (p->encode_coding_system, proc_encode_coding_system[p->outfd]); } @@ -5445,7 +5531,7 @@ read_process_output (Lisp_Object proc, register int channel) if (coding->carryover_bytes > 0) { if (SCHARS (p->decoding_buf) < coding->carryover_bytes) - PSET (p, decoding_buf, make_uninit_string (coding->carryover_bytes)); + pset_decoding_buf (p, make_uninit_string (coding->carryover_bytes)); memcpy (SDATA (p->decoding_buf), coding->carryover, coding->carryover_bytes); p->decoding_carryover = coding->carryover_bytes; @@ -5495,7 +5581,7 @@ read_process_output (Lisp_Object proc, register int channel) Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); - BSET (current_buffer, read_only, old_read_only); + bset_read_only (current_buffer, old_read_only); SET_PT_BOTH (opoint, opoint_byte); } /* Handling the process output should not deactivate the mark. */ @@ -5562,9 +5648,9 @@ write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, entry = Fcons (obj, Fcons (make_number (offset), make_number (len))); if (front) - PSET (p, write_queue, Fcons (entry, p->write_queue)); + pset_write_queue (p, Fcons (entry, p->write_queue)); else - PSET (p, write_queue, nconc2 (p->write_queue, Fcons (entry, Qnil))); + pset_write_queue (p, nconc2 (p->write_queue, Fcons (entry, Qnil))); } /* Remove the first element in the write_queue of process P, put its @@ -5582,7 +5668,7 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, return 0; entry = XCAR (p->write_queue); - PSET (p, write_queue, XCDR (p->write_queue)); + pset_write_queue (p, XCDR (p->write_queue)); *obj = XCAR (entry); offset_length = XCDR (entry); @@ -5629,8 +5715,8 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, && !NILP (BVAR (XBUFFER (object), enable_multibyte_characters))) || EQ (object, Qt)) { - PSET (p, encode_coding_system, - complement_process_encoding_system (p->encode_coding_system)); + pset_encode_coding_system + (p, complement_process_encoding_system (p->encode_coding_system)); if (!EQ (Vlast_coding_system_used, p->encode_coding_system)) { /* The coding system for encoding was changed to raw-text @@ -5851,7 +5937,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, proc = process_sent_to; p = XPROCESS (proc); p->raw_status_new = 0; - PSET (p, status, Fcons (Qexit, Fcons (make_number (256), Qnil))); + pset_status (p, Fcons (Qexit, Fcons (make_number (256), Qnil))); p->tick = ++process_tick; deactivate_process (proc); error ("SIGPIPE raised on process %s; closed it", SDATA (p->name)); @@ -6080,7 +6166,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, #ifdef SIGCONT case SIGCONT: p->raw_status_new = 0; - PSET (p, status, Qrun); + pset_status (p, Qrun); p->tick = ++process_tick; if (!nomsg) { @@ -6173,7 +6259,7 @@ traffic. */) if (NILP (p->command) && p->infd >= 0) delete_read_fd (p->infd); - PSET (p, command, Qt); + pset_command (p, Qt); return process; } #ifndef SIGTSTP @@ -6208,7 +6294,7 @@ traffic. */) tcflush (p->infd, TCIFLUSH); #endif /* not WINDOWSNT */ } - PSET (p, command, Qnil); + pset_command (p, Qnil); return process; } #ifdef SIGCONT @@ -6621,7 +6707,7 @@ sigchld_handler (int signo) static Lisp_Object exec_sentinel_unwind (Lisp_Object data) { - PSET (XPROCESS (XCAR (data)), sentinel, XCDR (data)); + pset_sentinel (XPROCESS (XCAR (data)), XCDR (data)); return Qnil; } @@ -6667,7 +6753,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason) /* Zilch the sentinel while it's running, to avoid recursive invocations; assure that it gets restored no matter how the sentinel exits. */ - PSET (p, sentinel, Qnil); + pset_sentinel (p, Qnil); record_unwind_protect (exec_sentinel_unwind, Fcons (proc, sentinel)); /* Inhibit quit so that random quits don't screw up a running filter. */ specbind (Qinhibit_quit, Qt); @@ -6822,13 +6908,13 @@ status_notify (struct Lisp_Process *deleting_process) before_byte = PT_BYTE; tem = BVAR (current_buffer, read_only); - BSET (current_buffer, read_only, Qnil); + bset_read_only (current_buffer, Qnil); insert_string ("\nProcess "); { /* FIXME: temporary kludge */ Lisp_Object tem2 = p->name; Finsert (1, &tem2); } insert_string (" "); Finsert (1, &msg); - BSET (current_buffer, read_only, tem); + bset_read_only (current_buffer, tem); set_marker_both (p->mark, p->buffer, PT, PT_BYTE); if (opoint >= before) @@ -6865,8 +6951,8 @@ encode subprocess input. */) Fcheck_coding_system (decoding); Fcheck_coding_system (encoding); encoding = coding_inherit_eol_type (encoding, Qnil); - PSET (p, decode_coding_system, decoding); - PSET (p, encode_coding_system, encoding); + pset_decode_coding_system (p, decoding); + pset_encode_coding_system (p, encoding); setup_process_coding_systems (process); return Qnil; @@ -6896,8 +6982,8 @@ suppressed. */) CHECK_PROCESS (process); p = XPROCESS (process); if (NILP (flag)) - PSET (p, decode_coding_system, - raw_text_coding_system (p->decode_coding_system)); + pset_decode_coding_system + (p, raw_text_coding_system (p->decode_coding_system)); setup_process_coding_systems (process); return Qnil; diff --git a/src/process.h b/src/process.h index 1ddfe915357..db000464cb5 100644 --- a/src/process.h +++ b/src/process.h @@ -26,10 +26,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "gnutls.h" #endif -/* Most code should use these macros to set - Lisp fields in struct Lisp_Process. */ - -#define PSET(p, field, value) ((p)->field = (value)) +INLINE_HEADER_BEGIN +#ifndef PROCESS_INLINE +# define PROCESS_INLINE INLINE +#endif /* This structure records information about a subprocess or network connection. */ @@ -168,6 +168,23 @@ struct Lisp_Process #define ChannelMask(n) (1 << (n)) +/* Most code should use these functions to set Lisp fields in struct + process. */ + +PROCESS_INLINE void +pset_childp (struct Lisp_Process *p, Lisp_Object val) +{ + p->childp = val; +} + +#ifdef HAVE_GNUTLS +PROCESS_INLINE void +pset_gnutls_cred_type (struct Lisp_Process *p, Lisp_Object val) +{ + p->gnutls_cred_type = val; +} +#endif + /* True if we are about to fork off a synchronous process or if we are waiting for it. */ extern int synch_process_alive; @@ -213,3 +230,5 @@ extern void add_write_fd (int fd, fd_callback func, void *data); extern void delete_write_fd (int fd); extern void update_processes_for_thread_death (Lisp_Object); + +INLINE_HEADER_END diff --git a/src/search.c b/src/search.c index 5df01f664f7..dac1a8d4dfc 100644 --- a/src/search.c +++ b/src/search.c @@ -278,8 +278,8 @@ looking_at_1 (Lisp_Object string, int posix) save_search_regs (); /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + set_char_table_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); CHECK_STRING (string); bufp = compile_pattern (string, @@ -393,8 +393,8 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int p } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + set_char_table_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); bufp = compile_pattern (regexp, (NILP (Vinhibit_changing_match_data) @@ -990,8 +990,8 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + set_char_table_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); np = search_buffer (string, PT, PT_BYTE, lim, lim_byte, n, RE, (!NILP (BVAR (current_buffer, case_fold_search)) diff --git a/src/syntax.c b/src/syntax.c index 08a63e033b2..f995b8f2cac 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <ctype.h> #include <sys/types.h> #include <setjmp.h> #include "lisp.h" @@ -150,6 +149,13 @@ static void scan_sexps_forward (struct lisp_parse_state *, ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT, int, Lisp_Object, int); static int in_classes (int, Lisp_Object); + +/* This setter is used only in this file, so it can be private. */ +static inline void +bset_syntax_table (struct buffer *b, Lisp_Object val) +{ + b->INTERNAL_FIELD (syntax_table) = val; +} /* Whether the syntax of the character C has the prefix flag set. */ int syntax_prefix_flag_p (int c) @@ -819,7 +825,7 @@ It is a copy of the TABLE, which defaults to the standard syntax table. */) /* Only the standard syntax table should have a default element. Other syntax tables should inherit from parents instead. */ - XCHAR_TABLE (copy)->defalt = Qnil; + set_char_table_defalt (copy, Qnil); /* Copied syntax tables should all have parents. If we copied one with no parent, such as the standard syntax table, @@ -836,7 +842,7 @@ One argument, a syntax table. */) { int idx; check_syntax_table (table); - BSET (current_buffer, syntax_table, table); + bset_syntax_table (current_buffer, table); /* Indicate that this buffer now has a specified syntax table. */ idx = PER_BUFFER_VAR_IDX (syntax_table); SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1); diff --git a/src/sysdep.c b/src/sysdep.c index 01ca905a987..183ee005227 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define SYSTIME_INLINE EXTERN_INLINE -#include <ctype.h> #include <signal.h> #include <stdio.h> #include <setjmp.h> @@ -33,6 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <allocator.h> +#include <c-ctype.h> #include <careadlinkat.h> #include <ignore-value.h> #include <utimens.h> @@ -2307,8 +2307,7 @@ serial_configure (struct Lisp_Process *p, error ("tcsetattr() failed: %s", emacs_strerror (errno)); childp2 = Fplist_put (childp2, QCsummary, build_string (summary)); - PSET (p, childp, childp2); - + pset_childp (p, childp2); } #endif /* not DOS_NT */ @@ -2733,7 +2732,7 @@ system_process_attributes (Lisp_Object pid) if (emacs_read (fd, &ch, 1) != 1) break; c = ch; - if (isspace (c) || c == '\\') + if (c_isspace (c) || c == '\\') cmdline_size++; /* for later quoting, see below */ } if (cmdline_size) @@ -2757,7 +2756,7 @@ system_process_attributes (Lisp_Object pid) for (p = cmdline; p < cmdline + nread; p++) { /* Escape-quote whitespace and backslashes. */ - if (isspace (*p) || *p == '\\') + if (c_isspace (*p) || *p == '\\') { memmove (p + 1, p, nread - (p - cmdline)); nread++; diff --git a/src/term.c b/src/term.c index 514c7ad11ec..23e074287c1 100644 --- a/src/term.c +++ b/src/term.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <ctype.h> #include <errno.h> #include <sys/file.h> #include <sys/time.h> @@ -1333,7 +1332,7 @@ term_get_fkeys_1 (void) /* This can happen if CANNOT_DUMP or with strange options. */ if (!KEYMAPP (KVAR (kboard, Vinput_decode_map))) - KSET (kboard, Vinput_decode_map, Fmake_sparse_keymap (Qnil)); + kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil)); for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) { @@ -3281,7 +3280,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ terminal->kboard = xmalloc (sizeof *terminal->kboard); init_kboard (terminal->kboard); - KSET (terminal->kboard, Vwindow_system, Qnil); + kset_window_system (terminal->kboard, Qnil); terminal->kboard->next_kboard = all_kboards; all_kboards = terminal->kboard; terminal->kboard->reference_count++; diff --git a/src/termhooks.h b/src/termhooks.h index 78d8532e03f..46962a1217d 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -22,6 +22,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "systime.h" /* for Time */ +INLINE_HEADER_BEGIN +#ifndef TERMHOOKS_INLINE +# define TERMHOOKS_INLINE INLINE +#endif + struct glyph; struct frame; @@ -321,10 +326,6 @@ struct ns_display_info; struct x_display_info; struct w32_display_info; -/* Most code should use this macro to set Lisp field in struct terminal. */ - -#define TSET(f, field, value) ((f)->field = (value)) - /* Terminal-local parameters. */ struct terminal { @@ -631,6 +632,18 @@ struct terminal void (*delete_terminal_hook) (struct terminal *); }; +/* Most code should use these functions to set Lisp fields in struct + terminal. */ +TERMHOOKS_INLINE void +tset_charset_list (struct terminal *t, Lisp_Object val) +{ + t->charset_list = val; +} +TERMHOOKS_INLINE void +tset_selection_alist (struct terminal *t, Lisp_Object val) +{ + t->Vselection_alist = val; +} /* Chain of all terminal devices currently in use. */ extern struct terminal *terminal_list; @@ -669,3 +682,5 @@ extern unsigned char *encode_terminal_code (struct glyph *, int, #ifdef HAVE_GPM extern void close_gpm (int gpm_fd); #endif + +INLINE_HEADER_END diff --git a/src/terminal.c b/src/terminal.c index 53610d9736f..d94164a4e40 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -17,6 +17,9 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> + +#define TERMHOOKS_INLINE EXTERN_INLINE + #include <stdio.h> #include <setjmp.h> @@ -39,6 +42,13 @@ struct terminal *initial_terminal; static void delete_initial_terminal (struct terminal *); +/* This setter is used only in this file, so it can be private. */ +static inline void +tset_param_alist (struct terminal *t, Lisp_Object val) +{ + t->param_alist = val; +} + void @@ -446,7 +456,7 @@ store_terminal_param (struct terminal *t, Lisp_Object parameter, Lisp_Object val Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist); if (EQ (old_alist_elt, Qnil)) { - TSET (t, param_alist, Fcons (Fcons (parameter, value), t->param_alist)); + tset_param_alist (t, Fcons (Fcons (parameter, value), t->param_alist)); return Qnil; } else diff --git a/src/textprop.c b/src/textprop.c index ac1980fde78..20d98b0e6f3 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -143,7 +143,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end) && XINT (*end) <= BUF_ZV (b))) args_out_of_range (*begin, *end); - i = buffer_get_intervals (b); + i = buffer_intervals (b); /* If there's no text, there are no properties. */ if (BUF_BEGV (b) == BUF_ZV (b)) @@ -161,7 +161,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en XSETFASTINT (*begin, XFASTINT (*begin)); if (begin != end) XSETFASTINT (*end, XFASTINT (*end)); - i = string_get_intervals (object); + i = string_intervals (object); if (len == 0) return NULL; @@ -338,7 +338,7 @@ set_properties (Lisp_Object properties, INTERVAL interval, Lisp_Object object) } /* Store new properties. */ - interval_set_plist (interval, Fcopy_sequence (properties)); + set_interval_plist (interval, Fcopy_sequence (properties)); } /* Add the properties of PLIST to the interval I, or set @@ -411,7 +411,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object) record_property_change (i->position, LENGTH (i), sym1, Qnil, object); } - interval_set_plist (i, Fcons (sym1, Fcons (val1, i->plist))); + set_interval_plist (i, Fcons (sym1, Fcons (val1, i->plist))); changed++; } } @@ -484,7 +484,7 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object } if (changed) - interval_set_plist (i, current_plist); + set_interval_plist (i, current_plist); return changed; } @@ -510,13 +510,13 @@ interval_of (ptrdiff_t position, Lisp_Object object) beg = BUF_BEGV (b); end = BUF_ZV (b); - i = buffer_get_intervals (b); + i = buffer_intervals (b); } else { beg = 0; end = SCHARS (object); - i = string_get_intervals (object); + i = string_intervals (object); } if (!(beg <= position && position <= end)) @@ -1274,10 +1274,10 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, && XFASTINT (start) == 0 && XFASTINT (end) == SCHARS (object)) { - if (!string_get_intervals (object)) + if (!string_intervals (object)) return Qnil; - string_set_intervals (object, NULL); + set_string_intervals (object, NULL); return Qt; } @@ -1339,7 +1339,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie return; if (i == NULL) - i = find_interval (buffer_get_intervals (XBUFFER (buffer)), s); + i = find_interval (buffer_intervals (XBUFFER (buffer)), s); if (i->position != s) { @@ -1993,10 +1993,10 @@ void verify_interval_modification (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) { - register INTERVAL intervals = buffer_get_intervals (buf); - register INTERVAL i; + INTERVAL intervals = buffer_intervals (buf); + INTERVAL i; Lisp_Object hooks; - register Lisp_Object prev_mod_hooks; + Lisp_Object prev_mod_hooks; Lisp_Object mod_hooks; struct gcpro gcpro1; diff --git a/src/undo.c b/src/undo.c index cfb67ba5bc8..777e3291806 100644 --- a/src/undo.c +++ b/src/undo.c @@ -104,9 +104,9 @@ record_point (ptrdiff_t pt) if (at_boundary && current_buffer == last_boundary_buffer && last_boundary_position != pt) - BSET (current_buffer, undo_list, - Fcons (make_number (last_boundary_position), - BVAR (current_buffer, undo_list))); + bset_undo_list (current_buffer, + Fcons (make_number (last_boundary_position), + BVAR (current_buffer, undo_list))); } /* Record an insertion that just happened or is about to happen, @@ -142,8 +142,8 @@ record_insert (ptrdiff_t beg, ptrdiff_t length) XSETFASTINT (lbeg, beg); XSETINT (lend, beg + length); - BSET (current_buffer, undo_list, - Fcons (Fcons (lbeg, lend), BVAR (current_buffer, undo_list))); + bset_undo_list (current_buffer, + Fcons (Fcons (lbeg, lend), BVAR (current_buffer, undo_list))); } /* Record that a deletion is about to take place, @@ -168,8 +168,9 @@ record_delete (ptrdiff_t beg, Lisp_Object string) record_point (beg); } - BSET (current_buffer, undo_list, - Fcons (Fcons (string, sbeg), BVAR (current_buffer, undo_list))); + bset_undo_list + (current_buffer, + Fcons (Fcons (string, sbeg), BVAR (current_buffer, undo_list))); } /* Record the fact that MARKER is about to be adjusted by ADJUSTMENT. @@ -191,9 +192,10 @@ record_marker_adjustment (Lisp_Object marker, ptrdiff_t adjustment) Fundo_boundary (); last_undo_buffer = current_buffer; - BSET (current_buffer, undo_list, - Fcons (Fcons (marker, make_number (adjustment)), - BVAR (current_buffer, undo_list))); + bset_undo_list + (current_buffer, + Fcons (Fcons (marker, make_number (adjustment)), + BVAR (current_buffer, undo_list))); } /* Record that a replacement is about to take place, @@ -226,9 +228,10 @@ record_first_change (void) if (base_buffer->base_buffer) base_buffer = base_buffer->base_buffer; - BSET (current_buffer, undo_list, - Fcons (Fcons (Qt, make_lisp_time (base_buffer->modtime)), - BVAR (current_buffer, undo_list))); + bset_undo_list + (current_buffer, + Fcons (Fcons (Qt, make_lisp_time (base_buffer->modtime)), + BVAR (current_buffer, undo_list))); } /* Record a change in property PROP (whose old value was VAL) @@ -266,8 +269,8 @@ record_property_change (ptrdiff_t beg, ptrdiff_t length, XSETINT (lbeg, beg); XSETINT (lend, beg + length); entry = Fcons (Qnil, Fcons (prop, Fcons (value, Fcons (lbeg, lend)))); - BSET (current_buffer, undo_list, - Fcons (entry, BVAR (current_buffer, undo_list))); + bset_undo_list (current_buffer, + Fcons (entry, BVAR (current_buffer, undo_list))); current_buffer = obuf; } @@ -290,11 +293,12 @@ but another undo command will undo to the previous boundary. */) /* If we have preallocated the cons cell to use here, use that one. */ XSETCDR (pending_boundary, BVAR (current_buffer, undo_list)); - BSET (current_buffer, undo_list, pending_boundary); + bset_undo_list (current_buffer, pending_boundary); pending_boundary = Qnil; } else - BSET (current_buffer, undo_list, Fcons (Qnil, BVAR (current_buffer, undo_list))); + bset_undo_list (current_buffer, + Fcons (Qnil, BVAR (current_buffer, undo_list))); } last_boundary_position = PT; last_boundary_buffer = current_buffer; @@ -435,7 +439,7 @@ truncate_undo_list (struct buffer *b) XSETCDR (last_boundary, Qnil); /* There's nothing we decided to keep, so clear it out. */ else - BSET (b, undo_list, Qnil); + bset_undo_list (b, Qnil); unbind_to (count, Qnil); } @@ -650,8 +654,9 @@ Return what remains of the list. */) will work right. */ if (did_apply && EQ (oldlist, BVAR (current_buffer, undo_list))) - BSET (current_buffer, undo_list, - Fcons (list3 (Qapply, Qcdr, Qnil), BVAR (current_buffer, undo_list))); + bset_undo_list + (current_buffer, + Fcons (list3 (Qapply, Qcdr, Qnil), BVAR (current_buffer, undo_list))); UNGCPRO; return unbind_to (count, list); diff --git a/src/unexaix.c b/src/unexaix.c index 29fa0fd6287..c09156296f7 100644 --- a/src/unexaix.c +++ b/src/unexaix.c @@ -56,8 +56,9 @@ what you give them. Help stamp out software-hoarding! */ #include <unistd.h> #include <fcntl.h> +#include "mem-limits.h" + char *start_of_text (void); /* Start of text */ -extern char *start_of_data (void); /* Start of initialized data */ extern int _data; extern int _text; diff --git a/src/unexcoff.c b/src/unexcoff.c index 5b269737839..e83042a379d 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c @@ -98,7 +98,7 @@ struct aouthdr #include <sys/file.h> -extern char *start_of_data (void); /* Start of initialized data */ +#include "mem-limits.h" static long block_copy_start; /* Old executable start point */ static struct filehdr f_hdr; /* File header */ diff --git a/src/vm-limit.c b/src/vm-limit.c index c313a900f2c..cf697b56fdf 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -18,6 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <setjmp.h> +#include <unistd.h> /* for 'environ', on AIX */ #include "lisp.h" #include "mem-limits.h" @@ -268,7 +269,6 @@ start_of_data (void) * is known to live at or near the start of the system crt0.c, and * we don't sweat the handful of bytes that might lose. */ - extern char **environ; return ((POINTER) &environ); #else extern int data_start; diff --git a/src/w32.c b/src/w32.c index 61de234cf70..b460660cb8c 100644 --- a/src/w32.c +++ b/src/w32.c @@ -7023,7 +7023,7 @@ serial_configure (struct Lisp_Process *p, Lisp_Object contact) error ("SetCommState() failed"); childp2 = Fplist_put (childp2, QCsummary, build_string (summary)); - PSET (p, childp, childp2); + pset_childp (p, childp2); } #ifdef HAVE_GNUTLS diff --git a/src/w32fns.c b/src/w32fns.c index 7779f032104..9c5231f9d93 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1490,7 +1490,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) else if (!NILP (arg) || NILP (oldval)) return; - FSET (f, icon_name, arg); + fset_icon_name (f, arg); #if 0 if (f->output_data.w32->icon_bitmap != 0) @@ -1686,7 +1686,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit) if (! NILP (Fstring_equal (name, f->name))) return; - FSET (f, name, name); + fset_name (f, name); /* For setting the frame title, the title parameter should override the name parameter. */ @@ -1734,7 +1734,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) update_mode_lines = 1; - FSET (f, title, name); + fset_title (f, name); if (NILP (name)) name = f->name; @@ -3925,7 +3925,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only) f->explicit_name = 0; name = f->name; - FSET (f, name, Qnil); + fset_name (f, Qnil); x_set_name (f, name, explicit); } @@ -4174,11 +4174,11 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_data.w32 = xzalloc (sizeof (struct w32_output)); FRAME_FONTSET (f) = -1; - FSET (f, icon_name, - x_get_arg (dpyinfo, parameters, Qicon_name, "iconName", "Title", + fset_icon_name + (f, x_get_arg (dpyinfo, parameters, Qicon_name, "iconName", "Title", RES_TYPE_STRING)); if (! STRINGP (f->icon_name)) - FSET (f, icon_name, Qnil); + fset_icon_name (f, Qnil); /* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */ @@ -4207,12 +4207,12 @@ This function is an internal primitive--use `make-frame' instead. */) be set. */ if (EQ (name, Qunbound) || NILP (name)) { - FSET (f, name, build_string (dpyinfo->w32_id_name)); + fset_name (f, build_string (dpyinfo->w32_id_name)); f->explicit_name = 0; } else { - FSET (f, name, name); + fset_name (f, name); f->explicit_name = 1; /* use the frame's title when getting resources for this frame. */ specbind (Qx_resource_name, name); @@ -4381,13 +4381,13 @@ This function is an internal primitive--use `make-frame' instead. */) if (FRAME_HAS_MINIBUF_P (f) && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame)) || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame))))) - KSET (kb, Vdefault_minibuffer_frame, frame); + kset_default_minibuffer_frame (kb, frame); /* All remaining specified parameters, which have not been "used" by x_get_arg and friends, now go in the misc. alist of the frame. */ for (tem = parameters; CONSP (tem); tem = XCDR (tem)) if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) - FSET (f, param_alist, Fcons (XCAR (tem), f->param_alist)); + fset_param_alist (f, Fcons (XCAR (tem), f->param_alist)); UNGCPRO; @@ -5242,7 +5242,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, set_window_buffer (FRAME_ROOT_WINDOW (f), buffer, 0, 0); old_buffer = current_buffer; set_buffer_internal_1 (XBUFFER (buffer)); - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); specbind (Qinhibit_read_only, Qt); specbind (Qinhibit_modification_hooks, Qt); Ferase_buffer (); @@ -5261,7 +5261,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, f->output_data.w32 = xzalloc (sizeof (struct w32_output)); FRAME_FONTSET (f) = -1; - FSET (f, icon_name, Qnil); + fset_icon_name (f, Qnil); #ifdef GLYPH_DEBUG image_cache_refcount = @@ -5276,12 +5276,12 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, be set. */ if (EQ (name, Qunbound) || NILP (name)) { - FSET (f, name, build_string (dpyinfo->w32_id_name)); + fset_name (f, build_string (dpyinfo->w32_id_name)); f->explicit_name = 0; } else { - FSET (f, name, name); + fset_name (f, name); f->explicit_name = 1; /* use the frame's title when getting resources for this frame. */ specbind (Qx_resource_name, name); @@ -5647,8 +5647,8 @@ Text larger than the specified size is clipped. */) /* Set up the frame's root window. */ w = XWINDOW (FRAME_ROOT_WINDOW (f)); - WSET (w, left_col, make_number (0)); - WSET (w, top_line, make_number (0)); + wset_left_col (w, make_number (0)); + wset_top_line (w, make_number (0)); if (CONSP (Vx_max_tooltip_size) && INTEGERP (XCAR (Vx_max_tooltip_size)) @@ -5656,13 +5656,13 @@ Text larger than the specified size is clipped. */) && INTEGERP (XCDR (Vx_max_tooltip_size)) && XINT (XCDR (Vx_max_tooltip_size)) > 0) { - WSET (w, total_cols, XCAR (Vx_max_tooltip_size)); - WSET (w, total_lines, XCDR (Vx_max_tooltip_size)); + wset_total_cols (w, XCAR (Vx_max_tooltip_size)); + wset_total_lines (w, XCDR (Vx_max_tooltip_size)); } else { - WSET (w, total_cols, make_number (80)); - WSET (w, total_lines, make_number (40)); + wset_total_cols (w, make_number (80)); + wset_total_lines (w, make_number (40)); } FRAME_TOTAL_COLS (f) = XINT (w->total_cols); @@ -5672,7 +5672,7 @@ Text larger than the specified size is clipped. */) /* Display the tooltip text in a temporary buffer. */ old_buffer = current_buffer; set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); @@ -5733,7 +5733,7 @@ Text larger than the specified size is clipped. */) /* w->total_cols and FRAME_TOTAL_COLS want the width in columns, not in pixels. */ width /= WINDOW_FRAME_COLUMN_WIDTH (w); - WSET (w, total_cols, make_number (width)); + wset_total_cols (w, make_number (width)); FRAME_TOTAL_COLS (f) = width; adjust_glyphs (f); w->pseudo_window_p = 1; diff --git a/src/w32menu.c b/src/w32menu.c index 02302c2d594..3aa4c8bc96d 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -413,7 +413,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) /* Run the hooks. */ safe_run_hooks (Qactivate_menubar_hook); safe_run_hooks (Qmenu_bar_update_hook); - FSET (f, menu_bar_items, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); + fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); items = FRAME_MENU_BAR_ITEMS (f); @@ -500,7 +500,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) return; } - FSET (f, menu_bar_vector, menu_items); + fset_menu_bar_vector (f, menu_items); f->menu_bar_items_used = menu_items_used; /* This undoes save_menu_items. */ @@ -615,7 +615,7 @@ initialize_frame_menubar (FRAME_PTR f) { /* This function is called before the first chance to redisplay the frame. It has to be, so the frame will have the right size. */ - FSET (f, menu_bar_items, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); + fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); set_frame_menubar (f, 1, 1); } diff --git a/src/w32term.c b/src/w32term.c index 7da9433d3f1..6948a98998e 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -2972,7 +2972,7 @@ x_frame_rehighlight (struct w32_display_info *dpyinfo) : dpyinfo->w32_focus_frame); if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame)) { - FSET (dpyinfo->w32_focus_frame, focus_frame, Qnil); + fset_focus_frame (dpyinfo->w32_focus_frame, Qnil); dpyinfo->x_highlight_frame = dpyinfo->w32_focus_frame; } } @@ -3646,7 +3646,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height) bar->next = FRAME_SCROLL_BARS (f); bar->prev = Qnil; XSETVECTOR (barobj, bar); - FSET (f, scroll_bars, barobj); + fset_scroll_bars (f, barobj); if (! NILP (bar->next)) XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); @@ -3670,7 +3670,7 @@ x_scroll_bar_remove (struct scroll_bar *bar) my_destroy_window (f, SCROLL_BAR_W32_WINDOW (bar)); /* Dissociate this scroll bar from its window. */ - WSET (XWINDOW (bar->window), vertical_scroll_bar, Qnil); + wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil); UNBLOCK_INPUT; } @@ -3808,7 +3808,7 @@ w32_set_vertical_scroll_bar (struct window *w, w32_set_scroll_bar_thumb (bar, portion, position, whole); XSETVECTOR (barobj, bar); - WSET (w, vertical_scroll_bar, barobj); + wset_vertical_scroll_bar (w, barobj); } @@ -3832,12 +3832,12 @@ w32_condemn_scroll_bars (FRAME_PTR frame) { Lisp_Object bar; bar = FRAME_SCROLL_BARS (frame); - FSET (frame, scroll_bars, XSCROLL_BAR (bar)->next); + fset_scroll_bars (frame, XSCROLL_BAR (bar)->next); XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame); XSCROLL_BAR (bar)->prev = Qnil; if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame))) XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar; - FSET (frame, condemned_scroll_bars, bar); + fset_condemned_scroll_bars (frame, bar); } } @@ -3869,7 +3869,7 @@ w32_redeem_scroll_bar (struct window *window) return; else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f), window->vertical_scroll_bar)) - FSET (f, condemned_scroll_bars, bar->next); + fset_condemned_scroll_bars (f, bar->next); else /* If its prev pointer is nil, it must be at the front of one or the other! */ @@ -3884,7 +3884,7 @@ w32_redeem_scroll_bar (struct window *window) bar->next = FRAME_SCROLL_BARS (f); bar->prev = Qnil; XSETVECTOR (barobj, bar); - FSET (f, scroll_bars, barobj); + fset_scroll_bars (f, barobj); if (! NILP (bar->next)) XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); } @@ -3901,7 +3901,7 @@ w32_judge_scroll_bars (FRAME_PTR f) /* Clear out the condemned list now so we won't try to process any more events on the hapless scroll bars. */ - FSET (f, condemned_scroll_bars, Qnil); + fset_condemned_scroll_bars (f, Qnil); for (; ! NILP (bar); bar = next) { @@ -6232,7 +6232,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) terminal like X does. */ terminal->kboard = xmalloc (sizeof (KBOARD)); init_kboard (terminal->kboard); - KSET (terminal->kboard, Vwindow_system, intern ("w32")); + kset_window_system (terminal->kboard, intern ("w32")); terminal->kboard->next_kboard = all_kboards; all_kboards = terminal->kboard; /* Don't let the initial kboard remain current longer than necessary. diff --git a/src/window.c b/src/window.c index e404b332516..20325711e73 100644 --- a/src/window.c +++ b/src/window.c @@ -19,6 +19,9 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> + +#define WINDOW_INLINE EXTERN_INLINE + #include <stdio.h> #include <setjmp.h> @@ -51,7 +54,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "nsterm.h" #endif -Lisp_Object Qwindowp, Qwindow_live_p; +Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_valid_p; static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; @@ -61,7 +64,6 @@ static Lisp_Object Qsafe, Qabove, Qbelow; static Lisp_Object Qauto_buffer_name, Qclone_of; static int displayed_window_lines (struct window *); -static struct window *decode_window (Lisp_Object); static int count_windows (struct window *); static int get_leaf_windows (struct window *, struct window **, int); static void window_scroll (Lisp_Object, EMACS_INT, int, int); @@ -131,8 +133,120 @@ static int window_scroll_pixel_based_preserve_y; static EMACS_INT window_scroll_preserve_hpos; static EMACS_INT window_scroll_preserve_vpos; -static struct window * -decode_window (register Lisp_Object window) +/* These setters are used only in this file, so they can be private. */ +static inline void +wset_combination_limit (struct window *w, Lisp_Object val) +{ + w->combination_limit = val; +} +static inline void +wset_dedicated (struct window *w, Lisp_Object val) +{ + w->dedicated = val; +} +static inline void +wset_display_table (struct window *w, Lisp_Object val) +{ + w->display_table = val; +} +static inline void +wset_hchild (struct window *w, Lisp_Object val) +{ + w->hchild = val; +} +static inline void +wset_left_fringe_width (struct window *w, Lisp_Object val) +{ + w->left_fringe_width = val; +} +static inline void +wset_left_margin_cols (struct window *w, Lisp_Object val) +{ + w->left_margin_cols = val; +} +static inline void +wset_new_normal (struct window *w, Lisp_Object val) +{ + w->new_normal = val; +} +static inline void +wset_new_total (struct window *w, Lisp_Object val) +{ + w->new_total = val; +} +static inline void +wset_next_buffers (struct window *w, Lisp_Object val) +{ + w->next_buffers = val; +} +static inline void +wset_normal_cols (struct window *w, Lisp_Object val) +{ + w->normal_cols = val; +} +static inline void +wset_normal_lines (struct window *w, Lisp_Object val) +{ + w->normal_lines = val; +} +static inline void +wset_parent (struct window *w, Lisp_Object val) +{ + w->parent = val; +} +static inline void +wset_pointm (struct window *w, Lisp_Object val) +{ + w->pointm = val; +} +static inline void +wset_prev_buffers (struct window *w, Lisp_Object val) +{ + w->prev_buffers = val; +} +static inline void +wset_right_fringe_width (struct window *w, Lisp_Object val) +{ + w->right_fringe_width = val; +} +static inline void +wset_right_margin_cols (struct window *w, Lisp_Object val) +{ + w->right_margin_cols = val; +} +static inline void +wset_scroll_bar_width (struct window *w, Lisp_Object val) +{ + w->scroll_bar_width = val; +} +static inline void +wset_start (struct window *w, Lisp_Object val) +{ + w->start = val; +} +static inline void +wset_temslot (struct window *w, Lisp_Object val) +{ + w->temslot = val; +} +static inline void +wset_vchild (struct window *w, Lisp_Object val) +{ + w->vchild = val; +} +static inline void +wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) +{ + w->vertical_scroll_bar_type = val; +} +static inline void +wset_window_parameters (struct window *w, Lisp_Object val) +{ + w->window_parameters = val; +} + +struct window * +decode_live_window (register Lisp_Object window) { if (NILP (window)) return XWINDOW (selected_window); @@ -154,6 +268,19 @@ decode_any_window (register Lisp_Object window) return w; } +struct window * +decode_valid_window (register Lisp_Object window) +{ + struct window *w; + + if (NILP (window)) + return XWINDOW (selected_window); + + CHECK_VALID_WINDOW (window); + w = XWINDOW (window); + return w; +} + DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, doc: /* Return t if OBJECT is a window and nil otherwise. */) (Lisp_Object object) @@ -161,6 +288,15 @@ DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, return WINDOWP (object) ? Qt : Qnil; } +DEFUN ("window-valid-p", Fwindow_valid_p, Swindow_valid_p, 1, 1, 0, + doc: /* Return t if OBJECT is a valid window and nil otherwise. +A valid window is either a window that displays a buffer or an internal +window. Deleted windows are not live. */) + (Lisp_Object object) +{ + return WINDOW_VALID_P (object) ? Qt : Qnil; +} + DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, doc: /* Return t if OBJECT is a live window and nil otherwise. A live window is a window that displays a buffer. @@ -173,10 +309,10 @@ Internal windows and deleted windows are not live. */) /* Frames and windows. */ DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, doc: /* Return the frame that window WINDOW is on. -If WINDOW is omitted or nil, it defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window) { - return decode_any_window (window)->frame; + return decode_valid_window (window)->frame; } DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, @@ -190,8 +326,8 @@ With a window argument, return the root window of that window's frame. */) if (NILP (frame_or_window)) window = SELECTED_FRAME ()->root_window; - else if (WINDOWP (frame_or_window)) - window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; + else if (WINDOW_VALID_P (frame_or_window)) + window = XFRAME (XWINDOW (frame_or_window)->frame)->root_window; else { CHECK_LIVE_FRAME (frame_or_window); @@ -215,18 +351,18 @@ If FRAME is omitted or nil, it defaults to the selected frame. */) DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 0, 1, 0, doc: /* Return non-nil if WINDOW is a minibuffer window. -If WINDOW is omitted or nil, it defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window) { - return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil; + return MINI_WINDOW_P (decode_valid_window (window)) ? Qt : Qnil; } /* Don't move this to window.el - this must be a safe routine. */ DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW. If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. -Else if FRAME-OR-WINDOW denotes any window, return the first window of -that window's frame. If FRAME-OR-WINDOW denotes a live frame, return +Else if FRAME-OR-WINDOW denotes a valid window, return the first window +of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return the first window of that frame. */) (Lisp_Object frame_or_window) { @@ -234,7 +370,7 @@ the first window of that frame. */) if (NILP (frame_or_window)) window = SELECTED_FRAME ()->root_window; - else if (WINDOWP (frame_or_window)) + else if (WINDOW_VALID_P (frame_or_window)) window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; else { @@ -259,16 +395,16 @@ DEFUN ("frame-selected-window", Fframe_selected_window, Sframe_selected_window, 0, 1, 0, doc: /* Return the selected window of FRAME-OR-WINDOW. If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. -Else if FRAME-OR-WINDOW denotes any window, return the selected window -of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return -the selected window of that frame. */) +Else if FRAME-OR-WINDOW denotes a valid window, return the selected +window of that window's frame. If FRAME-OR-WINDOW denotes a live frame, +return the selected window of that frame. */) (Lisp_Object frame_or_window) { Lisp_Object window; if (NILP (frame_or_window)) window = SELECTED_FRAME ()->selected_window; - else if (WINDOWP (frame_or_window)) + else if (WINDOW_VALID_P (frame_or_window)) window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window; else { @@ -301,7 +437,10 @@ Return WINDOW. */) if (EQ (frame, selected_frame)) return Fselect_window (window, norecord); else - return FSET (XFRAME (frame), selected_window, window); + { + fset_selected_window (XFRAME (frame), window); + return window; + } } DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, @@ -338,13 +477,16 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) record_buffer (w->buffer); } + /* Make the selected window's buffer current. */ + Fset_buffer (w->buffer); + if (EQ (window, selected_window) && !inhibit_point_swap) return window; sf = SELECTED_FRAME (); if (XFRAME (WINDOW_FRAME (w)) != sf) { - FSET (XFRAME (WINDOW_FRAME (w)), selected_window, window); + fset_selected_window (XFRAME (WINDOW_FRAME (w)), window); /* Use this rather than Fhandle_switch_frame so that FRAME_FOCUS_FRAME is moved appropriately as we move around in the state where a minibuffer in a separate @@ -355,11 +497,11 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) return window; } else - FSET (sf, selected_window, window); + fset_selected_window (sf, window); - /* Store the current buffer's actual point into the - old selected window. It belongs to that window, - and when the window is not selected, must be in the window. */ + /* Store the old selected window's buffer's point in pointm of the old + selected window. It belongs to that window, and when the window is + not selected, must be in the window. */ if (!inhibit_point_swap) { ow = XWINDOW (selected_window); @@ -370,10 +512,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) } selected_window = window; - - Fset_buffer (w->buffer); - - BSET (XBUFFER (w->buffer), last_selected_window, window); + bset_last_selected_window (XBUFFER (w->buffer), window); /* Go to the point recorded in the window. This is important when the buffer is in more @@ -421,88 +560,93 @@ Return nil for an internal window or a deleted window. */) DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, doc: /* Return the parent window of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a valid window and defaults to the selected one. Return nil for a window with no parent (e.g. a root window). */) (Lisp_Object window) { - return decode_any_window (window)->parent; + return decode_valid_window (window)->parent; } DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 1, 1, 0, doc: /* Return the topmost child window of window WINDOW. +WINDOW must be a valid window and defaults to the selected one. Return nil if WINDOW is a live window (live windows have no children). Return nil if WINDOW is an internal window whose children form a horizontal combination. */) (Lisp_Object window) { CHECK_WINDOW (window); - return decode_any_window (window)->vchild; + return decode_valid_window (window)->vchild; } DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 1, 1, 0, doc: /* Return the leftmost child window of window WINDOW. +WINDOW must be a valid window and defaults to the selected one. Return nil if WINDOW is a live window (live windows have no children). Return nil if WINDOW is an internal window whose children form a vertical combination. */) (Lisp_Object window) { CHECK_WINDOW (window); - return decode_any_window (window)->hchild; + return decode_valid_window (window)->hchild; } DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, doc: /* Return the next sibling window of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a valid window and defaults to the selected one. Return nil if WINDOW has no next sibling. */) (Lisp_Object window) { - return decode_any_window (window)->next; + return decode_valid_window (window)->next; } DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0, doc: /* Return the previous sibling window of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a valid window and defaults to the selected one. Return nil if WINDOW has no previous sibling. */) (Lisp_Object window) { - return decode_any_window (window)->prev; + return decode_valid_window (window)->prev; } DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0, doc: /* Return combination limit of window WINDOW. +WINDOW must be a valid window and defaults to the selected one. If the return value is nil, child windows of WINDOW can be recombined with WINDOW's siblings. A return value of t means that child windows of WINDOW are never \(re-)combined with WINDOW's siblings. */) (Lisp_Object window) { - return decode_any_window (window)->combination_limit; + return decode_valid_window (window)->combination_limit; } DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. +WINDOW must be a valid window and defaults to the selected one. If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's siblings. LIMIT t means that child windows of WINDOW are never \(re-)combined with WINDOW's siblings. Other values are reserved for future use. */) (Lisp_Object window, Lisp_Object limit) { - return WSET (decode_any_window (window), combination_limit, limit); + wset_combination_limit (decode_valid_window (window), limit); + return limit; } DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, doc: /* Return the use time of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. The window with the highest use time is the most recently selected one. The window with the lowest use time is the least recently selected one. */) (Lisp_Object window) { - return make_number (decode_window (window)->use_time); + return make_number (decode_live_window (window)->use_time); } DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0, doc: /* Return the total height, in lines, of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a valid window and defaults to the selected one. The return value includes the mode line and header line, if any. If WINDOW is an internal window, the total height is the height @@ -512,12 +656,12 @@ On a graphical display, this total height is reported as an integer multiple of the default character height. */) (Lisp_Object window) { - return decode_any_window (window)->total_lines; + return decode_valid_window (window)->total_lines; } DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0, doc: /* Return the total width, in columns, of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a valid window and defaults to the selected one. The return value includes any vertical dividers or scroll bars belonging to WINDOW. If WINDOW is an internal window, the total width @@ -527,34 +671,34 @@ On a graphical display, this total width is reported as an integer multiple of the default character width. */) (Lisp_Object window) { - return decode_any_window (window)->total_cols; + return decode_valid_window (window)->total_cols; } DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, doc: /* Return the new total size of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window) { - return decode_any_window (window)->new_total; + return decode_valid_window (window)->new_total; } DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, doc: /* Return the normal height of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a valid window and defaults to the selected one. If HORIZONTAL is non-nil, return the normal width of WINDOW. */) (Lisp_Object window, Lisp_Object horizontal) { - struct window *w = decode_any_window (window); + struct window *w = decode_valid_window (window); return NILP (horizontal) ? w->normal_lines : w->normal_cols; } DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, doc: /* Return new normal size of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window) { - return decode_any_window (window)->new_normal; + return decode_valid_window (window)->new_normal; } DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, @@ -563,10 +707,10 @@ This is the distance, in columns, between the left edge of WINDOW and the left edge of the frame's window area. For instance, the return value is 0 if there is no window to the left of WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window) { - return decode_any_window (window)->left_col; + return decode_valid_window (window)->left_col; } DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, @@ -575,10 +719,10 @@ This is the distance, in lines, between the top of WINDOW and the top of the frame's window area. For instance, the return value is 0 if there is no window above WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window) { - return decode_any_window (window)->top_line; + return decode_valid_window (window)->top_line; } /* Return the number of lines of W's body. Don't count any mode or @@ -632,8 +776,7 @@ window_body_cols (struct window *w) DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0, doc: /* Return the height, in lines, of WINDOW's text area. -If WINDOW is omitted or nil, it defaults to the selected window. -Signal an error if the window is not live. +WINDOW must be a live window and defaults to the selected one. The returned height does not include the mode line or header line. On a graphical display, the height is expressed as an integer multiple @@ -642,21 +785,20 @@ area is only partially visible, that counts as a whole line; to exclude partially-visible lines, use `window-text-height'. */) (Lisp_Object window) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); return make_number (window_body_lines (w)); } DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0, doc: /* Return the width, in columns, of WINDOW's text area. -If WINDOW is omitted or nil, it defaults to the selected window. -Signal an error if the window is not live. +WINDOW must be a live window and defaults to the selected one. The return value does not include any vertical dividers, fringe or marginal areas, or scroll bars. On a graphical display, the width is expressed as an integer multiple of the default character width. */) (Lisp_Object window) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); return make_number (window_body_cols (w)); } @@ -665,7 +807,7 @@ DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, WINDOW must be a live window and defaults to the selected one. */) (Lisp_Object window) { - return make_number (decode_window (window)->hscroll); + return make_number (decode_live_window (window)->hscroll); } /* Set W's horizontal scroll amount to HSCROLL clipped to a reasonable @@ -692,7 +834,7 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll) DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. -If WINDOW is nil, the selected window is used. +WINDOW must be a live window and defaults to the selected one. Clip the number to a reasonable value if out of range. Return the new number. NCOL should be zero or positive. @@ -700,7 +842,7 @@ Note that if `automatic-hscrolling' is non-nil, you cannot scroll the window so that the location of point moves off-window. */) (Lisp_Object window, Lisp_Object ncol) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); CHECK_NUMBER (ncol); return set_window_hscroll (w, XINT (ncol)); @@ -709,41 +851,44 @@ window so that the location of point moves off-window. */) DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger, Swindow_redisplay_end_trigger, 0, 1, 0, doc: /* Return WINDOW's redisplay end trigger value. -WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. See `set-window-redisplay-end-trigger' for more information. */) (Lisp_Object window) { - return decode_window (window)->redisplay_end_trigger; + return decode_live_window (window)->redisplay_end_trigger; } DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger, Sset_window_redisplay_end_trigger, 2, 2, 0, doc: /* Set WINDOW's redisplay end trigger value to VALUE. -VALUE should be a buffer position (typically a marker) or nil. -If it is a buffer position, then if redisplay in WINDOW reaches a position -beyond VALUE, the functions in `redisplay-end-trigger-functions' are called -with two arguments: WINDOW, and the end trigger value. -Afterwards the end-trigger value is reset to nil. */) +WINDOW must be a live window and defaults to the selected one. VALUE +should be a buffer position (typically a marker) or nil. If it is a +buffer position, then if redisplay in WINDOW reaches a position beyond +VALUE, the functions in `redisplay-end-trigger-functions' are called +with two arguments: WINDOW, and the end trigger value. Afterwards the +end-trigger value is reset to nil. */) (register Lisp_Object window, Lisp_Object value) { - return WSET (decode_window (window), redisplay_end_trigger, value); + wset_redisplay_end_trigger (decode_live_window (window), value); + return value; } DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0, doc: /* Return a list of the edge coordinates of WINDOW. -The list has the form (LEFT TOP RIGHT BOTTOM). -TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, -all relative to 0, 0 at top left corner of frame. - -RIGHT is one more than the rightmost column occupied by WINDOW. -BOTTOM is one more than the bottommost row occupied by WINDOW. -The edges include the space used by WINDOW's scroll bar, display -margins, fringes, header line, and/or mode line. For the edges of -just the text area, use `window-inside-edges'. */) +WINDOW must be a valid window and defaults to the selected one. + +The returned list has the form (LEFT TOP RIGHT BOTTOM). TOP and BOTTOM +count by lines, and LEFT and RIGHT count by columns, all relative to 0, +0 at top left corner of frame. + +RIGHT is one more than the rightmost column occupied by WINDOW. BOTTOM +is one more than the bottommost row occupied by WINDOW. The edges +include the space used by WINDOW's scroll bar, display margins, fringes, +header line, and/or mode line. For the edges of just the text area, use +`window-inside-edges'. */) (Lisp_Object window) { - register struct window *w = decode_any_window (window); - CHECK_LIVE_FRAME (w->frame); + register struct window *w = decode_valid_window (window); return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w)), Fcons (make_number (WINDOW_TOP_EDGE_LINE (w)), @@ -754,8 +899,10 @@ just the text area, use `window-inside-edges'. */) DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0, doc: /* Return a list of the edge pixel coordinates of WINDOW. -The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at -the top left corner of the frame. +WINDOW must be a valid window and defaults to the selected one. + +The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to +0, 0 at the top left corner of the frame. RIGHT is one more than the rightmost x position occupied by WINDOW. BOTTOM is one more than the bottommost y position occupied by WINDOW. @@ -764,8 +911,7 @@ margins, fringes, header line, and/or mode line. For the pixel edges of just the text area, use `window-inside-pixel-edges'. */) (Lisp_Object window) { - register struct window *w = decode_any_window (window); - CHECK_LIVE_FRAME (w->frame); + register struct window *w = decode_valid_window (window); return Fcons (make_number (WINDOW_LEFT_EDGE_X (w)), Fcons (make_number (WINDOW_TOP_EDGE_Y (w)), @@ -799,8 +945,10 @@ calc_absolute_offset (struct window *w, int *add_x, int *add_y) DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, Swindow_absolute_pixel_edges, 0, 1, 0, doc: /* Return a list of the edge pixel coordinates of WINDOW. -The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at -the top left corner of the display. +WINDOW must be a valid window and defaults to the selected one. + +The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to +0, 0 at the top left corner of the display. RIGHT is one more than the rightmost x position occupied by WINDOW. BOTTOM is one more than the bottommost y position occupied by WINDOW. @@ -809,10 +957,8 @@ margins, fringes, header line, and/or mode line. For the pixel edges of just the text area, use `window-inside-absolute-pixel-edges'. */) (Lisp_Object window) { - register struct window *w = decode_any_window (window); + register struct window *w = decode_valid_window (window); int add_x, add_y; - - CHECK_LIVE_FRAME (w->frame); calc_absolute_offset (w, &add_x, &add_y); return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x), @@ -824,17 +970,19 @@ of just the text area, use `window-inside-absolute-pixel-edges'. */) DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, doc: /* Return a list of the edge coordinates of WINDOW. -The list has the form (LEFT TOP RIGHT BOTTOM). -TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, -all relative to 0, 0 at top left corner of frame. +WINDOW must be a live window and defaults to the selected one. + +The returned list has the form (LEFT TOP RIGHT BOTTOM). TOP and BOTTOM +count by lines, and LEFT and RIGHT count by columns, all relative to 0, +0 at top left corner of frame. RIGHT is one more than the rightmost column of WINDOW's text area. -BOTTOM is one more than the bottommost row of WINDOW's text area. -The inside edges do not include the space used by the WINDOW's scroll -bar, display margins, fringes, header line, and/or mode line. */) +BOTTOM is one more than the bottommost row of WINDOW's text area. The +inside edges do not include the space used by the WINDOW's scroll bar, +display margins, fringes, header line, and/or mode line. */) (Lisp_Object window) { - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w) + WINDOW_LEFT_MARGIN_COLS (w) @@ -850,8 +998,10 @@ bar, display margins, fringes, header line, and/or mode line. */) DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. -The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) -at the top left corner of the frame's window area. +WINDOW must be a live window and defaults to the selected one. + +The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to +(0,0) at the top left corner of the frame's window area. RIGHT is one more than the rightmost x position of WINDOW's text area. BOTTOM is one more than the bottommost y position of WINDOW's text area. @@ -859,7 +1009,7 @@ The inside edges do not include the space used by WINDOW's scroll bar, display margins, fringes, header line, and/or mode line. */) (Lisp_Object window) { - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) + WINDOW_LEFT_MARGIN_WIDTH (w) @@ -877,8 +1027,10 @@ DEFUN ("window-inside-absolute-pixel-edges", Fwindow_inside_absolute_pixel_edges, Swindow_inside_absolute_pixel_edges, 0, 1, 0, doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. -The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) -at the top left corner of the frame's window area. +WINDOW must be a live window and defaults to the selected one. + +The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to +(0,0) at the top left corner of the frame's window area. RIGHT is one more than the rightmost x position of WINDOW's text area. BOTTOM is one more than the bottommost y position of WINDOW's text area. @@ -886,7 +1038,7 @@ The inside edges do not include the space used by WINDOW's scroll bar, display margins, fringes, header line, and/or mode line. */) (Lisp_Object window) { - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); int add_x, add_y; calc_absolute_offset (w, &add_x, &add_y); @@ -1065,7 +1217,7 @@ window_relative_x_coord (struct window *w, enum window_part part, int x) DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, Scoordinates_in_window_p, 2, 2, 0, doc: /* Return non-nil if COORDINATES are in WINDOW. -WINDOW must be a live window. +WINDOW must be a live window and defaults to the selected one. COORDINATES is a cons of the form (X . Y), X and Y being distances measured in characters from the upper-left corner of the frame. \(0 . 0) denotes the character in the upper left corner of the @@ -1087,8 +1239,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\ int x, y; Lisp_Object lx, ly; - CHECK_LIVE_WINDOW (window); - w = XWINDOW (window); + w = decode_live_window (window); f = XFRAME (w->frame); CHECK_CONS (coordinates); lx = Fcar (coordinates); @@ -1266,7 +1417,7 @@ of point, outside of any save-excursion forms. But that is hard to define. */) (Lisp_Object window) { - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); if (w == XWINDOW (selected_window) && current_buffer == XBUFFER (w->buffer)) @@ -1280,7 +1431,7 @@ WINDOW must be a live window and defaults to the selected one. This is updated by redisplay or by calling `set-window-start'. */) (Lisp_Object window) { - return Fmarker_position (decode_window (window)->start); + return Fmarker_position (decode_live_window (window)->start); } /* This is text temporarily removed from the doc string below. @@ -1307,7 +1458,7 @@ if it isn't already recorded. */) (Lisp_Object window, Lisp_Object update) { Lisp_Object value; - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); Lisp_Object buf; struct buffer *b; @@ -1374,10 +1525,11 @@ if it isn't already recorded. */) DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, doc: /* Make point value in WINDOW be at position POS in WINDOW's buffer. +WINDOW must be a live window and defaults to the selected one. Return POS. */) (Lisp_Object window, Lisp_Object pos) { - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); CHECK_NUMBER_COERCE_MARKER (pos); if (w == XWINDOW (selected_window) @@ -1396,12 +1548,12 @@ Return POS. */) DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. -If WINDOW is nil, the selected window is used. Return POS. -Optional third arg NOFORCE non-nil inhibits next redisplay from +WINDOW must be a live window and defaults to the selected one. Return +POS. Optional third arg NOFORCE non-nil inhibits next redisplay from overriding motion of point in order to display at this exact start. */) (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) { - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); CHECK_NUMBER_COERCE_MARKER (pos); set_marker_restricted (w->start, pos, w->buffer); @@ -1421,12 +1573,14 @@ overriding motion of point in order to display at this exact start. */) DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, Spos_visible_in_window_p, 0, 3, 0, doc: /* Return non-nil if position POS is currently on the frame in WINDOW. -Return nil if that position is scrolled vertically out of view. -If a character is only partially visible, nil is returned, unless the -optional argument PARTIALLY is non-nil. -If POS is only out of view because of horizontal scrolling, return non-nil. -If POS is t, it specifies the position of the last visible glyph in WINDOW. -POS defaults to point in WINDOW; WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. + +Return nil if that position is scrolled vertically out of view. If a +character is only partially visible, nil is returned, unless the +optional argument PARTIALLY is non-nil. If POS is only out of view +because of horizontal scrolling, return non-nil. If POS is t, it +specifies the position of the last visible glyph in WINDOW. POS +defaults to point in WINDOW; WINDOW defaults to the selected window. If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), @@ -1445,7 +1599,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) int rtop, rbot, rowh, vpos, fully_p = 1; int x, y; - w = decode_window (window); + w = decode_live_window (window); buf = XBUFFER (w->buffer); SET_TEXT_POS_FROM_MARKER (top, w->start); @@ -1487,7 +1641,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) DEFUN ("window-line-height", Fwindow_line_height, Swindow_line_height, 0, 2, 0, doc: /* Return height in pixels of text line LINE in window WINDOW. -WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. Return height of current line if LINE is omitted or nil. Return height of header or mode line if LINE is `header-line' or `mode-line'. @@ -1511,7 +1665,7 @@ Return nil if window display is not up-to-date. In that case, use int max_y, crop, i; EMACS_INT n; - w = decode_window (window); + w = decode_live_window (window); if (noninteractive || w->pseudo_window_p) return Qnil; @@ -1599,8 +1753,8 @@ DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, More precisely, return the value assigned by the last call of `set-window-dedicated-p' for WINDOW. Return nil if that function was never called with WINDOW as its argument, or the value set by that -function was internally reset since its last call. WINDOW defaults to -the selected window. +function was internally reset since its last call. WINDOW must be a +live window and defaults to the selected one. When a window is dedicated to its buffer, `display-buffer' will refrain from displaying another buffer in it. `get-lru-window' and @@ -1613,7 +1767,7 @@ window, unless that window is "strongly" dedicated to its buffer, that is the value returned by `window-dedicated-p' is t. */) (Lisp_Object window) { - return decode_window (window)->dedicated; + return decode_live_window (window)->dedicated; } DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, @@ -1637,7 +1791,8 @@ buffer. If and when `set-window-buffer' displays another buffer in a window, it also makes sure that the window is no more dedicated. */) (Lisp_Object window, Lisp_Object flag) { - return WSET (decode_window (window), dedicated, flag); + wset_dedicated (decode_live_window (window), flag); + return flag; } DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers, @@ -1650,7 +1805,7 @@ where BUFFER is a buffer, WINDOW-START is the start position of the window for that buffer, and POS is a window-specific point value. */) (Lisp_Object window) { - return decode_window (window)->prev_buffers; + return decode_live_window (window)->prev_buffers; } DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, @@ -1663,7 +1818,8 @@ where BUFFER is a buffer, WINDOW-START is the start position of the window for that buffer, and POS is a window-specific point value. */) (Lisp_Object window, Lisp_Object prev_buffers) { - return WSET (decode_window (window), prev_buffers, prev_buffers); + wset_prev_buffers (decode_live_window (window), prev_buffers); + return prev_buffers; } DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, @@ -1672,7 +1828,7 @@ DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, WINDOW must be a live window and defaults to the selected one. */) (Lisp_Object window) { - return decode_window (window)->next_buffers; + return decode_live_window (window)->next_buffers; } DEFUN ("set-window-next-buffers", Fset_window_next_buffers, @@ -1682,44 +1838,46 @@ WINDOW must be a live window and defaults to the selected one. NEXT-BUFFERS should be a list of buffers. */) (Lisp_Object window, Lisp_Object next_buffers) { - return WSET (decode_window (window), next_buffers, next_buffers); + wset_next_buffers (decode_live_window (window), next_buffers); + return next_buffers; } DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, 0, 1, 0, doc: /* Return the parameters of WINDOW and their values. -WINDOW defaults to the selected window. The return value is a list of -elements of the form (PARAMETER . VALUE). */) +WINDOW must be a valid window and defaults to the selected one. The +return value is a list of elements of the form (PARAMETER . VALUE). */) (Lisp_Object window) { - return Fcopy_alist (decode_any_window (window)->window_parameters); + return Fcopy_alist (decode_valid_window (window)->window_parameters); } DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, 2, 2, 0, doc: /* Return WINDOW's value for PARAMETER. -WINDOW defaults to the selected window. */) +WINDOW must be a valid window and defaults to the selected one. */) (Lisp_Object window, Lisp_Object parameter) { Lisp_Object result; - result = Fassq (parameter, decode_any_window (window)->window_parameters); + result = Fassq (parameter, decode_valid_window (window)->window_parameters); return CDR_SAFE (result); } DEFUN ("set-window-parameter", Fset_window_parameter, Sset_window_parameter, 3, 3, 0, doc: /* Set WINDOW's value of PARAMETER to VALUE. -WINDOW defaults to the selected window. Return VALUE. */) +WINDOW must be a valid window and defaults to the selected one. +Return VALUE. */) (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) { - register struct window *w = decode_any_window (window); + register struct window *w = decode_valid_window (window); Lisp_Object old_alist_elt; old_alist_elt = Fassq (parameter, w->window_parameters); if (NILP (old_alist_elt)) - WSET (w, window_parameters, - Fcons (Fcons (parameter, value), w->window_parameters)); + wset_window_parameters + (w, Fcons (Fcons (parameter, value), w->window_parameters)); else Fsetcdr (old_alist_elt, value); return value; @@ -1728,10 +1886,10 @@ WINDOW defaults to the selected window. Return VALUE. */) DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, 0, 1, 0, doc: /* Return the display-table that WINDOW is using. -WINDOW defaults to the selected window. */) +WINDOW must be a live window and defaults to the selected one. */) (Lisp_Object window) { - return decode_window (window)->display_table; + return decode_live_window (window)->display_table; } /* Get the display table for use on window W. This is either W's @@ -1760,10 +1918,12 @@ window_display_table (struct window *w) } DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, - doc: /* Set WINDOW's display-table to TABLE. */) + doc: /* Set WINDOW's display-table to TABLE. +WINDOW must be a live window and defaults to the selected one. */) (register Lisp_Object window, Lisp_Object table) { - return WSET (decode_window (window), display_table, table); + wset_display_table (decode_live_window (window), table); + return table; } /* Record info on buffer window W is displaying @@ -1812,7 +1972,7 @@ unshow_buffer (register struct window *w) if (WINDOWP (BVAR (b, last_selected_window)) && w == XWINDOW (BVAR (b, last_selected_window))) - BSET (b, last_selected_window, Qnil); + bset_last_selected_window (b, Qnil); } /* Put NEW into the window structure in place of OLD. SETFLAG zero @@ -1827,18 +1987,18 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) /* If OLD is its frame's root window, then NEW is the new root window for that frame. */ if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) - FSET (XFRAME (o->frame), root_window, new); + fset_root_window (XFRAME (o->frame), new); if (setflag) { - WSET (n, left_col, o->left_col); - WSET (n, top_line, o->top_line); - WSET (n, total_cols, o->total_cols); - WSET (n, total_lines, o->total_lines); - WSET (n, normal_cols, o->normal_cols); - WSET (o, normal_cols, make_float (1.0)); - WSET (n, normal_lines, o->normal_lines); - WSET (o, normal_lines, make_float (1.0)); + wset_left_col (n, o->left_col); + wset_top_line (n, o->top_line); + wset_total_cols (n, o->total_cols); + wset_total_lines (n, o->total_lines); + wset_normal_cols (n, o->normal_cols); + wset_normal_cols (o, make_float (1.0)); + wset_normal_lines (n, o->normal_lines); + wset_normal_lines (o, make_float (1.0)); n->desired_matrix = n->current_matrix = 0; n->vscroll = 0; memset (&n->cursor, 0, sizeof (n->cursor)); @@ -1848,30 +2008,30 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) n->phys_cursor_width = -1; n->must_be_updated_p = 0; n->pseudo_window_p = 0; - WSET (n, window_end_vpos, make_number (0)); - WSET (n, window_end_pos, make_number (0)); - WSET (n, window_end_valid, Qnil); + wset_window_end_vpos (n, make_number (0)); + wset_window_end_pos (n, make_number (0)); + wset_window_end_valid (n, Qnil); n->frozen_window_start_p = 0; } tem = o->next; - WSET (n, next, tem); + wset_next (n, tem); if (!NILP (tem)) - WSET (XWINDOW (tem), prev, new); + wset_prev (XWINDOW (tem), new); tem = o->prev; - WSET (n, prev, tem); + wset_prev (n, tem); if (!NILP (tem)) - WSET (XWINDOW (tem), next, new); + wset_next (XWINDOW (tem), new); tem = o->parent; - WSET (n, parent, tem); + wset_parent (n, tem); if (!NILP (tem)) { if (EQ (XWINDOW (tem)->vchild, old)) - WSET (XWINDOW (tem), vchild, new); + wset_vchild (XWINDOW (tem), new); if (EQ (XWINDOW (tem)->hchild, old)) - WSET (XWINDOW (tem), hchild, new); + wset_hchild (XWINDOW (tem), new); } } @@ -1904,34 +2064,34 @@ recombine_windows (Lisp_Object window) assign new normal sizes. */ if (NILP (w->prev)) if (horflag) - WSET (p, hchild, child); + wset_hchild (p, child); else - WSET (p, vchild, child); + wset_vchild (p, child); else { - WSET (c, prev, w->prev); - WSET (XWINDOW (w->prev), next, child); + wset_prev (c, w->prev); + wset_next (XWINDOW (w->prev), child); } while (c) { - WSET (c, parent, parent); + wset_parent (c, parent); if (horflag) - WSET (c, normal_cols, - make_float (XFLOATINT (c->total_cols) - / XFLOATINT (p->total_cols))); + wset_normal_cols (c, + make_float (XFLOATINT (c->total_cols) + / XFLOATINT (p->total_cols))); else - WSET (c, normal_lines, - make_float (XFLOATINT (c->total_lines) - / XFLOATINT (p->total_lines))); + wset_normal_lines (c, + make_float (XFLOATINT (c->total_lines) + / XFLOATINT (p->total_lines))); if (NILP (c->next)) { if (!NILP (w->next)) { - WSET (c, next, w->next); - WSET (XWINDOW (c->next), prev, child); + wset_next (c, w->next); + wset_prev (XWINDOW (c->next), child); } c = 0; @@ -1944,8 +2104,8 @@ recombine_windows (Lisp_Object window) } /* WINDOW can be deleted now. */ - WSET (w, vchild, Qnil); - WSET (w, hchild, Qnil); + wset_vchild (w, Qnil); + wset_hchild (w, Qnil); } } } @@ -2110,7 +2270,7 @@ decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object /* ALL_FRAMES nil doesn't specify which frames to include. */ if (NILP (*all_frames)) - *all_frames + *all_frames = (!EQ (*minibuf, Qlambda) ? FRAME_MINIBUF_WINDOW (XFRAME (XWINDOW (*window)->frame)) : Qnil); @@ -2466,7 +2626,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame if (EQ (w->buffer, obj)) { /* Undedicate WINDOW. */ - WSET (w, dedicated, Qnil); + wset_dedicated (w, Qnil); /* Make WINDOW show the buffer returned by other_buffer_safely, don't run any hooks. */ set_window_buffer @@ -2559,8 +2719,8 @@ resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizonta DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal, Sdelete_other_windows_internal, 0, 2, "", doc: /* Make WINDOW fill its frame. -Only the frame WINDOW is on is affected. WINDOW may be any window and -defaults to the selected one. +Only the frame WINDOW is on is affected. WINDOW must be a valid window +and defaults to the selected one. Optional argument ROOT, if non-nil, must specify an internal window such that WINDOW is in its window subtree. If this is the case, replace ROOT @@ -2579,8 +2739,7 @@ window-start value is reasonable when this function is called. */) ptrdiff_t startpos IF_LINT (= 0); int top IF_LINT (= 0), new_top, resize_failed; - w = decode_any_window (window); - CHECK_LIVE_FRAME (w->frame); + w = decode_valid_window (window); XSETWINDOW (window, w); f = XFRAME (w->frame); @@ -2593,8 +2752,7 @@ window-start value is reasonable when this function is called. */) else /* ROOT must be an ancestor of WINDOW. */ { - r = decode_any_window (root); - CHECK_LIVE_FRAME (r->frame); + r = decode_valid_window (root); pwindow = XWINDOW (window)->parent; while (!NILP (pwindow)) if (EQ (pwindow, root)) @@ -2625,7 +2783,7 @@ window-start value is reasonable when this function is called. */) if (EQ (selected_frame, w->frame)) Fselect_window (window, Qnil); else - FSET (f, selected_window, window); + fset_selected_window (f, window); } } else @@ -2655,7 +2813,7 @@ window-start value is reasonable when this function is called. */) if (EQ (selected_frame, w->frame)) Fselect_window (swindow, Qnil); else - FSET (f, selected_window, swindow); + fset_selected_window (f, swindow); } } @@ -2690,7 +2848,7 @@ window-start value is reasonable when this function is called. */) /* Resize child windows vertically. */ XSETINT (delta, XINT (r->total_lines) - XINT (w->total_lines)); - WSET (w, top_line, r->top_line); + wset_top_line (w, r->top_line); resize_root_window (window, delta, Qnil, Qnil); if (window_resize_check (w, 0)) window_resize_apply (w, 0); @@ -2706,10 +2864,10 @@ window-start value is reasonable when this function is called. */) /* Resize child windows horizontally. */ if (!resize_failed) { - WSET (w, left_col, r->left_col); - XSETINT (delta, XINT (r->total_cols) - - XINT (w->total_cols)); - WSET (w, left_col, r->left_col); + wset_left_col (w, r->left_col); + XSETINT (delta, + XINT (r->total_cols) - XINT (w->total_cols)); + wset_left_col (w, r->left_col); resize_root_window (window, delta, Qt, Qnil); if (window_resize_check (w, 1)) window_resize_apply (w, 1); @@ -2737,32 +2895,32 @@ window-start value is reasonable when this function is called. */) { sibling = w->prev; s = XWINDOW (sibling); - WSET (s, next, w->next); + wset_next (s, w->next); if (!NILP (s->next)) - WSET (XWINDOW (s->next), prev, sibling); + wset_prev (XWINDOW (s->next), sibling); } else /* Get SIBLING below (on the right of) WINDOW. */ { sibling = w->next; s = XWINDOW (sibling); - WSET (s, prev, Qnil); + wset_prev (s, Qnil); if (!NILP (XWINDOW (w->parent)->vchild)) - WSET (XWINDOW (w->parent), vchild, sibling); + wset_vchild (XWINDOW (w->parent), sibling); else - WSET (XWINDOW (w->parent), hchild, sibling); + wset_hchild (XWINDOW (w->parent), sibling); } /* Delete ROOT and all child windows of ROOT. */ if (!NILP (r->vchild)) { delete_all_child_windows (r->vchild); - WSET (r, vchild, Qnil); + wset_vchild (r, Qnil); } else if (!NILP (r->hchild)) { delete_all_child_windows (r->hchild); - WSET (r, hchild, Qnil); + wset_hchild (r, Qnil); } replace_window (root, window, 1); @@ -2789,7 +2947,7 @@ window-start value is reasonable when this function is called. */) pos = *vmotion (startpos, -top, w); set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); w->start_at_line_beg = (pos.bytepos == BEGV_BYTE || FETCH_BYTE (pos.bytepos - 1) == '\n'); /* We need to do this, so that the window-scroll-functions @@ -2880,14 +3038,14 @@ adjust_window_margins (struct window *w) { if (WINDOW_LEFT_MARGIN_COLS (w) > 0) { - WSET (w, left_margin_cols, make_number (margin_cols / 2)); - WSET (w, right_margin_cols, make_number (margin_cols / 2)); + wset_left_margin_cols (w, make_number (margin_cols / 2)); + wset_right_margin_cols (w, make_number (margin_cols / 2)); } else - WSET (w, right_margin_cols, make_number (margin_cols)); + wset_right_margin_cols (w, make_number (margin_cols)); } else - WSET (w, left_margin_cols, make_number (margin_cols)); + wset_left_margin_cols (w, make_number (margin_cols)); return 1; } @@ -2987,23 +3145,23 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int ptrdiff_t count = SPECPDL_INDEX (); int samebuf = EQ (buffer, w->buffer); - WSET (w, buffer, buffer); + wset_buffer (w, buffer); if (EQ (window, selected_window)) - BSET (b, last_selected_window, window); + bset_last_selected_window (b, window); /* Let redisplay errors through. */ b->display_error_modiff = 0; /* Update time stamps of buffer display. */ if (INTEGERP (BVAR (b, display_count))) - BSET (b, display_count, make_number (XINT (BVAR (b, display_count)) + 1)); - BSET (b, display_time, Fcurrent_time ()); + bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1)); + bset_display_time (b, Fcurrent_time ()); - WSET (w, window_end_pos, make_number (0)); - WSET (w, window_end_vpos, make_number (0)); + wset_window_end_pos (w, make_number (0)); + wset_window_end_vpos (w, make_number (0)); memset (&w->last_cursor, 0, sizeof w->last_cursor); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); if (!(keep_margins_p && samebuf)) { /* If we're not actually changing the buffer, don't reset hscroll and vscroll. This case happens for example when called from @@ -3048,8 +3206,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int Lisp_Object save_left = w->left_margin_cols; Lisp_Object save_right = w->right_margin_cols; - WSET (w, left_margin_cols, Qnil); - WSET (w, right_margin_cols, Qnil); + wset_left_margin_cols (w, Qnil); + wset_right_margin_cols (w, Qnil); Fset_window_fringes (window, BVAR (b, left_fringe_width), BVAR (b, right_fringe_width), @@ -3059,8 +3217,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int BVAR (b, scroll_bar_width), BVAR (b, vertical_scroll_bar_type), Qnil); - WSET (w, left_margin_cols, save_left); - WSET (w, right_margin_cols, save_right); + wset_left_margin_cols (w, save_left); + wset_right_margin_cols (w, save_right); Fset_window_margins (window, BVAR (b, left_margin_cols), BVAR (b, right_margin_cols)); @@ -3079,7 +3237,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. -WINDOW has to be a live window and defaults to the selected one. +WINDOW must be a live window and defaults to the selected one. BUFFER-OR-NAME must be a buffer or the name of an existing buffer. Optional third argument KEEP-MARGINS non-nil means that WINDOW's current @@ -3096,7 +3254,7 @@ This function runs `window-scroll-functions' before running (register Lisp_Object window, Lisp_Object buffer_or_name, Lisp_Object keep_margins) { register Lisp_Object tem, buffer; - register struct window *w = decode_window (window); + register struct window *w = decode_live_window (window); XSETWINDOW (window, w); buffer = Fget_buffer (buffer_or_name); @@ -3119,7 +3277,7 @@ This function runs `window-scroll-functions' before running else /* WINDOW is weakly dedicated to its buffer, reset dedication. */ - WSET (w, dedicated, Qnil); + wset_dedicated (w, Qnil); call1 (Qrecord_window_buffer, window); } @@ -3189,7 +3347,7 @@ temp_output_buffer_show (register Lisp_Object buf) register Lisp_Object window; register struct window *w; - BSET (XBUFFER (buf), directory, BVAR (current_buffer, directory)); + bset_directory (XBUFFER (buf), BVAR (current_buffer, directory)); Fset_buffer (buf); BUF_SAVE_MODIFF (XBUFFER (buf)) = MODIFF; @@ -3265,17 +3423,17 @@ make_parent_window (Lisp_Object window, int horflag) replace_window (window, parent, 1); - WSET (o, next, Qnil); - WSET (o, prev, Qnil); - WSET (o, parent, parent); + wset_next (o, Qnil); + wset_prev (o, Qnil); + wset_parent (o, parent); - WSET (p, hchild, horflag ? window : Qnil); - WSET (p, vchild, horflag ? Qnil : window); - WSET (p, start, Qnil); - WSET (p, pointm, Qnil); - WSET (p, buffer, Qnil); - WSET (p, combination_limit, Qnil); - WSET (p, window_parameters, Qnil); + wset_hchild (p, horflag ? window : Qnil); + wset_vchild (p, horflag ? Qnil : window); + wset_start (p, Qnil); + wset_pointm (p, Qnil); + wset_buffer (p, Qnil); + wset_combination_limit (p, Qnil); + wset_window_parameters (p, Qnil); } /* Make new window from scratch. */ @@ -3288,19 +3446,19 @@ make_window (void) w = allocate_window (); /* Initialize Lisp data. Note that allocate_window initializes all Lisp data to nil, so do it only for slots which should not be nil. */ - WSET (w, left_col, make_number (0)); - WSET (w, top_line, make_number (0)); - WSET (w, total_lines, make_number (0)); - WSET (w, total_cols, make_number (0)); - WSET (w, normal_lines, make_float (1.0)); - WSET (w, normal_cols, make_float (1.0)); - WSET (w, new_total, make_number (0)); - WSET (w, new_normal, make_number (0)); - WSET (w, start, Fmake_marker ()); - WSET (w, pointm, Fmake_marker ()); - WSET (w, vertical_scroll_bar_type, Qt); - WSET (w, window_end_pos, make_number (0)); - WSET (w, window_end_vpos, make_number (0)); + wset_left_col (w, make_number (0)); + wset_top_line (w, make_number (0)); + wset_total_lines (w, make_number (0)); + wset_total_cols (w, make_number (0)); + wset_normal_lines (w, make_float (1.0)); + wset_normal_cols (w, make_float (1.0)); + wset_new_total (w, make_number (0)); + wset_new_normal (w, make_number (0)); + wset_start (w, Fmake_marker ()); + wset_pointm (w, Fmake_marker ()); + wset_vertical_scroll_bar_type (w, Qt); + wset_window_end_pos (w, make_number (0)); + wset_window_end_vpos (w, make_number (0)); /* Initialize non-Lisp data. Note that allocate_window zeroes out all non-Lisp data, so do it only for slots which should not be zero. */ @@ -3318,6 +3476,7 @@ make_window (void) DEFUN ("set-window-new-total", Fset_window_new_total, Sset_window_new_total, 2, 3, 0, doc: /* Set new total size of WINDOW to SIZE. +WINDOW must be a valid window and defaults to the selected one. Return SIZE. Optional argument ADD non-nil means add SIZE to the new total size of @@ -3326,25 +3485,27 @@ WINDOW and return the sum. Note: This function does not operate on any child windows of WINDOW. */) (Lisp_Object window, Lisp_Object size, Lisp_Object add) { - struct window *w = decode_any_window (window); + struct window *w = decode_valid_window (window); CHECK_NUMBER (size); if (NILP (add)) - WSET (w, new_total, size); + wset_new_total (w, size); else - WSET (w, new_total, make_number (XINT (w->new_total) + XINT (size))); + wset_new_total (w, make_number (XINT (w->new_total) + XINT (size))); return w->new_total; } DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal, 1, 2, 0, doc: /* Set new normal size of WINDOW to SIZE. +WINDOW must be a valid window and defaults to the selected one. Return SIZE. Note: This function does not operate on any child windows of WINDOW. */) (Lisp_Object window, Lisp_Object size) { - return WSET (decode_any_window (window), new_normal, size); + wset_new_normal (decode_valid_window (window), size); + return size; } /* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is @@ -3445,17 +3606,17 @@ window_resize_apply (struct window *w, int horflag) parent window has been set *before*. */ if (horflag) { - WSET (w, total_cols, w->new_total); + wset_total_cols (w, w->new_total); if (NUMBERP (w->new_normal)) - WSET (w, normal_cols, w->new_normal); + wset_normal_cols (w, w->new_normal); pos = XINT (w->left_col); } else { - WSET (w, total_lines, w->new_total); + wset_total_lines (w, w->new_total); if (NUMBERP (w->new_normal)) - WSET (w, normal_lines, w->new_normal); + wset_normal_lines (w, w->new_normal); pos = XINT (w->top_line); } @@ -3467,9 +3628,9 @@ window_resize_apply (struct window *w, int horflag) while (c) { if (horflag) - WSET (c, left_col, make_number (pos)); + wset_left_col (c, make_number (pos)); else - WSET (c, top_line, make_number (pos)); + wset_top_line (c, make_number (pos)); window_resize_apply (c, horflag); if (!horflag) pos = pos + XINT (c->total_lines); @@ -3483,9 +3644,9 @@ window_resize_apply (struct window *w, int horflag) while (c) { if (horflag) - WSET (c, left_col, make_number (pos)); + wset_left_col (c, make_number (pos)); else - WSET (c, top_line, make_number (pos)); + wset_top_line (c, make_number (pos)); window_resize_apply (c, horflag); if (horflag) pos = pos + XINT (c->total_cols); @@ -3566,17 +3727,17 @@ resize_frame_windows (struct frame *f, int size, int horflag) - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) ? 1 : 0))); - WSET (r, top_line, make_number (FRAME_TOP_MARGIN (f))); + wset_top_line (r, make_number (FRAME_TOP_MARGIN (f))); if (NILP (r->vchild) && NILP (r->hchild)) /* For a leaf root window just set the size. */ if (horflag) - WSET (r, total_cols, make_number (new_size)); + wset_total_cols (r, make_number (new_size)); else - WSET (r, total_lines, make_number (new_size)); + wset_total_lines (r, make_number (new_size)); else { /* old_size is the old size of the frame's root window. */ - int old_size = XFASTINT (horflag ? r->total_cols + int old_size = XFASTINT (horflag ? r->total_cols : r->total_lines); Lisp_Object delta; @@ -3607,9 +3768,9 @@ resize_frame_windows (struct frame *f, int size, int horflag) root = f->selected_window; Fdelete_other_windows_internal (root, Qnil); if (horflag) - WSET (XWINDOW (root), total_cols, make_number (new_size)); + wset_total_cols (XWINDOW (root), make_number (new_size)); else - WSET (XWINDOW (root), total_lines, make_number (new_size)); + wset_total_lines (XWINDOW (root), make_number (new_size)); } } } @@ -3619,13 +3780,13 @@ resize_frame_windows (struct frame *f, int size, int horflag) { m = XWINDOW (mini); if (horflag) - WSET (m, total_cols, make_number (size)); + wset_total_cols (m, make_number (size)); else { /* Are we sure we always want 1 line here? */ - WSET (m, total_lines, make_number (1)); - WSET (m, top_line, - make_number (XINT (r->top_line) + XINT (r->total_lines))); + wset_total_lines (m, make_number (1)); + wset_top_line + (m, make_number (XINT (r->top_line) + XINT (r->total_lines))); } } } @@ -3706,15 +3867,14 @@ set correctly. See the code of `split-window' for how this is done. */) { p = XWINDOW (o->parent); /* Temporarily pretend we split the parent window. */ - WSET (p, new_total, - make_number (XINT (horflag ? p->total_cols : p->total_lines) + wset_new_total + (p, make_number (XINT (horflag ? p->total_cols : p->total_lines) - XINT (total_size))); if (!window_resize_check (p, horflag)) error ("Window sizes don't fit"); else /* Undo the temporary pretension. */ - WSET (p, new_total, - horflag ? p->total_cols : p->total_lines); + wset_new_total (p, horflag ? p->total_cols : p->total_lines); } else { @@ -3738,10 +3898,10 @@ set correctly. See the code of `split-window' for how this is done. */) p = XWINDOW (o->parent); /* Store value of `window-combination-limit' in new parent's combination_limit slot. */ - WSET (p, combination_limit, Vwindow_combination_limit); + wset_combination_limit (p, Vwindow_combination_limit); /* These get applied below. */ - WSET (p, new_total, horflag ? o->total_cols : o->total_lines); - WSET (p, new_normal, new_normal); + wset_new_total (p, horflag ? o->total_cols : o->total_lines); + wset_new_normal (p, new_normal); } else p = XWINDOW (o->parent); @@ -3750,62 +3910,62 @@ set correctly. See the code of `split-window' for how this is done. */) FRAME_WINDOW_SIZES_CHANGED (f) = 1; new = make_window (); n = XWINDOW (new); - WSET (n, frame, frame); - WSET (n, parent, o->parent); - WSET (n, vchild, Qnil); - WSET (n, hchild, Qnil); + wset_frame (n, frame); + wset_parent (n, o->parent); + wset_vchild (n, Qnil); + wset_hchild (n, Qnil); if (EQ (side, Qabove) || EQ (side, Qleft)) { - WSET (n, prev, o->prev); + wset_prev (n, o->prev); if (NILP (n->prev)) if (horflag) - WSET (p, hchild, new); + wset_hchild (p, new); else - WSET (p, vchild, new); + wset_vchild (p, new); else - WSET (XWINDOW (n->prev), next, new); - WSET (n, next, old); - WSET (o, prev, new); + wset_next (XWINDOW (n->prev), new); + wset_next (n, old); + wset_prev (o, new); } else { - WSET (n, next, o->next); + wset_next (n, o->next); if (!NILP (n->next)) - WSET (XWINDOW (n->next), prev, new); - WSET (n, prev, old); - WSET (o, next, new); + wset_prev (XWINDOW (n->next), new); + wset_prev (n, old); + wset_next (o, new); } - WSET (n, buffer, Qt); - WSET (n, window_end_valid, Qnil); + wset_buffer (n, Qt); + wset_window_end_valid (n, Qnil); memset (&n->last_cursor, 0, sizeof n->last_cursor); /* Get special geometry settings from reference window. */ - WSET (n, left_margin_cols, r->left_margin_cols); - WSET (n, right_margin_cols, r->right_margin_cols); - WSET (n, left_fringe_width, r->left_fringe_width); - WSET (n, right_fringe_width, r->right_fringe_width); + wset_left_margin_cols (n, r->left_margin_cols); + wset_right_margin_cols (n, r->right_margin_cols); + wset_left_fringe_width (n, r->left_fringe_width); + wset_right_fringe_width (n, r->right_fringe_width); n->fringes_outside_margins = r->fringes_outside_margins; - WSET (n, scroll_bar_width, r->scroll_bar_width); - WSET (n, vertical_scroll_bar_type, r->vertical_scroll_bar_type); + wset_scroll_bar_width (n, r->scroll_bar_width); + wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type); /* Directly assign orthogonal coordinates and sizes. */ if (horflag) { - WSET (n, top_line, o->top_line); - WSET (n, total_lines, o->total_lines); + wset_top_line (n, o->top_line); + wset_total_lines (n, o->total_lines); } else { - WSET (n, left_col, o->left_col); - WSET (n, total_cols, o->total_cols); + wset_left_col (n, o->left_col); + wset_total_cols (n, o->total_cols); } /* Iso-coordinates and sizes are assigned by window_resize_apply, get them ready here. */ - WSET (n, new_total, total_size); - WSET (n, new_normal, normal_size); + wset_new_total (n, total_size); + wset_new_normal (n, normal_size); BLOCK_INPUT; window_resize_apply (p, horflag); @@ -3838,8 +3998,6 @@ Signal an error when WINDOW is the only window on its frame. */) int before_sibling = 0; w = decode_any_window (window); - CHECK_LIVE_FRAME (w->frame); - XSETWINDOW (window, w); if (NILP (w->buffer) && NILP (w->hchild) && NILP (w->vchild)) @@ -3873,20 +4031,20 @@ Signal an error when WINDOW is the only window on its frame. */) before_sibling = 1; sibling = w->next; s = XWINDOW (sibling); - WSET (s, prev, Qnil); + wset_prev (s, Qnil); if (horflag) - WSET (p, hchild, sibling); + wset_hchild (p, sibling); else - WSET (p, vchild, sibling); + wset_vchild (p, sibling); } else /* Get SIBLING above (on the left of) WINDOW. */ { sibling = w->prev; s = XWINDOW (sibling); - WSET (s, next, w->next); + wset_next (s, w->next); if (!NILP (s->next)) - WSET (XWINDOW (s->next), prev, sibling); + wset_prev (XWINDOW (s->next), sibling); } if (window_resize_check (r, horflag) @@ -3913,25 +4071,25 @@ Signal an error when WINDOW is the only window on its frame. */) Vwindow_list = Qnil; FRAME_WINDOW_SIZES_CHANGED (f) = 1; - WSET (w, next, Qnil); /* Don't delete w->next too. */ + wset_next (w, Qnil); /* Don't delete w->next too. */ free_window_matrices (w); if (!NILP (w->vchild)) { delete_all_child_windows (w->vchild); - WSET (w, vchild, Qnil); + wset_vchild (w, Qnil); } else if (!NILP (w->hchild)) { delete_all_child_windows (w->hchild); - WSET (w, hchild, Qnil); + wset_hchild (w, Qnil); } else if (!NILP (w->buffer)) { unshow_buffer (w); unchain_marker (XMARKER (w->pointm)); unchain_marker (XMARKER (w->start)); - WSET (w, buffer, Qnil); + wset_buffer (w, Qnil); } if (NILP (s->prev) && NILP (s->next)) @@ -3942,11 +4100,11 @@ Signal an error when WINDOW is the only window on its frame. */) replace_window (parent, sibling, 0); /* Have SIBLING inherit the following three slot values from PARENT (the combination_limit slot is not inherited). */ - WSET (s, normal_cols, p->normal_cols); - WSET (s, normal_lines, p->normal_lines); + wset_normal_cols (s, p->normal_cols); + wset_normal_lines (s, p->normal_lines); /* Mark PARENT as deleted. */ - WSET (p, vchild, Qnil); - WSET (p, hchild, Qnil); + wset_vchild (p, Qnil); + wset_hchild (p, Qnil); /* Try to merge SIBLING into its new parent. */ recombine_windows (sibling); } @@ -3966,7 +4124,7 @@ Signal an error when WINDOW is the only window on its frame. */) if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) Fselect_window (new_selected_window, Qt); else - FSET (f, selected_window, new_selected_window); + fset_selected_window (f, new_selected_window); UNBLOCK_INPUT; @@ -3980,7 +4138,7 @@ Signal an error when WINDOW is the only window on its frame. */) if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) Fselect_window (new_selected_window, Qnil); else - FSET (f, selected_window, new_selected_window); + fset_selected_window (f, new_selected_window); } else UNBLOCK_INPUT; @@ -3993,17 +4151,17 @@ Signal an error when WINDOW is the only window on its frame. */) { if (before_sibling) { - WSET (s, prev, window); + wset_prev (s, window); if (horflag) - WSET (p, hchild, window); + wset_hchild (p, window); else - WSET (p, vchild, window); + wset_vchild (p, window); } else { - WSET (s, next, window); + wset_next (s, window); if (!NILP (w->next)) - WSET (XWINDOW (w->next), prev, window); + wset_prev (XWINDOW (w->next), window); } error ("Deletion failed"); } @@ -4037,10 +4195,10 @@ grow_mini_window (struct window *w, int delta) window_resize_apply (r, 0); /* Grow the mini-window. */ - WSET (w, top_line, - make_number (XFASTINT (r->top_line) + XFASTINT (r->total_lines))); - WSET (w, total_lines, - make_number (XFASTINT (w->total_lines) - XINT (value))); + wset_top_line + (w, make_number (XFASTINT (r->top_line) + XFASTINT (r->total_lines))); + wset_total_lines + (w, make_number (XFASTINT (w->total_lines) - XINT (value))); w->last_modified = 0; w->last_overlay_modified = 0; @@ -4074,9 +4232,9 @@ shrink_mini_window (struct window *w) window_resize_apply (r, 0); /* Shrink the mini-window. */ - WSET (w, top_line, - make_number (XFASTINT (r->top_line) + XFASTINT (r->total_lines))); - WSET (w, total_lines, make_number (1)); + wset_top_line (w, make_number (XFASTINT (r->top_line) + + XFASTINT (r->total_lines))); + wset_total_lines (w, make_number (1)); w->last_modified = 0; w->last_overlay_modified = 0; @@ -4117,9 +4275,9 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini BLOCK_INPUT; window_resize_apply (r, 0); - WSET (w, total_lines, w->new_total); - WSET (w, top_line, - make_number (XINT (r->top_line) + XINT (r->total_lines))); + wset_total_lines (w, w->new_total); + wset_top_line (w, make_number (XINT (r->top_line) + + XINT (r->total_lines))); windows_or_buffers_changed++; FRAME_WINDOW_SIZES_CHANGED (f) = 1; @@ -5187,7 +5345,7 @@ and redisplay normally--don't erase and redraw the frame. */) /* Set the new window start. */ set_marker_both (w->start, w->buffer, charpos, bytepos); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); w->optional_new_start = 1; @@ -5201,13 +5359,13 @@ and redisplay normally--don't erase and redraw the frame. */) DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, 0, 1, 0, doc: /* Return the height in lines of the text display area of WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. The returned height does not include the mode line, any header line, nor any partial-height lines at the bottom of the text area. */) (Lisp_Object window) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); int pixel_height = window_box_height (w); int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame)); return make_number (line_height); @@ -5505,34 +5663,34 @@ the return value is nil. Otherwise the value is t. */) p = SAVED_WINDOW_N (saved_windows, k); window = p->window; w = XWINDOW (window); - WSET (w, next, Qnil); + wset_next (w, Qnil); if (!NILP (p->parent)) - WSET (w, parent, SAVED_WINDOW_N - (saved_windows, XFASTINT (p->parent))->window); + wset_parent + (w, SAVED_WINDOW_N (saved_windows, XFASTINT (p->parent))->window); else - WSET (w, parent, Qnil); + wset_parent (w, Qnil); if (!NILP (p->prev)) { - WSET (w, prev, SAVED_WINDOW_N - (saved_windows, XFASTINT (p->prev))->window); - WSET (XWINDOW (w->prev), next, p->window); + wset_prev + (w, SAVED_WINDOW_N (saved_windows, XFASTINT (p->prev))->window); + wset_next (XWINDOW (w->prev), p->window); } else { - WSET (w, prev, Qnil); + wset_prev (w, Qnil); if (!NILP (w->parent)) { if (EQ (p->total_cols, XWINDOW (w->parent)->total_cols)) { - WSET (XWINDOW (w->parent), vchild, p->window); - WSET (XWINDOW (w->parent), hchild, Qnil); + wset_vchild (XWINDOW (w->parent), p->window); + wset_hchild (XWINDOW (w->parent), Qnil); } else { - WSET (XWINDOW (w->parent), hchild, p->window); - WSET (XWINDOW (w->parent), vchild, Qnil); + wset_hchild (XWINDOW (w->parent), p->window); + wset_vchild (XWINDOW (w->parent), Qnil); } } } @@ -5540,25 +5698,25 @@ the return value is nil. Otherwise the value is t. */) /* If we squirreled away the buffer in the window's height, restore it now. */ if (BUFFERP (w->total_lines)) - WSET (w, buffer, w->total_lines); - WSET (w, left_col, p->left_col); - WSET (w, top_line, p->top_line); - WSET (w, total_cols, p->total_cols); - WSET (w, total_lines, p->total_lines); - WSET (w, normal_cols, p->normal_cols); - WSET (w, normal_lines, p->normal_lines); + wset_buffer (w, w->total_lines); + wset_left_col (w, p->left_col); + wset_top_line (w, p->top_line); + wset_total_cols (w, p->total_cols); + wset_total_lines (w, p->total_lines); + wset_normal_cols (w, p->normal_cols); + wset_normal_lines (w, p->normal_lines); w->hscroll = XFASTINT (p->hscroll); w->min_hscroll = XFASTINT (p->min_hscroll); - WSET (w, display_table, p->display_table); - WSET (w, left_margin_cols, p->left_margin_cols); - WSET (w, right_margin_cols, p->right_margin_cols); - WSET (w, left_fringe_width, p->left_fringe_width); - WSET (w, right_fringe_width, p->right_fringe_width); + wset_display_table (w, p->display_table); + wset_left_margin_cols (w, p->left_margin_cols); + wset_right_margin_cols (w, p->right_margin_cols); + wset_left_fringe_width (w, p->left_fringe_width); + wset_right_fringe_width (w, p->right_fringe_width); w->fringes_outside_margins = !NILP (p->fringes_outside_margins); - WSET (w, scroll_bar_width, p->scroll_bar_width); - WSET (w, vertical_scroll_bar_type, p->vertical_scroll_bar_type); - WSET (w, dedicated, p->dedicated); - WSET (w, combination_limit, p->combination_limit); + wset_scroll_bar_width (w, p->scroll_bar_width); + wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type); + wset_dedicated (w, p->dedicated); + wset_combination_limit (w, p->combination_limit); /* Restore any window parameters that have been saved. Parameters that have not been saved are left alone. */ for (tem = p->window_parameters; CONSP (tem); tem = XCDR (tem)) @@ -5587,24 +5745,24 @@ the return value is nil. Otherwise the value is t. */) /* Reinstall the saved buffer and pointers into it. */ if (NILP (p->buffer)) /* An internal window. */ - WSET (w, buffer, p->buffer); + wset_buffer (w, p->buffer); else if (!NILP (BVAR (XBUFFER (p->buffer), name))) /* If saved buffer is alive, install it. */ { - WSET (w, buffer, p->buffer); - w->start_at_line_beg = !NILP (p->start_at_line_beg); - set_marker_restricted (w->start, p->start, w->buffer); - set_marker_restricted (w->pointm, p->pointm, - w->buffer); - Fset_marker (BVAR (XBUFFER (w->buffer), mark), - p->mark, w->buffer); - - /* As documented in Fcurrent_window_configuration, don't - restore the location of point in the buffer which was - current when the window configuration was recorded. */ - if (!EQ (p->buffer, new_current_buffer) - && XBUFFER (p->buffer) == current_buffer) - Fgoto_char (w->pointm); + wset_buffer (w, p->buffer); + w->start_at_line_beg = !NILP (p->start_at_line_beg); + set_marker_restricted (w->start, p->start, w->buffer); + set_marker_restricted (w->pointm, p->pointm, + w->buffer); + Fset_marker (BVAR (XBUFFER (w->buffer), mark), + p->mark, w->buffer); + + /* As documented in Fcurrent_window_configuration, don't + restore the location of point in the buffer which was + current when the window configuration was recorded. */ + if (!EQ (p->buffer, new_current_buffer) + && XBUFFER (p->buffer) == current_buffer) + Fgoto_char (w->pointm); } else if (!NILP (w->buffer) && !NILP (BVAR (XBUFFER (w->buffer), name))) @@ -5616,7 +5774,7 @@ the return value is nil. Otherwise the value is t. */) set_marker_restricted (w->start, make_number (0), w->buffer); if (XMARKER (w->pointm)->buffer == 0) - set_marker_restricted_both + set_marker_restricted_both (w->pointm, w->buffer, BUF_PT (XBUFFER (w->buffer)), BUF_PT_BYTE (XBUFFER (w->buffer))); @@ -5625,7 +5783,8 @@ the return value is nil. Otherwise the value is t. */) else if (STRINGP (auto_buffer_name = Fwindow_parameter (window, Qauto_buffer_name)) && SCHARS (auto_buffer_name) != 0 - && !NILP (WSET (w, buffer, Fget_buffer_create (auto_buffer_name)))) + && (wset_buffer (w, Fget_buffer_create (auto_buffer_name)), + !NILP (w->buffer))) { set_marker_restricted (w->start, make_number (0), w->buffer); @@ -5640,7 +5799,7 @@ the return value is nil. Otherwise the value is t. */) avoid showing an unimportant buffer and, if necessary, to recreate *scratch* in the course (part of Juanma's bs-show scenario from March 2011). */ - WSET (w, buffer, other_buffer_safely (Fcurrent_buffer ())); + wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); /* This will set the markers to beginning of visible range. */ set_marker_restricted (w->start, @@ -5652,11 +5811,11 @@ the return value is nil. Otherwise the value is t. */) /* Record this window as dead. */ dead_windows = Fcons (window, dead_windows); /* Make sure window is no more dedicated. */ - WSET (w, dedicated, Qnil); + wset_dedicated (w, Qnil); } } - FSET (f, root_window, data->root_window); + fset_root_window (f, data->root_window); /* Arrange *not* to restore point in the buffer that was current when the window configuration was saved. */ if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) @@ -5752,24 +5911,25 @@ delete_all_child_windows (Lisp_Object window) /* Delete WINDOW's siblings (we traverse postorderly). */ delete_all_child_windows (w->next); - WSET (w, total_lines, w->buffer); /* See Fset_window_configuration for excuse. */ + /* See Fset_window_configuration for excuse. */ + wset_total_lines (w, w->buffer); if (!NILP (w->vchild)) { delete_all_child_windows (w->vchild); - WSET (w, vchild, Qnil); + wset_vchild (w, Qnil); } else if (!NILP (w->hchild)) { delete_all_child_windows (w->hchild); - WSET (w, hchild, Qnil); + wset_hchild (w, Qnil); } else if (!NILP (w->buffer)) { unshow_buffer (w); unchain_marker (XMARKER (w->pointm)); unchain_marker (XMARKER (w->start)); - WSET (w, buffer, Qnil); + wset_buffer (w, Qnil); } Vwindow_list = Qnil; @@ -5861,7 +6021,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) p = SAVED_WINDOW_N (vector, i); w = XWINDOW (window); - WSET (w, temslot, make_number (i)); i++; + wset_temslot (w, make_number (i)); i++; p->window = window; p->buffer = w->buffer; p->left_col = w->left_col; @@ -6034,14 +6194,15 @@ saved by this function. */) DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, 2, 3, 0, doc: /* Set width of marginal areas of window WINDOW. -If WINDOW is nil, set margins of the currently selected window. +WINDOW must be a live window and defaults to the selected one. + Second arg LEFT-WIDTH specifies the number of character cells to reserve for the left marginal area. Optional third arg RIGHT-WIDTH does the same for the right marginal area. A nil width parameter means no margin. */) (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); /* Translate negative or zero widths to nil. Margins that are too wide have to be checked elsewhere. */ @@ -6063,8 +6224,8 @@ means no margin. */) if (!EQ (w->left_margin_cols, left_width) || !EQ (w->right_margin_cols, right_width)) { - WSET (w, left_margin_cols, left_width); - WSET (w, right_margin_cols, right_width); + wset_left_margin_cols (w, left_width); + wset_right_margin_cols (w, right_width); adjust_window_margins (w); @@ -6079,13 +6240,14 @@ means no margin. */) DEFUN ("window-margins", Fwindow_margins, Swindow_margins, 0, 1, 0, doc: /* Get width of marginal areas of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. + Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). If a marginal area does not exist, its width will be returned as nil. */) (Lisp_Object window) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); return Fcons (w->left_margin_cols, w->right_margin_cols); } @@ -6098,8 +6260,8 @@ as nil. */) DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, 2, 4, 0, doc: /* Set the fringe widths of window WINDOW. -If WINDOW is nil, set the fringe widths of the currently selected -window. +WINDOW must be a live window and defaults to the selected one. + Second arg LEFT-WIDTH specifies the number of pixels to reserve for the left fringe. Optional third arg RIGHT-WIDTH specifies the right fringe width. If a fringe width arg is nil, that means to use the @@ -6110,7 +6272,7 @@ outside of the display margins. By default, fringes are drawn between display marginal areas and the text area. */) (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); int outside = !NILP (outside_margins); if (!NILP (left_width)) @@ -6124,14 +6286,14 @@ display marginal areas and the text area. */) || !EQ (w->right_fringe_width, right_width) || w->fringes_outside_margins != outside)) { - WSET (w, left_fringe_width, left_width); - WSET (w, right_fringe_width, right_width); + wset_left_fringe_width (w, left_width); + wset_right_fringe_width (w, right_width); w->fringes_outside_margins = outside; adjust_window_margins (w); clear_glyph_matrix (w->current_matrix); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); ++windows_or_buffers_changed; adjust_glyphs (XFRAME (WINDOW_FRAME (w))); @@ -6144,11 +6306,12 @@ display marginal areas and the text area. */) DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, 0, 1, 0, doc: /* Get width of fringes of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. + Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) (Lisp_Object window) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)), Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)), @@ -6165,7 +6328,8 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, Sset_window_scroll_bars, 2, 4, 0, doc: /* Set width and type of scroll bars of window WINDOW. -If window is nil, set scroll bars of the currently selected window. +WINDOW must be a live window and defaults to the selected one. + Second parameter WIDTH specifies the pixel width for the scroll bar; this is automatically adjusted to a multiple of the frame column width. Third parameter VERTICAL-TYPE specifies the type of the vertical scroll @@ -6175,7 +6339,7 @@ If VERTICAL-TYPE is t, use the frame's scroll-bar type. Fourth parameter HORIZONTAL-TYPE is currently unused. */) (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); if (!NILP (width)) { @@ -6194,13 +6358,13 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) if (!EQ (w->scroll_bar_width, width) || !EQ (w->vertical_scroll_bar_type, vertical_type)) { - WSET (w, scroll_bar_width, width); - WSET (w, vertical_scroll_bar_type, vertical_type); + wset_scroll_bar_width (w, width); + wset_vertical_scroll_bar_type (w, vertical_type); adjust_window_margins (w); clear_glyph_matrix (w->current_matrix); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); ++windows_or_buffers_changed; adjust_glyphs (XFRAME (WINDOW_FRAME (w))); @@ -6213,13 +6377,14 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars, 0, 1, 0, doc: /* Get width and type of scroll bars of window WINDOW. -If WINDOW is omitted or nil, it defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. + Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). If WIDTH is nil or TYPE is t, the window is using the frame's corresponding value. */) (Lisp_Object window) { - struct window *w = decode_window (window); + struct window *w = decode_live_window (window); return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) : WINDOW_SCROLL_BAR_AREA_WIDTH (w))), @@ -6513,6 +6678,7 @@ syms_of_window (void) DEFSYM (Qwindowp, "windowp"); DEFSYM (Qwindow_configuration_p, "window-configuration-p"); DEFSYM (Qwindow_live_p, "window-live-p"); + DEFSYM (Qwindow_valid_p, "window-valid-p"); DEFSYM (Qwindow_deletable_p, "window-deletable-p"); DEFSYM (Qdelete_window, "delete-window"); DEFSYM (Qwindow_resize_root_window, "window--resize-root-window"); @@ -6665,6 +6831,7 @@ respectively are not installed by `window-state-put'. */); defsubr (&Sminibuffer_window); defsubr (&Swindow_minibuffer_p); defsubr (&Swindowp); + defsubr (&Swindow_valid_p); defsubr (&Swindow_live_p); defsubr (&Swindow_frame); defsubr (&Sframe_root_window); diff --git a/src/window.h b/src/window.h index 3e6f4f82b0a..28b9678b667 100644 --- a/src/window.h +++ b/src/window.h @@ -22,6 +22,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "dispextern.h" +INLINE_HEADER_BEGIN +#ifndef WINDOW_INLINE +# define WINDOW_INLINE INLINE +#endif + extern Lisp_Object Qleft, Qright; /* Windows are allocated as if they were vectors, but then the @@ -86,10 +91,6 @@ struct cursor_pos int hpos, vpos; }; -/* Most code should use this macro to set Lisp fields in struct window. */ - -#define WSET(w, field, value) ((w)->field = (value)) - struct window { /* This is for Lisp; the terminal code does not refer to it. */ @@ -348,6 +349,75 @@ struct window ptrdiff_t window_end_bytepos; }; +/* Most code should use these functions to set Lisp fields in struct + window. */ +WINDOW_INLINE void +wset_buffer (struct window *w, Lisp_Object val) +{ + w->buffer = val; +} +WINDOW_INLINE void +wset_frame (struct window *w, Lisp_Object val) +{ + w->frame = val; +} +WINDOW_INLINE void +wset_left_col (struct window *w, Lisp_Object val) +{ + w->left_col = val; +} +WINDOW_INLINE void +wset_next (struct window *w, Lisp_Object val) +{ + w->next = val; +} +WINDOW_INLINE void +wset_prev (struct window *w, Lisp_Object val) +{ + w->prev = val; +} +WINDOW_INLINE void +wset_redisplay_end_trigger (struct window *w, Lisp_Object val) +{ + w->redisplay_end_trigger = val; +} +WINDOW_INLINE void +wset_top_line (struct window *w, Lisp_Object val) +{ + w->top_line = val; +} +WINDOW_INLINE void +wset_total_cols (struct window *w, Lisp_Object val) +{ + w->total_cols = val; +} +WINDOW_INLINE void +wset_total_lines (struct window *w, Lisp_Object val) +{ + w->total_lines = val; +} +WINDOW_INLINE void +wset_vertical_scroll_bar (struct window *w, Lisp_Object val) +{ + w->vertical_scroll_bar = val; +} +WINDOW_INLINE void +wset_window_end_pos (struct window *w, Lisp_Object val) +{ + w->window_end_pos = val; +} +WINDOW_INLINE void +wset_window_end_valid (struct window *w, Lisp_Object val) +{ + w->window_end_valid = val; +} +WINDOW_INLINE void +wset_window_end_vpos (struct window *w, Lisp_Object val) +{ + w->window_end_vpos = val; +} + + /* 1 if W is a minibuffer window. */ #define MINI_WINDOW_P(W) ((W)->mini) @@ -885,8 +955,15 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols); struct glyph *get_phys_cursor_glyph (struct window *w); -/* Value is non-zero if WINDOW is a live window. */ +/* Value is non-zero if WINDOW is a valid window. */ +#define WINDOW_VALID_P(WINDOW) \ + (WINDOWP (WINDOW) \ + && (!NILP (XWINDOW (WINDOW)->buffer) \ + || !NILP (XWINDOW (WINDOW)->vchild) \ + || !NILP (XWINDOW (WINDOW)->hchild))) + +/* Value is non-zero if WINDOW is a live window. */ #define WINDOW_LIVE_P(WINDOW) \ (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) @@ -895,6 +972,8 @@ struct glyph *get_phys_cursor_glyph (struct window *w); extern Lisp_Object Qwindowp, Qwindow_live_p; extern Lisp_Object Vwindow_list; +extern struct window *decode_valid_window (Lisp_Object); +extern struct window *decode_live_window (Lisp_Object); extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); extern void mark_window_cursors_off (struct window *); extern int window_internal_height (struct window *); @@ -907,4 +986,6 @@ extern void init_window (void); extern void syms_of_window (void); extern void keys_of_window (void); +INLINE_HEADER_END + #endif /* not WINDOW_H_INCLUDED */ diff --git a/src/xdisp.c b/src/xdisp.c index 4cd95606041..e41783d03c1 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -365,6 +365,28 @@ Lisp_Object Qcenter; static Lisp_Object Qmargin, Qpointer; static Lisp_Object Qline_height; +/* These setters are used only in this file, so they can be private. */ +static inline void +wset_base_line_number (struct window *w, Lisp_Object val) +{ + w->base_line_number = val; +} +static inline void +wset_base_line_pos (struct window *w, Lisp_Object val) +{ + w->base_line_pos = val; +} +static inline void +wset_column_number_displayed (struct window *w, Lisp_Object val) +{ + w->column_number_displayed = val; +} +static inline void +wset_region_showing (struct window *w, Lisp_Object val) +{ + w->region_showing = val; +} + #ifdef HAVE_WINDOW_SYSTEM /* Test if overflow newline into fringe. Called with iterator IT @@ -4047,38 +4069,54 @@ static enum prop_handled handle_invisible_prop (struct it *it) { enum prop_handled handled = HANDLED_NORMALLY; + int invis_p; + Lisp_Object prop; if (STRINGP (it->string)) { - Lisp_Object prop, end_charpos, limit, charpos; + Lisp_Object end_charpos, limit, charpos; /* Get the value of the invisible text property at the current position. Value will be nil if there is no such property. */ charpos = make_number (IT_STRING_CHARPOS (*it)); prop = Fget_text_property (charpos, Qinvisible, it->string); + invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); - if (!NILP (prop) - && IT_STRING_CHARPOS (*it) < it->end_charpos) + if (invis_p && IT_STRING_CHARPOS (*it) < it->end_charpos) { - ptrdiff_t endpos; + /* Record whether we have to display an ellipsis for the + invisible text. */ + int display_ellipsis_p = (invis_p == 2); + ptrdiff_t len, endpos; handled = HANDLED_RECOMPUTE_PROPS; - /* Get the position at which the next change of the - invisible text property can be found in IT->string. - Value will be nil if the property value is the same for - all the rest of IT->string. */ - XSETINT (limit, SCHARS (it->string)); - end_charpos = Fnext_single_property_change (charpos, Qinvisible, - it->string, limit); - - /* Text at current position is invisible. The next - change in the property is at position end_charpos. - Move IT's current position to that position. */ - if (INTEGERP (end_charpos) - && (endpos = XFASTINT (end_charpos)) < XFASTINT (limit)) + /* Get the position at which the next visible text can be + found in IT->string, if any. */ + endpos = len = SCHARS (it->string); + XSETINT (limit, len); + do + { + end_charpos = Fnext_single_property_change (charpos, Qinvisible, + it->string, limit); + if (INTEGERP (end_charpos)) + { + endpos = XFASTINT (end_charpos); + prop = Fget_text_property (end_charpos, Qinvisible, it->string); + invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); + if (invis_p == 2) + display_ellipsis_p = 1; + } + } + while (invis_p && endpos < len); + + if (display_ellipsis_p) + it->ellipsis_p = 1; + + if (endpos < len) { + /* Text at END_CHARPOS is visible. Move IT there. */ struct text_pos old; ptrdiff_t oldpos; @@ -4114,7 +4152,8 @@ handle_invisible_prop (struct it *it) /* The rest of the string is invisible. If this is an overlay string, proceed with the next overlay string or whatever comes and return a character from there. */ - if (it->current.overlay_string_index >= 0) + if (it->current.overlay_string_index >= 0 + && !display_ellipsis_p) { next_overlay_string (it); /* Don't check for overlay strings when we just @@ -4131,9 +4170,8 @@ handle_invisible_prop (struct it *it) } else { - int invis_p; ptrdiff_t newpos, next_stop, start_charpos, tem; - Lisp_Object pos, prop, overlay; + Lisp_Object pos, overlay; /* First of all, is there invisible text at this position? */ tem = start_charpos = IT_CHARPOS (*it); @@ -6010,7 +6048,7 @@ back_to_previous_visible_line_start (struct it *it) { Lisp_Object prop; prop = Fget_char_property (make_number (IT_CHARPOS (*it) - 1), - Qinvisible, it->window); + Qinvisible, it->window); if (TEXT_PROP_MEANS_INVISIBLE (prop)) continue; } @@ -7981,7 +8019,7 @@ run_redisplay_end_trigger_hook (struct it *it) /* Since we are *trying* to run these functions, don't try to run them again, even if they get an error. */ - WSET (it->w, redisplay_end_trigger, Qnil); + wset_redisplay_end_trigger (it->w, Qnil); Frun_hook_with_args (3, args); /* Notice if it changed the face of the character we are on. */ @@ -9318,7 +9356,7 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte) old_deactivate_mark = Vdeactivate_mark; oldbuf = current_buffer; Fset_buffer (Fget_buffer_create (Vmessages_buffer_name)); - BSET (current_buffer, undo_list, Qt); + bset_undo_list (current_buffer, Qt); oldpoint = message_dolog_marker1; set_marker_restricted (oldpoint, make_number (PT), Qnil); @@ -9880,7 +9918,7 @@ ensure_echo_area_buffers (void) old_buffer = echo_buffer[i]; echo_buffer[i] = Fget_buffer_create (make_formatted_string (name, " *Echo Area %d*", i)); - BSET (XBUFFER (echo_buffer[i]), truncate_lines, Qnil); + bset_truncate_lines (XBUFFER (echo_buffer[i]), Qnil); /* to force word wrap in echo area - it was decided to postpone this*/ /* XBUFFER (echo_buffer[i])->word_wrap = Qt; */ @@ -9969,12 +10007,12 @@ with_echo_area_buffer (struct window *w, int which, set_buffer_internal_1 (XBUFFER (buffer)); if (w) { - WSET (w, buffer, buffer); + wset_buffer (w, buffer); set_marker_both (w->pointm, buffer, BEG, BEG_BYTE); } - BSET (current_buffer, undo_list, Qt); - BSET (current_buffer, read_only, Qnil); + bset_undo_list (current_buffer, Qt); + bset_read_only (current_buffer, Qnil); specbind (Qinhibit_read_only, Qt); specbind (Qinhibit_modification_hooks, Qt); @@ -10054,7 +10092,7 @@ unwind_with_echo_area_buffer (Lisp_Object vector) charpos = AREF (vector, 5); bytepos = AREF (vector, 6); - WSET (w, buffer, buffer); + wset_buffer (w, buffer); set_marker_both (w->pointm, buffer, XFASTINT (charpos), XFASTINT (bytepos)); } @@ -10087,7 +10125,7 @@ setup_echo_area_for_printing (int multibyte_p) /* Switch to that buffer and clear it. */ set_buffer_internal (XBUFFER (echo_area_buffer[0])); - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); if (Z > BEG) { @@ -10130,7 +10168,7 @@ setup_echo_area_for_printing (int multibyte_p) { /* Someone switched buffers between print requests. */ set_buffer_internal (XBUFFER (echo_area_buffer[0])); - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); } } } @@ -10582,9 +10620,9 @@ set_message_1 (ptrdiff_t a1, Lisp_Object a2, ptrdiff_t nbytes, ptrdiff_t multiby != !NILP (BVAR (current_buffer, enable_multibyte_characters))) Fset_buffer_multibyte (message_enable_multibyte ? Qt : Qnil); - BSET (current_buffer, truncate_lines, message_truncate_lines ? Qt : Qnil); + bset_truncate_lines (current_buffer, message_truncate_lines ? Qt : Qnil); if (!NILP (BVAR (current_buffer, bidi_display_reordering))) - BSET (current_buffer, bidi_paragraph_direction, Qleft_to_right); + bset_bidi_paragraph_direction (current_buffer, Qleft_to_right); /* Insert new message at BEG. */ TEMP_SET_PT_BOTH (BEG, BEG_BYTE); @@ -11274,7 +11312,7 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run) } XSETFRAME (Vmenu_updating_frame, f); - FSET (f, menu_bar_items, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); + fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); /* Redisplay the menu bar in case we changed it. */ #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ @@ -11487,7 +11525,7 @@ update_tool_bar (struct frame *f, int save_match_data) may access f->tool_bar_items. Make sure we update both variables within BLOCK_INPUT so no such event interrupts. */ BLOCK_INPUT; - FSET (f, tool_bar_items, new_tool_bar); + fset_tool_bar_items (f, new_tool_bar); f->n_tool_bar_items = new_n_tool_bar; w->update_mode_line = 1; UNBLOCK_INPUT; @@ -11529,8 +11567,8 @@ build_desired_tool_bar_string (struct frame *f) /* Reuse f->desired_tool_bar_string, if possible. */ if (size < size_needed || NILP (f->desired_tool_bar_string)) - FSET (f, desired_tool_bar_string, - Fmake_string (make_number (size_needed), make_number (' '))); + fset_desired_tool_bar_string + (f, Fmake_string (make_number (size_needed), make_number (' '))); else { props = list4 (Qdisplay, Qnil, Qmenu_item, Qnil); @@ -13266,12 +13304,12 @@ redisplay_internal (void) if ((it.glyph_row - 1)->displays_text_p) { if (XFASTINT (w->window_end_vpos) < this_line_vpos) - WSET (w, window_end_vpos, make_number (this_line_vpos)); + wset_window_end_vpos (w, make_number (this_line_vpos)); } else if (XFASTINT (w->window_end_vpos) == this_line_vpos && this_line_vpos > 0) - WSET (w, window_end_vpos, make_number (this_line_vpos - 1)); - WSET (w, window_end_valid, Qnil); + wset_window_end_vpos (w, make_number (this_line_vpos - 1)); + wset_window_end_valid (w, Qnil); /* Update hint: No need to try to scroll in update_window. */ w->desired_matrix->no_scrolling_p = 1; @@ -13737,7 +13775,7 @@ mark_window_display_accurate_1 (struct window *w, int accurate_p) if (accurate_p) { - WSET (w, window_end_valid, w->buffer); + wset_window_end_valid (w, w->buffer); w->update_mode_line = 0; } } @@ -14845,7 +14883,7 @@ try_scrolling (Lisp_Object window, int just_this_one_p, if (!just_this_one_p || current_buffer->clip_changed || BEG_UNCHANGED < CHARPOS (startp)) - WSET (w, base_line_number, Qnil); + wset_base_line_number (w, Qnil); /* If cursor ends up on a partially visible line, treat that as being off the bottom of the screen. */ @@ -15470,7 +15508,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) if (XMARKER (w->start)->buffer == current_buffer) compute_window_start_on_continuation_line (w); - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); } /* Some sanity checks. */ @@ -15581,11 +15619,11 @@ redisplay_window (Lisp_Object window, int just_this_one_p) w->force_start = 0; w->vscroll = 0; - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); /* Forget any recorded base line for line number display. */ if (!buffer_unchanged_p) - WSET (w, base_line_number, Qnil); + wset_base_line_number (w, Qnil); /* Redisplay the mode line. Select the buffer properly for that. Also, run the hook window-scroll-functions @@ -15799,7 +15837,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) || current_buffer->clip_changed || BEG_UNCHANGED < CHARPOS (startp)) /* Forget any recorded base line for line number display. */ - WSET (w, base_line_number, Qnil); + wset_base_line_number (w, Qnil); if (!cursor_row_fully_visible_p (w, 1, 0)) { @@ -15870,7 +15908,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) /* Forget any previously recorded base line for line number display. */ if (!buffer_unchanged_p) - WSET (w, base_line_number, Qnil); + wset_base_line_number (w, Qnil); /* Determine the window start relative to point. */ init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); @@ -16128,8 +16166,8 @@ redisplay_window (Lisp_Object window, int just_this_one_p) if (!line_number_displayed && !BUFFERP (w->base_line_pos)) { - WSET (w, base_line_pos, Qnil); - WSET (w, base_line_number, Qnil); + wset_base_line_pos (w, Qnil); + wset_base_line_number (w, Qnil); } finish_menu_bars: @@ -16306,10 +16344,10 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row)); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix))); + wset_window_end_pos + (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix))); eassert (MATRIX_ROW (w->desired_matrix, XFASTINT (w->window_end_vpos))->displays_text_p); @@ -16317,12 +16355,12 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) else { w->window_end_bytepos = Z_BYTE - ZV_BYTE; - WSET (w, window_end_pos, make_number (Z - ZV)); - WSET (w, window_end_vpos, make_number (0)); + wset_window_end_pos (w, make_number (Z - ZV)); + wset_window_end_vpos (w, make_number (0)); } /* But that is not valid info until redisplay finishes. */ - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); return 1; } @@ -16546,28 +16584,31 @@ try_window_reusing_current_matrix (struct window *w) { w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_reused_text_row); - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (last_reused_text_row))); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (last_reused_text_row, w->current_matrix))); + wset_window_end_pos + (w, make_number (Z + - MATRIX_ROW_END_CHARPOS (last_reused_text_row))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (last_reused_text_row, + w->current_matrix))); } else if (last_text_row) { w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix))); + wset_window_end_pos + (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (last_text_row, + w->desired_matrix))); } else { /* This window must be completely empty. */ w->window_end_bytepos = Z_BYTE - ZV_BYTE; - WSET (w, window_end_pos, make_number (Z - ZV)); - WSET (w, window_end_vpos, make_number (0)); + wset_window_end_pos (w, make_number (Z - ZV)); + wset_window_end_vpos (w, make_number (0)); } - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); /* Update hint: don't try scrolling again in update_window. */ w->desired_matrix->no_scrolling_p = 1; @@ -16748,18 +16789,19 @@ try_window_reusing_current_matrix (struct window *w) { w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix))); + wset_window_end_pos + (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (last_text_row, + w->desired_matrix))); } else { - WSET (w, window_end_vpos, - make_number (XFASTINT (w->window_end_vpos) - nrows_scrolled)); + wset_window_end_vpos + (w, make_number (XFASTINT (w->window_end_vpos) - nrows_scrolled)); } - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); w->desired_matrix->no_scrolling_p = 1; #ifdef GLYPH_DEBUG @@ -17331,8 +17373,8 @@ try_window_id (struct window *w) { /* We have to compute the window end anew since text could have been added/removed after it. */ - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (row))); + wset_window_end_pos + (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); @@ -17766,21 +17808,22 @@ try_window_id (struct window *w) first_unchanged_at_end_row); eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row)); - WSET (w, window_end_pos, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); + wset_window_end_pos (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (row, w->current_matrix))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (row, w->current_matrix))); eassert (w->window_end_bytepos >= 0); IF_DEBUG (debug_method_add (w, "A")); } else if (last_text_row_at_end) { - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end))); + wset_window_end_pos + (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end))); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row_at_end); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (last_text_row_at_end, desired_matrix))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (last_text_row_at_end, + desired_matrix))); eassert (w->window_end_bytepos >= 0); IF_DEBUG (debug_method_add (w, "B")); } @@ -17789,12 +17832,12 @@ try_window_id (struct window *w) /* We have displayed either to the end of the window or at the end of the window, i.e. the last row with text is to be found in the desired matrix. */ - WSET (w, window_end_pos, - make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); + wset_window_end_pos + (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); - WSET (w, window_end_vpos, - make_number (MATRIX_ROW_VPOS (last_text_row, desired_matrix))); + wset_window_end_vpos + (w, make_number (MATRIX_ROW_VPOS (last_text_row, desired_matrix))); eassert (w->window_end_bytepos >= 0); } else if (first_unchanged_at_end_row == NULL @@ -17822,8 +17865,8 @@ try_window_id (struct window *w) } eassert (row != NULL); - WSET (w, window_end_vpos, make_number (vpos + 1)); - WSET (w, window_end_pos, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); + wset_window_end_vpos (w, make_number (vpos + 1)); + wset_window_end_pos (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); eassert (w->window_end_bytepos >= 0); IF_DEBUG (debug_method_add (w, "C")); @@ -17835,7 +17878,7 @@ try_window_id (struct window *w) debug_end_vpos = XFASTINT (w->window_end_vpos)); /* Record that display has not been completed. */ - WSET (w, window_end_valid, Qnil); + wset_window_end_valid (w, Qnil); w->desired_matrix->no_scrolling_p = 1; return 3; @@ -19248,7 +19291,7 @@ display_line (struct it *it) } /* Is IT->w showing the region? */ - WSET (it->w, region_showing, it->region_beg_charpos > 0 ? Qt : Qnil); + wset_region_showing (it->w, it->region_beg_charpos > 0 ? Qt : Qnil); /* Clear the result glyph row and enable it. */ prepare_desired_row (row); @@ -20252,7 +20295,7 @@ display_mode_lines (struct window *w) /* These will be set while the mode line specs are processed. */ line_number_displayed = 0; - WSET (w, column_number_displayed, Qnil); + wset_column_number_displayed (w, Qnil); if (WINDOW_WANTS_MODELINE_P (w)) { @@ -21388,7 +21431,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, else { ptrdiff_t col = current_column (); - WSET (w, column_number_displayed, make_number (col)); + wset_column_number_displayed (w, make_number (col)); pint2str (decode_mode_spec_buf, field_width, col); return decode_mode_spec_buf; } @@ -21451,14 +21494,14 @@ decode_mode_spec (struct window *w, register int c, int field_width, goto no_value; /* But do forget it, if the window shows a different buffer now. */ else if (BUFFERP (w->base_line_pos)) - WSET (w, base_line_pos, Qnil); + wset_base_line_pos (w, Qnil); /* If the buffer is very big, don't waste time. */ if (INTEGERP (Vline_number_display_limit) && BUF_ZV (b) - BUF_BEGV (b) > XINT (Vline_number_display_limit)) { - WSET (w, base_line_pos, Qnil); - WSET (w, base_line_number, Qnil); + wset_base_line_pos (w, Qnil); + wset_base_line_number (w, Qnil); goto no_value; } @@ -21490,8 +21533,8 @@ decode_mode_spec (struct window *w, register int c, int field_width, go back past it. */ if (startpos == BUF_BEGV (b)) { - WSET (w, base_line_number, make_number (topline)); - WSET (w, base_line_pos, make_number (BUF_BEGV (b))); + wset_base_line_number (w, make_number (topline)); + wset_base_line_pos (w, make_number (BUF_BEGV (b))); } else if (nlines < height + 25 || nlines > height * 3 + 50 || linepos == BUF_BEGV (b)) @@ -21517,13 +21560,13 @@ decode_mode_spec (struct window *w, register int c, int field_width, give up on line numbers for this window. */ if (position == limit_byte && limit == startpos - distance) { - WSET (w, base_line_pos, w->buffer); - WSET (w, base_line_number, Qnil); + wset_base_line_pos (w, w->buffer); + wset_base_line_number (w, Qnil); goto no_value; } - WSET (w, base_line_number, make_number (topline - nlines)); - WSET (w, base_line_pos, make_number (BYTE_TO_CHAR (position))); + wset_base_line_number (w, make_number (topline - nlines)); + wset_base_line_pos (w, make_number (BYTE_TO_CHAR (position))); } /* Now count lines from the start pos to point. */ @@ -29288,12 +29331,13 @@ init_xdisp (void) echo_area_window = minibuf_window; - WSET (r, top_line, make_number (FRAME_TOP_MARGIN (f))); - WSET (r, total_lines, make_number (FRAME_LINES (f) - 1 - FRAME_TOP_MARGIN (f))); - WSET (r, total_cols, make_number (FRAME_COLS (f))); - WSET (m, top_line, make_number (FRAME_LINES (f) - 1)); - WSET (m, total_lines, make_number (1)); - WSET (m, total_cols, make_number (FRAME_COLS (f))); + wset_top_line (r, make_number (FRAME_TOP_MARGIN (f))); + wset_total_lines + (r, make_number (FRAME_LINES (f) - 1 - FRAME_TOP_MARGIN (f))); + wset_total_cols (r, make_number (FRAME_COLS (f))); + wset_top_line (m, make_number (FRAME_LINES (f) - 1)); + wset_total_lines (m, make_number (1)); + wset_total_cols (m, make_number (FRAME_COLS (f))); scratch_glyph_row.glyphs[TEXT_AREA] = scratch_glyphs; scratch_glyph_row.glyphs[TEXT_AREA + 1] diff --git a/src/xfaces.c b/src/xfaces.c index ed372c6b419..46121d66606 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -279,7 +279,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif /* HAVE_X_WINDOWS */ -#include <ctype.h> +#include <c-ctype.h> /* Number of pt per inch (from the TeXbook). */ @@ -2281,6 +2281,7 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, struct named_merge_point *named_merge_points) { int i; + Lisp_Object font = Qnil; /* If FROM inherits from some other faces, merge their attributes into TO before merging FROM's direct attributes. Note that an :inherit @@ -2291,24 +2292,13 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, && !NILP (from[LFACE_INHERIT_INDEX])) merge_face_ref (f, from[LFACE_INHERIT_INDEX], to, 0, named_merge_points); - i = LFACE_FONT_INDEX; - if (!UNSPECIFIEDP (from[i])) + if (FONT_SPEC_P (from[LFACE_FONT_INDEX])) { - if (!UNSPECIFIEDP (to[i])) - to[i] = merge_font_spec (from[i], to[i]); + if (!UNSPECIFIEDP (to[LFACE_FONT_INDEX])) + font = merge_font_spec (from[LFACE_FONT_INDEX], to[LFACE_FONT_INDEX]); else - to[i] = copy_font_spec (from[i]); - if (! NILP (AREF (to[i], FONT_FOUNDRY_INDEX))) - to[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (to[i], FONT_FOUNDRY_INDEX)); - if (! NILP (AREF (to[i], FONT_FAMILY_INDEX))) - to[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (to[i], FONT_FAMILY_INDEX)); - if (! NILP (AREF (to[i], FONT_WEIGHT_INDEX))) - to[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (to[i]); - if (! NILP (AREF (to[i], FONT_SLANT_INDEX))) - to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (to[i]); - if (! NILP (AREF (to[i], FONT_WIDTH_INDEX))) - to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (to[i]); - ASET (to[i], FONT_SIZE_INDEX, Qnil); + font = copy_font_spec (from[LFACE_FONT_INDEX]); + to[LFACE_FONT_INDEX] = font; } for (i = 1; i < LFACE_VECTOR_SIZE; ++i) @@ -2319,8 +2309,7 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, to[i] = merge_face_heights (from[i], to[i], to[i]); font_clear_prop (to, FONT_SIZE_INDEX); } - else if (i != LFACE_FONT_INDEX - && ! EQ (to[i], from[i])) + else if (i != LFACE_FONT_INDEX && ! EQ (to[i], from[i])) { to[i] = from[i]; if (i >= LFACE_FAMILY_INDEX && i <=LFACE_SLANT_INDEX) @@ -2334,6 +2323,25 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, } } + /* If FROM specifies a font spec, make its contents take precedence + over :family and other attributes. This is needed for face + remapping using :font to work. */ + + if (!NILP (font)) + { + if (! NILP (AREF (font, FONT_FOUNDRY_INDEX))) + to[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (font, FONT_FOUNDRY_INDEX)); + if (! NILP (AREF (font, FONT_FAMILY_INDEX))) + to[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX)); + if (! NILP (AREF (font, FONT_WEIGHT_INDEX))) + to[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (font); + if (! NILP (AREF (font, FONT_SLANT_INDEX))) + to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (font); + if (! NILP (AREF (font, FONT_WIDTH_INDEX))) + to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (font); + ASET (font, FONT_SIZE_INDEX, Qnil); + } + /* TO is always an absolute face, which should inherit from nothing. We blindly copy the :inherit attribute above and fix it up here. */ to[LFACE_INHERIT_INDEX] = Qnil; @@ -2575,6 +2583,13 @@ merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to, else err = 1; } + else if (EQ (keyword, QCfont)) + { + if (FONTP (value)) + to[LFACE_FONT_INDEX] = value; + else + err = 1; + } else if (EQ (keyword, QCinherit)) { /* This is not really very useful; it's just like a @@ -2680,7 +2695,7 @@ Value is a vector of face attributes. */) lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), Qunspecified); ASET (lface, 0, Qface); - FSET (f, face_alist, Fcons (Fcons (face, lface), f->face_alist)); + fset_face_alist (f, Fcons (Fcons (face, lface), f->face_alist)); } else for (i = 1; i < LFACE_VECTOR_SIZE; ++i) @@ -4059,7 +4074,7 @@ hash_string_case_insensitive (Lisp_Object string) unsigned hash = 0; eassert (STRINGP (string)); for (s = SDATA (string); *s; ++s) - hash = (hash << 1) ^ tolower (*s); + hash = (hash << 1) ^ c_tolower (*s); return hash; } diff --git a/src/xfns.c b/src/xfns.c index 2e7334b7d71..90b54d12345 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -49,7 +49,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_X_WINDOWS -#include <ctype.h> #include <sys/types.h> #include <sys/stat.h> @@ -659,7 +658,7 @@ x_set_tool_bar_position (struct frame *f, #ifdef USE_GTK if (xg_change_toolbar_position (f, new_value)) - FSET (f, tool_bar_position, new_value); + fset_tool_bar_position (f, new_value); #endif } @@ -1146,7 +1145,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) else if (!NILP (arg) || NILP (oldval)) return; - FSET (f, icon_name, arg); + fset_icon_name (f, arg); if (f->output_data.x->icon_bitmap != 0) return; @@ -1637,7 +1636,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit) if (! NILP (Fstring_equal (name, f->name))) return; - FSET (f, name, name); + fset_name (f, name); /* For setting the frame title, the title parameter should override the name parameter. */ @@ -1677,7 +1676,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) update_mode_lines = 1; - FSET (f, title, name); + fset_title (f, name); if (NILP (name)) name = f->name; @@ -2566,7 +2565,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) f->explicit_name = 0; name = f->name; - FSET (f, name, Qnil); + fset_name (f, Qnil); x_set_name (f, name, explicit); } @@ -2709,7 +2708,7 @@ x_window (struct frame *f) f->explicit_name = 0; name = f->name; - FSET (f, name, Qnil); + fset_name (f, Qnil); x_set_name (f, name, explicit); } @@ -3129,11 +3128,11 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_data.x->scroll_bar_bottom_shadow_pixel = -1; #endif /* USE_TOOLKIT_SCROLL_BARS */ - FSET (f, icon_name, - x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", - RES_TYPE_STRING)); + fset_icon_name (f, + x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", + RES_TYPE_STRING)); if (! STRINGP (f->icon_name)) - FSET (f, icon_name, Qnil); + fset_icon_name (f, Qnil); FRAME_X_DISPLAY_INFO (f) = dpyinfo; @@ -3190,12 +3189,12 @@ This function is an internal primitive--use `make-frame' instead. */) be set. */ if (EQ (name, Qunbound) || NILP (name)) { - FSET (f, name, build_string (dpyinfo->x_id_name)); + fset_name (f, build_string (dpyinfo->x_id_name)); f->explicit_name = 0; } else { - FSET (f, name, name); + fset_name (f, name); f->explicit_name = 1; /* use the frame's title when getting resources for this frame. */ specbind (Qx_resource_name, name); @@ -3456,13 +3455,13 @@ This function is an internal primitive--use `make-frame' instead. */) if (FRAME_HAS_MINIBUF_P (f) && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame)) || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame))))) - KSET (kb, Vdefault_minibuffer_frame, frame); + kset_default_minibuffer_frame (kb, frame); /* All remaining specified parameters, which have not been "used" by x_get_arg and friends, now go in the misc. alist of the frame. */ for (tem = parms; CONSP (tem); tem = XCDR (tem)) if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) - FSET (f, param_alist, Fcons (XCAR (tem), f->param_alist)); + fset_param_alist (f, Fcons (XCAR (tem), f->param_alist)); UNGCPRO; @@ -4591,7 +4590,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, set_window_buffer (FRAME_ROOT_WINDOW (f), buffer, 0, 0); old_buffer = current_buffer; set_buffer_internal_1 (XBUFFER (buffer)); - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); specbind (Qinhibit_read_only, Qt); specbind (Qinhibit_modification_hooks, Qt); Ferase_buffer (); @@ -4617,7 +4616,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, f->output_data.x->scroll_bar_top_shadow_pixel = -1; f->output_data.x->scroll_bar_bottom_shadow_pixel = -1; #endif /* USE_TOOLKIT_SCROLL_BARS */ - FSET (f, icon_name, Qnil); + fset_icon_name (f, Qnil); FRAME_X_DISPLAY_INFO (f) = dpyinfo; f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; f->output_data.x->explicit_parent = 0; @@ -4659,12 +4658,12 @@ x_create_tip_frame (struct x_display_info *dpyinfo, be set. */ if (EQ (name, Qunbound) || NILP (name)) { - FSET (f, name, build_string (dpyinfo->x_id_name)); + fset_name (f, build_string (dpyinfo->x_id_name)); f->explicit_name = 0; } else { - FSET (f, name, name); + fset_name (f, name); f->explicit_name = 1; /* use the frame's title when getting resources for this frame. */ specbind (Qx_resource_name, name); @@ -5065,20 +5064,20 @@ Text larger than the specified size is clipped. */) /* Set up the frame's root window. */ w = XWINDOW (FRAME_ROOT_WINDOW (f)); - WSET (w, left_col, make_number (0)); - WSET (w, top_line, make_number (0)); + wset_left_col (w, make_number (0)); + wset_top_line (w, make_number (0)); if (CONSP (Vx_max_tooltip_size) && RANGED_INTEGERP (1, XCAR (Vx_max_tooltip_size), INT_MAX) && RANGED_INTEGERP (1, XCDR (Vx_max_tooltip_size), INT_MAX)) { - WSET (w, total_cols, XCAR (Vx_max_tooltip_size)); - WSET (w, total_lines, XCDR (Vx_max_tooltip_size)); + wset_total_cols (w, XCAR (Vx_max_tooltip_size)); + wset_total_lines (w, XCDR (Vx_max_tooltip_size)); } else { - WSET (w, total_cols, make_number (80)); - WSET (w, total_lines, make_number (40)); + wset_total_cols (w, make_number (80)); + wset_total_lines (w, make_number (40)); } FRAME_TOTAL_COLS (f) = XINT (w->total_cols); @@ -5088,7 +5087,7 @@ Text larger than the specified size is clipped. */) /* Display the tooltip text in a temporary buffer. */ old_buffer = current_buffer; set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); - BSET (current_buffer, truncate_lines, Qnil); + bset_truncate_lines (current_buffer, Qnil); clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); @@ -5148,7 +5147,7 @@ Text larger than the specified size is clipped. */) /* w->total_cols and FRAME_TOTAL_COLS want the width in columns, not in pixels. */ width /= WINDOW_FRAME_COLUMN_WIDTH (w); - WSET (w, total_cols, make_number (width)); + wset_total_cols (w, make_number (width)); FRAME_TOTAL_COLS (f) = width; adjust_glyphs (f); clear_glyph_matrix (w->desired_matrix); diff --git a/src/xfont.c b/src/xfont.c index 9e929eed678..072bce7bb0a 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -823,6 +823,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) font->descent = xfont->descent; font->height = font->ascent + font->descent; font->min_width = xfont->min_bounds.width; + font->max_width = xfont->max_bounds.width; if (xfont->min_bounds.width == xfont->max_bounds.width) { /* Fixed width font. */ diff --git a/src/xftfont.c b/src/xftfont.c index 2f8125393bc..5e60ab0c4d3 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -39,7 +39,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Xft font driver. */ -static Lisp_Object Qxft; +Lisp_Object Qxft; static Lisp_Object QChinting, QCautohint, QChintstyle, QCrgba, QCembolden, QClcdfilter; @@ -414,20 +414,25 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) ascii_printable[ch] = ' ' + ch; } BLOCK_INPUT; + + /* Unfortunately Xft doesn't provide a way to get minimum char + width. So, we set min_width to space_width. */ + if (spacing != FC_PROPORTIONAL #ifdef FC_DUAL && spacing != FC_DUAL #endif /* FC_DUAL */ ) { - font->min_width = font->average_width = font->space_width - = xftfont->max_advance_width; + font->min_width = font->max_width = font->average_width + = font->space_width = xftfont->max_advance_width; XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); } else { XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); - font->space_width = extents.xOff; + font->min_width = font->max_width = font->space_width + = extents.xOff; if (font->space_width <= 0) /* dirty workaround */ font->space_width = pixel_size; @@ -470,10 +475,6 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) #endif /* HAVE_LIBOTF */ xftfont_info->ft_size = ft_face->size; - /* Unfortunately Xft doesn't provide a way to get minimum char - width. So, we use space_width instead. */ - font->min_width = font->space_width; - font->baseline_offset = 0; font->relative_compose = 0; font->default_ascent = 0; @@ -764,6 +765,8 @@ syms_of_xftfont (void) DEFSYM (QCembolden, ":embolden"); DEFSYM (QClcdfilter, ":lcdfilter"); + ascii_printable[0] = 0; + xftfont_driver = ftfont_driver; xftfont_driver.type = Qxft; xftfont_driver.get_cache = xfont_driver.get_cache; diff --git a/src/xmenu.c b/src/xmenu.c index ab790094f85..54a7849218a 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1008,7 +1008,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) if (! NILP (Vlucid_menu_bar_dirty_flag)) call0 (Qrecompute_lucid_menubar); safe_run_hooks (Qmenu_bar_update_hook); - FSET (f, menu_bar_items, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); + fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); items = FRAME_MENU_BAR_ITEMS (f); @@ -1100,7 +1100,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) } /* The menu items are different, so store them in the frame. */ - FSET (f, menu_bar_vector, menu_items); + fset_menu_bar_vector (f, menu_items); f->menu_bar_items_used = menu_items_used; /* This undoes save_menu_items. */ @@ -1283,7 +1283,7 @@ initialize_frame_menubar (FRAME_PTR f) { /* This function is called before the first chance to redisplay the frame. It has to be, so the frame will have the right size. */ - FSET (f, menu_bar_items, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); + fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); set_frame_menubar (f, 1, 1); } diff --git a/src/xselect.c b/src/xselect.c index 664b5f92a15..463bd6e37b0 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -353,8 +353,9 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value, INTEGER_TO_CONS (timestamp), frame); prev_value = LOCAL_SELECTION (selection_name, dpyinfo); - TSET (dpyinfo->terminal, Vselection_alist, - Fcons (selection_data, dpyinfo->terminal->Vselection_alist)); + tset_selection_alist + (dpyinfo->terminal, + Fcons (selection_data, dpyinfo->terminal->Vselection_alist)); /* If we already owned the selection, remove the old selection data. Don't use Fdelq as that may QUIT. */ @@ -989,7 +990,7 @@ x_handle_selection_clear (struct input_event *event) break; } } - TSET (dpyinfo->terminal, Vselection_alist, Vselection_alist); + tset_selection_alist (dpyinfo->terminal, Vselection_alist); /* Run the `x-lost-selection-functions' abnormal hook. */ { @@ -1039,7 +1040,7 @@ x_clear_frame_selections (FRAME_PTR f) args[1] = Fcar (Fcar (t->Vselection_alist)); Frun_hook_with_args (2, args); - TSET (t, Vselection_alist, XCDR (t->Vselection_alist)); + tset_selection_alist (t, XCDR (t->Vselection_alist)); } /* Delete elements after the beginning of Vselection_alist. */ diff --git a/src/xterm.c b/src/xterm.c index 1b746f87d53..118c8767c23 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -50,7 +50,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "systime.h" #include <fcntl.h> -#include <ctype.h> #include <errno.h> #include <setjmp.h> #include <sys/stat.h> @@ -3585,7 +3584,7 @@ x_frame_rehighlight (struct x_display_info *dpyinfo) : dpyinfo->x_focus_frame); if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame)) { - FSET (dpyinfo->x_focus_frame, focus_frame, Qnil); + fset_focus_frame (dpyinfo->x_focus_frame, Qnil); dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame; } } @@ -5019,7 +5018,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height) bar->next = FRAME_SCROLL_BARS (f); bar->prev = Qnil; XSETVECTOR (barobj, bar); - FSET (f, scroll_bars, barobj); + fset_scroll_bars (f, barobj); if (!NILP (bar->next)) XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); @@ -5182,7 +5181,7 @@ x_scroll_bar_remove (struct scroll_bar *bar) #endif /* Dissociate this scroll bar from its window. */ - WSET (XWINDOW (bar->window), vertical_scroll_bar, Qnil); + wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil); UNBLOCK_INPUT; } @@ -5396,7 +5395,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio #endif /* not USE_TOOLKIT_SCROLL_BARS */ XSETVECTOR (barobj, bar); - WSET (w, vertical_scroll_bar, barobj); + wset_vertical_scroll_bar (w, barobj); } @@ -5420,12 +5419,12 @@ XTcondemn_scroll_bars (FRAME_PTR frame) { Lisp_Object bar; bar = FRAME_SCROLL_BARS (frame); - FSET (frame, scroll_bars, XSCROLL_BAR (bar)->next); + fset_scroll_bars (frame, XSCROLL_BAR (bar)->next); XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame); XSCROLL_BAR (bar)->prev = Qnil; if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame))) XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar; - FSET (frame, condemned_scroll_bars, bar); + fset_condemned_scroll_bars (frame, bar); } } @@ -5457,7 +5456,7 @@ XTredeem_scroll_bar (struct window *window) return; else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f), window->vertical_scroll_bar)) - FSET (f, condemned_scroll_bars, bar->next); + fset_condemned_scroll_bars (f, bar->next); else /* If its prev pointer is nil, it must be at the front of one or the other! */ @@ -5472,7 +5471,7 @@ XTredeem_scroll_bar (struct window *window) bar->next = FRAME_SCROLL_BARS (f); bar->prev = Qnil; XSETVECTOR (barobj, bar); - FSET (f, scroll_bars, barobj); + fset_scroll_bars (f, barobj); if (! NILP (bar->next)) XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); } @@ -5489,7 +5488,7 @@ XTjudge_scroll_bars (FRAME_PTR f) /* Clear out the condemned list now so we won't try to process any more events on the hapless scroll bars. */ - FSET (f, condemned_scroll_bars, Qnil); + fset_condemned_scroll_bars (f, Qnil); for (; ! NILP (bar); bar = next) { @@ -7835,7 +7834,7 @@ x_connection_closed (Display *dpy, const char *error_message) { /* Set this to t so that delete_frame won't get confused trying to find a replacement. */ - KSET (FRAME_KBOARD (XFRAME (frame)), Vdefault_minibuffer_frame, Qt); + kset_default_minibuffer_frame (FRAME_KBOARD (XFRAME (frame)), Qt); delete_frame (frame, Qnoelisp); } @@ -10115,7 +10114,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) { terminal->kboard = xmalloc (sizeof *terminal->kboard); init_kboard (terminal->kboard); - KSET (terminal->kboard, Vwindow_system, Qx); + kset_window_system (terminal->kboard, Qx); /* Add the keyboard to the list before running Lisp code (via Qvendor_specific_keysyms below), since these are not traced @@ -10137,9 +10136,10 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) /* Temporarily hide the partially initialized terminal. */ terminal_list = terminal->next_terminal; UNBLOCK_INPUT; - KSET (terminal->kboard, Vsystem_key_alist, - call1 (Qvendor_specific_keysyms, - vendor ? build_string (vendor) : empty_unibyte_string)); + kset_system_key_alist + (terminal->kboard, + call1 (Qvendor_specific_keysyms, + vendor ? build_string (vendor) : empty_unibyte_string)); BLOCK_INPUT; terminal->next_terminal = terminal_list; terminal_list = terminal; |