From 07e47aad41e6d350b13531bf8a5eebd042f34794 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 15 Dec 2014 15:41:11 -0500 Subject: [PATCH] * src/: Various fixes to use bool type and constants. * src/dispnew.c (update_single_window): Remove arg `force_p' since it's always true. * src/xfaces.c (clear_face_cache): Use bool for the argument type. --- src/ChangeLog | 31 +++++++++++++++------------ src/callproc.c | 6 +++--- src/dispextern.h | 10 ++++----- src/dispnew.c | 28 ++++++++++++++----------- src/keyboard.c | 8 +++---- src/minibuf.c | 4 ++-- src/process.c | 8 +++---- src/w32fns.c | 4 ++-- src/window.c | 8 +++---- src/xdisp.c | 54 ++++++++++++++++++++++++------------------------ src/xfaces.c | 2 +- src/xfns.c | 4 ++-- 12 files changed, 88 insertions(+), 79 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5ce56f4df04..596ae25c649 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-12-15 Stefan Monnier + + Various fixes to use bool type and constants. + * dispnew.c (update_single_window): Remove arg `force_p' since it's + always true. + * xfaces.c (clear_face_cache): Use bool for the argument type. + 2014-12-15 Paul Eggert Correct same_at_end when restoring window points @@ -10,14 +17,12 @@ New feature optionally to accelerate auto-repeated scrolling. - * xdisp.c: Remove "static" from declaration of - Qfontification_functions. + * xdisp.c: Remove "static" from declaration of Qfontification_functions. - * window.c (window_scroll): bind fontification-functions to nil + * window.c (window_scroll): Bind fontification-functions to nil when scrolling by whole screens and fast-but-imprecise-scrolling is non-nil. - (syms_of_window): New DEFVAR_BOOL - fast-but-imprecise-scrolling. + (syms_of_window): New DEFVAR_BOOL fast-but-imprecise-scrolling. * lisp.h (bool): Declare Qfontification_functions extern. @@ -28,10 +33,10 @@ [GNUTLS >= 3.0.20]: Declare for WINDOWSNT. (init_gnutls_functions)(gnutls_certificate_set_x509_system_trust) [GNUTLS >= 3.0.20]: Load from shared library for WINDOWSNT. - (fn_gnutls_certificate_set_x509_system_trust) [!WINDOWSNT]: Define - new macro. - (Fgnutls_boot) [GNUTLS >= 3.0.20]: Call - gnutls_certificate_set_x509_system_trust. Log an error message if + (fn_gnutls_certificate_set_x509_system_trust) [!WINDOWSNT]: + Define new macro. + (Fgnutls_boot) [GNUTLS >= 3.0.20]: + Call gnutls_certificate_set_x509_system_trust. Log an error message if it fails. 2014-12-13 Paul Eggert @@ -41,8 +46,8 @@ 2014-12-13 Eli Zaretskii - * gnutls.c (Fgnutls_available_p, syms_of_gnutls): Move - gnutls-available-p out of the HAVE_GNUTLS conditional, and define + * gnutls.c (Fgnutls_available_p, syms_of_gnutls): + Move gnutls-available-p out of the HAVE_GNUTLS conditional, and define them only once. 2014-12-13 Teodor Zlatanov @@ -58,8 +63,8 @@ 2014-12-13 Eli Zaretskii - * xdisp.c (move_it_in_display_line_to, display_line): Don't - disallow overflow-newline-into-fringe when word-wrap is in + * xdisp.c (move_it_in_display_line_to, display_line): + Don't disallow overflow-newline-into-fringe when word-wrap is in effect. (Bug#19300) 2014-12-11 Stefan Monnier diff --git a/src/callproc.c b/src/callproc.c index 24b88551851..a677334b3b7 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -852,7 +852,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, (process_coding.dst_pos_byte + process_coding.produced), 0); - display_on_the_fly = 0; + display_on_the_fly = false; process_coding = saved_coding; carryover = nread; /* Make the above condition always fail in the future. */ @@ -884,9 +884,9 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, /* This variable might have been set to 0 for code detection. In that case, set it back to 1 because we should have already detected a coding system. */ - display_on_the_fly = 1; + display_on_the_fly = true; } - immediate_quit = 1; + immediate_quit = true; QUIT; } give_up: ; diff --git a/src/dispextern.h b/src/dispextern.h index 5510a1f50c1..8fd3ef935f6 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3371,7 +3371,7 @@ void x_free_colors (struct frame *, unsigned long *, int); void update_face_from_frame_parameter (struct frame *, Lisp_Object, Lisp_Object); Lisp_Object tty_color_name (struct frame *, int); -void clear_face_cache (int); +void clear_face_cache (bool); unsigned long load_color (struct frame *, struct face *, Lisp_Object, enum lface_attribute_index); char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object, @@ -3444,11 +3444,11 @@ extern void cancel_hourglass (void); #endif /* HAVE_WINDOW_SYSTEM */ -/* Defined in xmenu.c */ +/* Defined in xmenu.c. */ int popup_activated (void); -/* Defined in dispnew.c */ +/* Defined in dispnew.c. */ extern Lisp_Object buffer_posn_from_coords (struct window *, int *, int *, @@ -3484,7 +3484,7 @@ void blank_row (struct window *, struct glyph_row *, int); void clear_glyph_matrix_rows (struct glyph_matrix *, int, int); void clear_glyph_row (struct glyph_row *); void prepare_desired_row (struct window *, struct glyph_row *, bool); -void update_single_window (struct window *, bool); +void update_single_window (struct window *); void do_pending_window_change (bool); void change_frame_size (struct frame *, int, int, bool, bool, bool, bool); void init_display (void); @@ -3493,7 +3493,7 @@ extern Lisp_Object Qredisplay_dont_pause; extern void spec_glyph_lookup_face (struct window *, GLYPH *); extern void fill_up_frame_row_with_spaces (struct glyph_row *, int); -/* Defined in terminal.c */ +/* Defined in terminal.c. */ extern void ring_bell (struct frame *); extern void update_begin (struct frame *); diff --git a/src/dispnew.c b/src/dispnew.c index d50d06f2d47..a68901acd57 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3051,10 +3051,10 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p) struct window *root_window = XWINDOW (f->root_window); if (redisplay_dont_pause) - force_p = 1; + force_p = true; else if (!force_p && detect_input_pending_ignore_squeezables ()) { - paused_p = 1; + paused_p = true; goto do_pause; } @@ -3074,7 +3074,7 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p) /* Update the menu bar on X frames that don't have toolkit support. */ if (WINDOWP (f->menu_bar_window)) - update_window (XWINDOW (f->menu_bar_window), 1); + update_window (XWINDOW (f->menu_bar_window), true); #endif #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS) @@ -3088,7 +3088,7 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p) { Lisp_Object tem; - update_window (w, 1); + update_window (w, true); w->must_be_updated_p = false; /* Swap tool-bar strings. We swap because we want to @@ -3113,7 +3113,7 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p) /* Build F's desired matrix from window matrices. */ build_frame_matrix (f); - /* Update the display */ + /* Update the display. */ update_begin (f); paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p, 1); update_end (f); @@ -3225,7 +3225,7 @@ update_window_tree (struct window *w, bool force_p) If FORCE_P, don't stop updating if input is pending. */ void -update_single_window (struct window *w, bool force_p) +update_single_window (struct window *w) { if (w->must_be_updated_p) { @@ -3234,12 +3234,9 @@ update_single_window (struct window *w, bool force_p) /* Record that this is not a frame-based redisplay. */ set_frame_matrix_frame (NULL); - if (redisplay_dont_pause) - force_p = 1; - /* Update W. */ update_begin (f); - update_window (w, force_p); + update_window (w, true); update_end (f); /* Reset flag in W. */ @@ -6267,8 +6264,15 @@ See `buffer-display-table' for more information. */); Vstandard_display_table = Qnil; DEFVAR_BOOL ("redisplay-dont-pause", redisplay_dont_pause, - doc: /* Non-nil means display update isn't paused when input is detected. */); - redisplay_dont_pause = 1; + doc: /* Nil means display update is paused when input is detected. */); + /* Contrary to expectations, a value of "false" can be detrimental to + responsiveness since aborting a redisplay throws away some of the + work already performed. It's usually more efficient (and gives + more prompt feedback to the user) to let the redisplay terminate, + and just completely skip the next command's redisplay (which is + done regardless of this setting if there's pending input at the + beginning of the next redisplay). */ + redisplay_dont_pause = true; #ifdef CANNOT_DUMP if (noninteractive) diff --git a/src/keyboard.c b/src/keyboard.c index 6dc0b820eb9..beb34592d1c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -270,7 +270,7 @@ static Lisp_Object Qhelp_form_show; /* File in which we write all commands we read. */ static FILE *dribble; -/* Nonzero if input is available. */ +/* True if input is available. */ bool input_pending; /* Circular buffer for pre-read keyboard input. */ @@ -2403,9 +2403,9 @@ echo_keystrokes_p (void) /* commandflag 0 means do not autosave, but do redisplay. -1 means do not redisplay, but do autosave. -2 means do neither. - 1 means do both. */ + 1 means do both. -/* The argument MAP is a keymap for menu prompting. + The argument MAP is a keymap for menu prompting. PREV_EVENT is the previous input event, or nil if we are reading the first event of a key sequence (or not reading a key sequence). @@ -3878,7 +3878,7 @@ kbd_buffer_get_event (KBOARD **kbp, Lisp_Object obj; #ifdef subprocesses - if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4) + if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE / 4) { /* Start reading input again because we have processed enough to be able to accept new events again. */ diff --git a/src/minibuf.c b/src/minibuf.c index 0b455157d52..27b5f7b7f36 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -713,8 +713,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, { XWINDOW (minibuf_window)->cursor.hpos = 0; XWINDOW (minibuf_window)->cursor.x = 0; - XWINDOW (minibuf_window)->must_be_updated_p = 1; - update_frame (XFRAME (selected_frame), 1, 1); + XWINDOW (minibuf_window)->must_be_updated_p = true; + update_frame (XFRAME (selected_frame), true, true); flush_frame (XFRAME (XWINDOW (minibuf_window)->frame)); } diff --git a/src/process.c b/src/process.c index 7283df4147b..e59ca5863d5 100644 --- a/src/process.c +++ b/src/process.c @@ -4323,7 +4323,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, while (1) { - bool timeout_reduced_for_timers = 0; + bool timeout_reduced_for_timers = false; /* If calling from keyboard input, do not quit since we want to return C-g as an input character. @@ -4410,7 +4410,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (timespec_cmp (timer_delay, timeout) < 0) { timeout = timer_delay; - timeout_reduced_for_timers = 1; + timeout_reduced_for_timers = true; } } else @@ -6669,7 +6669,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, while (1) { - bool timeout_reduced_for_timers = 0; + bool timeout_reduced_for_timers = false; fd_set waitchannels; int xerrno; @@ -6736,7 +6736,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (timespec_cmp (timer_delay, timeout) < 0) { timeout = timer_delay; - timeout_reduced_for_timers = 1; + timeout_reduced_for_timers = true; } } } diff --git a/src/w32fns.c b/src/w32fns.c index fc10e74cdff..17633708049 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -6252,8 +6252,8 @@ Text larger than the specified size is clipped. */) } /* Draw into the window. */ - w->must_be_updated_p = 1; - update_single_window (w, 1); + w->must_be_updated_p = true; + update_single_window (w); unblock_input (); diff --git a/src/window.c b/src/window.c index 0b766649b17..ca2bc74fcf4 100644 --- a/src/window.c +++ b/src/window.c @@ -7352,7 +7352,7 @@ the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */ doc: /* Non-nil means to use `mode-line-inactive' face in non-selected windows. If the minibuffer is active, the `minibuffer-scroll-window' mode line is displayed in the `mode-line' face. */); - mode_line_in_non_selected_windows = 1; + mode_line_in_non_selected_windows = true; DEFVAR_LISP ("other-window-scroll-buffer", Vother_window_scroll_buffer, doc: /* If this is a live buffer, \\[scroll-other-window] should scroll its window. */); @@ -7360,7 +7360,7 @@ is displayed in the `mode-line' face. */); DEFVAR_BOOL ("auto-window-vscroll", auto_window_vscroll_p, doc: /* Non-nil means to automatically adjust `window-vscroll' to view tall lines. */); - auto_window_vscroll_p = 1; + auto_window_vscroll_p = true; DEFVAR_INT ("next-screen-context-lines", next_screen_context_lines, doc: /* Number of lines of continuity when scrolling by screenfuls. */); @@ -7483,7 +7483,7 @@ all functions that symmetrically resize a parent window. Note that when a frame's pixel size is not a multiple of the frame's character size, at least one window may get resized pixelwise even if this option is nil. */); - window_resize_pixelwise = 0; + window_resize_pixelwise = false; DEFVAR_BOOL ("fast-but-imprecise-scrolling", Vfast_but_imprecise_scrolling, @@ -7494,7 +7494,7 @@ are actually going to be displayed get fontified. Note that this optimization can cause the portion of the buffer displayed after a scrolling operation to be somewhat inaccurate. */); - Vfast_but_imprecise_scrolling = 0; + Vfast_but_imprecise_scrolling = false; defsubr (&Sselected_window); defsubr (&Sminibuffer_window); diff --git a/src/xdisp.c b/src/xdisp.c index 48a2979dcde..0e3e1a2bb69 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -905,7 +905,7 @@ static void iterate_out_of_display_property (struct it *); static void pop_it (struct it *); static void sync_frame_with_window_matrix_rows (struct window *); static void redisplay_internal (void); -static int echo_area_display (int); +static bool echo_area_display (bool); static void redisplay_windows (Lisp_Object); static void redisplay_window (Lisp_Object, bool); static Lisp_Object redisplay_window_error (Lisp_Object); @@ -10275,9 +10275,9 @@ message3_nolog (Lisp_Object m) else clear_message (true, true); - do_pending_window_change (0); - echo_area_display (1); - do_pending_window_change (0); + do_pending_window_change (false); + echo_area_display (true); + do_pending_window_change (false); if (FRAME_TERMINAL (f)->frame_up_to_date_hook) (*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f); } @@ -11248,13 +11248,13 @@ clear_garbaged_frames (void) is non-zero update selected_frame. Value is non-zero if the mini-windows height has been changed. */ -static int -echo_area_display (int update_frame_p) +static bool +echo_area_display (bool update_frame_p) { Lisp_Object mini_window; struct window *w; struct frame *f; - int window_height_changed_p = 0; + bool window_height_changed_p = false; struct frame *sf = SELECTED_FRAME (); mini_window = FRAME_MINIBUF_WINDOW (sf); @@ -11317,11 +11317,11 @@ echo_area_display (int update_frame_p) /* Window configuration is the same as before. Can do with a display update of the echo area, unless we displayed some mode lines. */ - update_single_window (w, 1); + update_single_window (w); flush_frame (f); } else - update_frame (f, 1, 1); + update_frame (f, true, true); /* If cursor is in the echo area, make sure that the next redisplay displays the minibuffer, so that the cursor will @@ -13435,7 +13435,7 @@ redisplay_internal (void) struct window *w = XWINDOW (selected_window); struct window *sw; struct frame *fr; - int pending; + bool pending; bool must_finish = 0, match_p; struct text_pos tlbufpos, tlendpos; int number_of_visible_frames; @@ -13495,7 +13495,7 @@ redisplay_internal (void) /* Remember the currently selected window. */ sw = w; - pending = 0; + pending = false; last_escape_glyph_frame = NULL; last_escape_glyph_face_id = (1 << FACE_ID_BITS); last_glyphless_glyph_frame = NULL; @@ -13547,7 +13547,7 @@ redisplay_internal (void) } /* Notice any pending interrupt request to change frame size. */ - do_pending_window_change (1); + do_pending_window_change (true); /* do_pending_window_change could change the selected_window due to frame resizing which makes the selected window too small. */ @@ -13594,7 +13594,7 @@ redisplay_internal (void) echo-area doesn't show through. */ && !MINI_WINDOW_P (XWINDOW (selected_window)))) { - int window_height_changed_p = echo_area_display (0); + int window_height_changed_p = echo_area_display (false); if (message_cleared_p) update_miniwindow_p = true; @@ -13802,7 +13802,7 @@ redisplay_internal (void) { if (!must_finish) { - do_pending_window_change (1); + do_pending_window_change (true); /* If selected_window changed, redisplay again. */ if (WINDOWP (selected_window) && (w = XWINDOW (selected_window)) != sw) @@ -13919,14 +13919,14 @@ redisplay_internal (void) if (f->fonts_changed) { adjust_frame_glyphs (f); - f->fonts_changed = 0; + f->fonts_changed = false; goto retry_frame; } /* See if we have to hscroll. */ if (!f->already_hscrolled_p) { - f->already_hscrolled_p = 1; + f->already_hscrolled_p = true; if (hscroll_windows (f->root_window)) goto retry_frame; } @@ -13938,9 +13938,9 @@ redisplay_internal (void) unrequest_sigio (); STOP_POLLING; - pending |= update_frame (f, 0, 0); - f->cursor_type_changed = 0; - f->updated_p = 1; + pending |= update_frame (f, false, false); + f->cursor_type_changed = false; + f->updated_p = true; } } } @@ -14001,8 +14001,8 @@ redisplay_internal (void) goto retry; XWINDOW (selected_window)->must_be_updated_p = true; - pending = update_frame (sf, 0, 0); - sf->cursor_type_changed = 0; + pending = update_frame (sf, false, false); + sf->cursor_type_changed = false; } /* We may have called echo_area_display at the top of this @@ -14016,8 +14016,8 @@ redisplay_internal (void) if (mini_frame != sf && FRAME_WINDOW_P (mini_frame)) { XWINDOW (mini_window)->must_be_updated_p = true; - pending |= update_frame (mini_frame, 0, 0); - mini_frame->cursor_type_changed = 0; + pending |= update_frame (mini_frame, false, false); + mini_frame->cursor_type_changed = false; if (!pending && hscroll_windows (mini_window)) goto retry; } @@ -14094,7 +14094,7 @@ redisplay_internal (void) } /* Change frame size now if a change is pending. */ - do_pending_window_change (1); + do_pending_window_change (true); /* If we just did a pending size change, or have additional visible frames, or selected_window changed, redisplay again. */ @@ -14110,7 +14110,7 @@ redisplay_internal (void) if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT) { - clear_face_cache (0); + clear_face_cache (false); clear_face_cache_count = 0; } @@ -14154,9 +14154,9 @@ redisplay_preserve_echo_area (int from_where) { /* We have a previously displayed message, but no current message. Redisplay the previous message. */ - display_last_displayed_message_p = 1; + display_last_displayed_message_p = true; redisplay_internal (); - display_last_displayed_message_p = 0; + display_last_displayed_message_p = false; } else redisplay_internal (); diff --git a/src/xfaces.c b/src/xfaces.c index 446107ef3b7..fbdd3c8bfe8 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -732,7 +732,7 @@ recompute_basic_faces (struct frame *f) try to free unused fonts, too. */ void -clear_face_cache (int clear_fonts_p) +clear_face_cache (bool clear_fonts_p) { #ifdef HAVE_WINDOW_SYSTEM Lisp_Object tail, frame; diff --git a/src/xfns.c b/src/xfns.c index 59715d0718e..1b17311f99c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5577,8 +5577,8 @@ Text larger than the specified size is clipped. */) unblock_input (); /* Draw into the window. */ - w->must_be_updated_p = 1; - update_single_window (w, 1); + w->must_be_updated_p = true; + update_single_window (w); /* Restore original current buffer. */ set_buffer_internal_1 (old_buffer); -- 2.39.2