=== modified file 'src/xdisp.c' --- src/xdisp.c 2014-08-01 13:10:07 +0000 +++ src/xdisp.c 2014-08-05 15:28:23 +0000 @@ -9713,7 +9713,7 @@ && it->dpvec + it->current.dpvec_index != it->dpend); } -DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pixel_size, 0, 6, 0, +DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pixel_size, 0, 7, 0, doc: /* Return the size of the text of WINDOW's buffer in pixels. WINDOW must be a live window and defaults to the selected one. The return value is a cons of the maximum pixel-width of any text line and @@ -9746,9 +9746,13 @@ include the height of the mode- or header-line of WINDOW in the return value. If it is either the symbol `mode-line' or `header-line', include only the height of that line, if present, in the return value. If t, -include the height of both, if present, in the return value. */) +include the height of both, if present, in the return value. + +Optional argument BUFFER, if non-nil, means to work on another buffer +than that displayed in WINDOW. If BUFFER denotes a live buffer, use +that buffer. If BUFFER equals t, use the current buffer. */) (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit, Lisp_Object y_limit, - Lisp_Object mode_and_header_line) + Lisp_Object mode_and_header_line, Lisp_Object buffer) { struct window *w = decode_live_window (window); Lisp_Object buf; @@ -9760,14 +9764,25 @@ void *itdata = NULL; int c, max_y = -1, x = 0, y = 0; - buf = w->contents; - CHECK_BUFFER (buf); - b = XBUFFER (buf); - - if (b != current_buffer) + if (!EQ (buffer, Qt)) { - old_buffer = current_buffer; - set_buffer_internal (b); + if (NILP (buffer)) + { + buf = w->contents; + CHECK_BUFFER (buf); + b = XBUFFER (buf); + } + else + { + CHECK_BUFFER (buffer); + b = XBUFFER (buffer); + } + + if (b != current_buffer) + { + old_buffer = current_buffer; + set_buffer_internal (b); + } } if (NILP (from)) @@ -15814,6 +15829,17 @@ left. */ whole = max (whole, w->hscroll + box_width); whole = max (whole, end - start); + if (it.bidi_p) + { + Lisp_Object pdir; + + pdir = Fcurrent_bidi_paragraph_direction (Qnil); + if (EQ (pdir, Qright_to_left)) + { + end = whole - w->hscroll * FRAME_COLUMN_WIDTH (WINDOW_XFRAME (w)); + start = end - box_width; + } + } if (old_buffer) set_buffer_internal (old_buffer);