From: Eli Zaretskii Date: Sat, 18 Jun 2011 20:17:29 +0000 (+0300) Subject: Add comments for forced L2R directions of menu bar and tool bar. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=acb288185281f8030279fd81705bb54fa16ca84a;p=emacs.git Add comments for forced L2R directions of menu bar and tool bar. GCPRO Lisp string inside bidi.c. Force L2R direction in buffer menu buffer. src/xdisp.c (tool_bar_lines_needed, redisplay_tool_bar) (display_menu_bar): Force left-to-right direction. Add a FIXME comment for making that be controlled by a user option. src/bidi.c (bidi_move_to_visually_next): GCPRO the Lisp string we are iterating. lisp/buff-menu.el (Buffer-menu-mode, list-buffers-noselect): Force left-to-right paragraph direction. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 50c3022ba0a..ccfff545293 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-06-18 Eli Zaretskii + + * buff-menu.el (Buffer-menu-mode, list-buffers-noselect): Force + left-to-right paragraph direction. + 2011-05-10 Glenn Morris Stefan Monnier diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index 9886b30d122..cd1c8d71243 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -266,7 +266,10 @@ Letters do not insert themselves; instead, they are commands. (set (make-local-variable 'buffer-stale-function) (lambda (&optional _noconfirm) 'fast)) (setq truncate-lines t) - (setq buffer-read-only t)) + (setq buffer-read-only t) + ;; Force L2R direction, to avoid messing the display if the first + ;; buffer in the list happens to begin with a string R2L character. + (setq bidi-paragraph-direction 'left-to-right)) (define-obsolete-variable-alias 'buffer-menu-mode-hook 'Buffer-menu-mode-hook "23.1") @@ -805,6 +808,10 @@ For more information, see the function `buffer-menu'." (setq buffer-read-only nil) (erase-buffer) (setq standard-output (current-buffer)) + ;; Force L2R direction, to avoid messing the display if the + ;; first buffer in the list happens to begin with a string R2L + ;; character. + (setq bidi-paragraph-direction 'left-to-right) (unless Buffer-menu-use-header-line ;; Use U+2014 (EM DASH) to underline if possible, else use ASCII ;; (i.e. U+002D, HYPHEN-MINUS). diff --git a/src/ChangeLog b/src/ChangeLog index 2ebd593d00e..37e1e85219f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2011-06-18 Eli Zaretskii + * xdisp.c (tool_bar_lines_needed, redisplay_tool_bar) + (display_menu_bar): Force left-to-right direction. Add a FIXME + comment for making that be controlled by a user option. + + * bidi.c (bidi_move_to_visually_next): GCPRO the Lisp string we + are iterating. + * term.c (produce_glyphs): Add IT_GLYPHLESS to the values of it->what accepted by the xassert. Fixes a gratuitous crash in an Emacs built with -DXASSERTS. diff --git a/src/bidi.c b/src/bidi.c index ac01f65bf4e..61de1fc7b5f 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1927,6 +1927,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) { int old_level, new_level, next_level; struct bidi_it sentinel; + struct gcpro gcpro1; if (bidi_it->charpos < 0 || bidi_it->bytepos < 0) abort (); @@ -1936,6 +1937,11 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) bidi_it->scan_dir = 1; /* default to logical order */ } + /* The code below can call eval, and thus cause GC. If we are + iterating a Lisp string, make sure it won't GCed. */ + if (STRINGP (bidi_it->string.lstring)) + GCPRO1 (bidi_it->string.lstring); + /* If we just passed a newline, initialize for the next line. */ if (!bidi_it->first_elt && bidi_it->orig_type == NEUTRAL_B) bidi_line_init (bidi_it); @@ -2061,6 +2067,9 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) else bidi_cache_iterator_state (bidi_it, 1); } + + if (STRINGP (bidi_it->string.lstring)) + UNGCPRO; } /* This is meant to be called from within the debugger, whenever you diff --git a/src/xdisp.c b/src/xdisp.c index 7aafab4f32c..74afa80ada7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10796,7 +10796,7 @@ display_tool_bar_line (struct it *it, int height) ++i; } - /* Stop at line ends. */ + /* Stop at line end. */ if (ITERATOR_AT_END_OF_LINE_P (it)) break; @@ -10879,6 +10879,7 @@ tool_bar_lines_needed (struct frame *f, int *n_rows) it.first_visible_x = 0; it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f); reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1); + it.paragraph_embedding = L2R; while (!ITERATOR_AT_END_P (&it)) { @@ -10961,6 +10962,14 @@ redisplay_tool_bar (struct frame *f) /* Build a string that represents the contents of the tool-bar. */ build_desired_tool_bar_string (f); reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1); + /* FIXME: This should be controlled by a user option. But it + doesn't make sense to have an R2L tool bar if the menu bar cannot + be drawn also R2L, and making the menu bar R2L is tricky due to + unibyte strings it uses and toolkit-specific code that implements + it. If an R2L tool bar is ever supported, display_tool_bar_line + should also be augmented to call unproduce_glyphs like + display_line and display_string do. */ + it.paragraph_embedding = L2R; if (f->n_tool_bar_rows == 0) { @@ -18656,6 +18665,11 @@ display_menu_bar (struct window *w) } #endif /* not USE_X_TOOLKIT */ + /* FIXME: This should be controlled by a user option. See the + comments in redisplay_tool_bar and display_mode_line about + this. */ + it.paragraph_embedding = L2R; + if (! mode_line_inverse_video) /* Force the menu-bar to be displayed in the default face. */ it.base_face_id = it.face_id = DEFAULT_FACE_ID;