all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 18195@debbugs.gnu.org, dgutov@yandex.ru
Subject: bug#18195: 24.3.92; window-screen-lines is not accurate
Date: Tue, 05 Aug 2014 17:45:25 +0200	[thread overview]
Message-ID: <53E0FC15.4060502@gmx.at> (raw)
In-Reply-To: <83oavzotxz.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 4267 bytes --]

 > You'll need to designate a window anyway, since layout is impossible
 > without knowing in which window it will be done.

`window-text-pixel-size' works on any life window, by default the
selected.

 > There's also the issue of the buffer text on which the text will be
 > overlaid: the dimensions of the screen lines to be (partially)
 > overlaid affect the pixel dimensions of the overlaying text.  So if
 > the buffer text uses different fonts, the text overlaid on it will
 > have different dimensions than the same text when displayed in its own
 > buffer.

This would have to be done on the Lisp level by selecting some font
before calculating the size of the overlay.  But I have problems with
the attached patch.  If I invoke `window-text-pixel-size' with a
different buffer than that displayed in the window I get an arguments
out of range error.  Any ideas?

martin

A backtrace goes as follows:

#0  args_out_of_range (a1=..., a2=...) at data.c:217
#1  0x011eadda in validate_interval_range (object=..., begin=0x82b310, end=0x82b310, force=false) at textprop.c:182
#2  0x011ec8a4 in Ftext_properties_at (position=..., object=...) at textprop.c:601
#3  0x011ec931 in Fget_text_property (position=..., prop=..., object=...) at textprop.c:621
#4  0x010f5806 in face_at_buffer_position (w=0x17b8bf8, pos=82, endptr=0x82b438, limit=182, mouse=0, base_face_id=0) at xfaces.c:5976
#5  0x0102eb20 in handle_face_prop (it=0x82e180) at xdisp.c:3923
#6  0x0102db70 in handle_stop (it=0x82e180) at xdisp.c:3427
#7  0x0103a40c in next_element_from_buffer (it=0x82e180) at xdisp.c:8242
#8  0x01036f16 in get_next_display_element (it=0x82e180) at xdisp.c:6874
#9  0x0103aec6 in move_it_in_display_line_to (it=0x82e180, to_charpos=311, to_x=-1, op=MOVE_TO_POS) at xdisp.c:8582
#10 0x0103d080 in move_it_to (it=0x82e180, to_charpos=311, to_x=-1, to_y=-1, to_vpos=-1, op=10) at xdisp.c:9149
#11 0x0103ec0d in Fwindow_text_pixel_size (window=..., from=..., to=..., x_limit=..., y_limit=..., mode_and_header_line=..., buffer=...) at xdisp.c:9833
#12 0x0118d7f5 in eval_sub (form=...) at eval.c:2202
#13 0x0118cf36 in Feval (form=..., lexical=...) at eval.c:1996
#14 0x0118e9e6 in Ffuncall (nargs=3, args=0x82ebdc) at eval.c:2811
#15 0x011d01d6 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x82ef10) at bytecode.c:918
#16 0x0118f18c in funcall_lambda (fun=..., nargs=1, arg_vector=0x82ef0c) at eval.c:2976
#17 0x0118ebde in Ffuncall (nargs=2, args=0x82ef08) at eval.c:2857
#18 0x011d01d6 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x82f33c) at bytecode.c:918
#19 0x0118f18c in funcall_lambda (fun=..., nargs=1, arg_vector=0x82f338) at eval.c:2976
#20 0x0118ebde in Ffuncall (nargs=2, args=0x82f334) at eval.c:2857
#21 0x01186548 in Ffuncall_interactively (nargs=2, args=0x82f334) at callint.c:270
#22 0x0118e8ac in Ffuncall (nargs=3, args=0x82f330) at eval.c:2789
#23 0x01188170 in Fcall_interactively (function=..., record_flag=..., keys=...) at callint.c:872
#24 0x0118ea15 in Ffuncall (nargs=4, args=0x82f54c) at eval.c:2815
#25 0x011d01d6 in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x82f894) at bytecode.c:918
#26 0x0118f18c in funcall_lambda (fun=..., nargs=1, arg_vector=0x82f890) at eval.c:2976
#27 0x0118ebde in Ffuncall (nargs=2, args=0x82f88c) at eval.c:2857
#28 0x0118e4a5 in call1 (fn=..., arg1=...) at eval.c:2607
#29 0x010ffcee in command_loop_1 () at keyboard.c:1545
#30 0x0118b92a in internal_condition_case (bfun=0x10ff67c <command_loop_1>, handlers=..., hfun=0x10feee7 <cmd_error>) at eval.c:1347
#31 0x010ff332 in command_loop_2 (ignore=...) at keyboard.c:1169
#32 0x0118aede in internal_catch (tag=..., func=0x10ff30e <command_loop_2>, arg=...) at eval.c:1111
#33 0x010ff2ec in command_loop () at keyboard.c:1148
#34 0x010fea83 in recursive_edit_1 () at keyboard.c:769
#35 0x010fec40 in Frecursive_edit () at keyboard.c:840
#36 0x010fcdaf in main (argc=1, argv=0xa327e8) at emacs.c:1650

Lisp Backtrace:
"window-text-pixel-size" (0x82ea80)
"eval" (0x82ebe0)
"eval-last-sexp-1" (0x82ef0c)
"eval-last-sexp" (0x82f338)
"funcall-interactively" (0x82f334)
"call-interactively" (0x82f550)
"command-execute" (0x82f890)

[-- Attachment #2: window-text-pixel-size.diff --]
[-- Type: text/plain, Size: 2497 bytes --]

=== 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);



  reply	other threads:[~2014-08-05 15:45 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05  2:00 bug#18195: 24.3.92; window-screen-lines is not accurate Dmitry
2014-08-05  8:38 ` martin rudalics
2014-08-05 10:03   ` Dmitry Gutov
2014-08-05 10:16     ` martin rudalics
2014-08-05 10:24       ` Dmitry Gutov
2014-08-05 12:20         ` martin rudalics
2014-08-05 13:05           ` Dmitry Gutov
2014-08-05 13:50             ` martin rudalics
2014-08-05 14:06               ` Eli Zaretskii
2014-08-06 11:55               ` Dmitry Gutov
2014-08-06 16:13                 ` martin rudalics
2014-08-05 14:01             ` Eli Zaretskii
2014-08-05 13:58           ` Eli Zaretskii
2014-08-05 14:08             ` martin rudalics
2014-08-05 14:13               ` Eli Zaretskii
2014-08-05 13:57         ` Eli Zaretskii
2014-08-05 13:51       ` Eli Zaretskii
2014-08-05 13:57         ` martin rudalics
2014-08-05 14:09           ` Eli Zaretskii
2014-08-05 14:12             ` martin rudalics
2014-08-05 14:23               ` Eli Zaretskii
2014-08-05 14:38                 ` martin rudalics
2014-08-05 15:08                   ` Eli Zaretskii
2014-08-05 15:45                     ` martin rudalics [this message]
2014-08-05 17:57                       ` Eli Zaretskii
2014-08-06  9:41                         ` martin rudalics
2014-08-06 14:39                           ` Eli Zaretskii
2014-08-06 14:41                             ` Dmitry Gutov
2014-08-06 16:23                               ` Eli Zaretskii
2014-08-06 16:26                                 ` Dmitry Gutov
2014-08-06 17:24                                   ` Eli Zaretskii
2014-08-06 18:02                                     ` Dmitry Gutov
2014-08-06 18:36                                       ` Eli Zaretskii
2014-08-06 21:09                                         ` Dmitry Gutov
2014-08-06 16:15                             ` martin rudalics
2014-08-06 16:30                               ` Eli Zaretskii
2014-08-06 17:46                                 ` martin rudalics
2014-08-06 18:03                                   ` Eli Zaretskii
2014-08-07 15:08                                     ` martin rudalics
2014-08-07 15:35                                       ` Eli Zaretskii
2014-08-07 15:39                                         ` martin rudalics
2014-08-07 16:36                                           ` Eli Zaretskii
2014-08-08  8:41                                             ` martin rudalics
2014-08-08  9:16                                               ` Eli Zaretskii
2014-08-08 10:10                                                 ` martin rudalics
2014-08-08 10:25                                                   ` Eli Zaretskii
2014-08-05 13:46     ` Eli Zaretskii
2014-08-05 21:21       ` Dmitry Gutov
2014-08-06  2:52         ` Eli Zaretskii
2014-08-06 12:09           ` Dmitry Gutov
2014-08-06 14:45             ` Eli Zaretskii
2014-08-06 15:07               ` Dmitry Gutov
2014-08-06 16:25                 ` Eli Zaretskii
2014-08-06 16:37                   ` Dmitry Gutov
2014-08-06 17:26                     ` Eli Zaretskii
2014-08-06 12:40           ` Layered display API (was: bug#18195: 24.3.92; window-screen-lines is not accurate) Dmitry Gutov
2014-08-06 17:19             ` Eli Zaretskii
2014-08-06 18:20               ` Alp Aker
2014-08-06 18:39                 ` Eli Zaretskii
2014-08-06 20:48                   ` Layered display API Stefan Monnier
2014-08-07  2:45                     ` Eli Zaretskii
2014-08-06 20:49               ` Dmitry Gutov
2014-08-07 15:39                 ` Eli Zaretskii
2014-08-11  1:14                   ` Dmitry Gutov
2014-08-11 15:01                     ` Eli Zaretskii
2014-08-13  2:42                       ` Dmitry Gutov
2014-08-13 12:46                         ` Stefan Monnier
2014-08-13 15:29                           ` Eli Zaretskii
2014-08-13 16:27                           ` Dmitry Gutov
2014-08-13 17:07                             ` Eli Zaretskii
2014-08-13 17:45                             ` Stefan Monnier
2014-08-13 15:28                         ` Eli Zaretskii
2014-08-14  2:35                           ` Dmitry Gutov
2014-08-14  2:53                             ` Eli Zaretskii
2014-08-14 13:12                               ` Dmitry Gutov
2014-08-14 15:20                                 ` Eli Zaretskii
2014-08-15  1:20                                   ` Dmitry Gutov
2014-08-15  6:39                                     ` Eli Zaretskii
2014-08-15 23:03                                       ` Dmitry Gutov
2014-08-16  7:41                                         ` Eli Zaretskii
2014-08-16  9:17                                           ` Dmitry Gutov
2014-08-14  2:06                       ` Bo Lin
2014-08-14  2:49                         ` Eli Zaretskii
2014-08-14 16:08                           ` Bo Lin
2014-08-14 16:19                             ` Eli Zaretskii
2014-08-14 16:42                               ` Bo Lin
2014-08-06 20:56               ` Stefan Monnier
2014-08-05 13:35 ` bug#18195: 24.3.92; window-screen-lines is not accurate Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53E0FC15.4060502@gmx.at \
    --to=rudalics@gmx.at \
    --cc=18195@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.