]> git.eshelyaron.com Git - emacs.git/commitdiff
Add comments for forced L2R directions of menu bar and tool bar.
authorEli Zaretskii <eliz@gnu.org>
Sat, 18 Jun 2011 20:17:29 +0000 (23:17 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 18 Jun 2011 20:17:29 +0000 (23:17 +0300)
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.

lisp/ChangeLog
lisp/buff-menu.el
src/ChangeLog
src/bidi.c
src/xdisp.c

index 50c3022ba0a3fc68098c1e24cd63c9afc4b9da90..ccfff5452931c789fc55232ff54029f0e32f733d 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-18  Eli Zaretskii  <eliz@gnu.org>
+
+       * buff-menu.el (Buffer-menu-mode, list-buffers-noselect): Force
+       left-to-right paragraph direction.
+
 2011-05-10  Glenn Morris  <rgm@gnu.org>
           Stefan Monnier  <monnier@iro.umontreal.ca>
 
index 9886b30d122a29942525d020b87e1daa3fc43c99..cd1c8d712436081d505c24697ef87f442b1b0c3f 100644 (file)
@@ -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).
index 2ebd593d00e8012689b1d97e47bd2239f928ea1f..37e1e85219f4a492659d53cb0d0c7df2d8f69f27 100644 (file)
@@ -1,5 +1,12 @@
 2011-06-18  Eli Zaretskii  <eliz@gnu.org>
 
+       * 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.
index ac01f65bf4efa2933a6925ce76474c8be7023581..61de1fc7b5f15a1e6316a5fb2b3a824ac01441ac 100644 (file)
@@ -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
index 7aafab4f32cc7ae6045b38e3845a34e546fc85e7..74afa80ada72f8bc918cc749d70c84c9397d016f 100644 (file)
@@ -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;