From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dick Newsgroups: gmane.emacs.bugs Subject: bug#52676: 28.0.50; [PATCH] Rationalize window-text-pixel-size Date: Sun, 19 Dec 2021 21:32:15 -0500 Message-ID: <87wnk0xaz4.fsf@dick> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14444"; mail-complaints-to="usenet@ciao.gmane.io" To: 52676@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 20 03:33:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mz8UC-0003Zb-MQ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Dec 2021 03:33:12 +0100 Original-Received: from localhost ([::1]:49022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mz8UB-00075F-MK for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Dec 2021 21:33:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mz8U2-00074z-64 for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2021 21:33:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mz8U1-0007tW-U9 for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2021 21:33:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mz8U1-0000Fp-Rt for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2021 21:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: dick Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Dec 2021 02:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52676 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.1639967546932 (code B ref -1); Mon, 20 Dec 2021 02:33:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Dec 2021 02:32:26 +0000 Original-Received: from localhost ([127.0.0.1]:48588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mz8TQ-0000Ew-J8 for submit@debbugs.gnu.org; Sun, 19 Dec 2021 21:32:25 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:50254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mz8TN-0000En-KZ for submit@debbugs.gnu.org; Sun, 19 Dec 2021 21:32:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mz8TN-0006n2-5v for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2021 21:32:21 -0500 Original-Received: from [2607:f8b0:4864:20::732] (port=34658 helo=mail-qk1-x732.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mz8TJ-0007pp-Mv for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2021 21:32:20 -0500 Original-Received: by mail-qk1-x732.google.com with SMTP id t6so8109429qkg.1 for ; Sun, 19 Dec 2021 18:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=EPMebf/VFZ78zkEbFBK6Q6zE4gZLxtYb5jfNhp6Lq5g=; b=FQpQD4VikSjeS3pXh5cQYWtkff3pSRQvA4D5Np0Nk2eN8JhD3oGNfY9F0IOJTnR3OZ e/8npP4gelcCXNkyTUpKNkB70rY6MtB0/Ug479REptsSPZAYcNNS4TW/f8+fvXEWxz15 H/oeS8wd/ZxWagTHIkJM8H7LwQL2pKjrSUNnxXF3UL+O/O3LTD2gW+3EYd14buCExB1T luy+IeTRrLLiBj5LqDK715cdO3OxOKsmgGuE0jOzW+JTCWu/r2Lwy3GVYeCDXKxL5POb 6/CNMAlSeGxyRKsFlY+q0lq2/lz7LIEyQfqqyG7mW9buLfdXJ5CX+5fysgo6kDoE/2PJ MTPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=EPMebf/VFZ78zkEbFBK6Q6zE4gZLxtYb5jfNhp6Lq5g=; b=fKexNpuV1QjyyBbRyCAC8QI+DBFEh9fsCB1/gh23Io/94wnvUE7V+XSXafi6O60vtQ aoSrhDFrspSH+ZEFdl+PYxos04fz3ttXFrYH4/wlRbKy88CtvDnwdKKsrRhCs4M1E/UC TEMDC7CoNtTkB2BvWbhdmtUuVpAhhk2GT5ZpRfJ/5fJHR3wH4DxZzXHat7fbpKhkoWLB zCOa7X/JkwnZasy9BeMPl1ZRQY1qycAmCYABx/4fyw0jJfhFnRMY/9pg7ZnPdWHU/2sk BXjeFAEn61Hu1Up1eanBeCBnH8AzUJX2wRbGqCXec0Scmt64IxA7vxYPCDsatoOnSkmE SrQQ== X-Gm-Message-State: AOAM5338XqzrV1CiQQqT5U85gIWKDsDTHGPGLKrgsV47qgiBcL84BWGR zl8NUM0e7y1aHEjuJM8xJO8xtvJIhkU= X-Google-Smtp-Source: ABdhPJze1vaSjvIHO9Je+m8flUtBZxUoYfVQG1RcHwEUYwMkuCLzFMr4kuGU9SjmUi7dWCyAZXsKnA== X-Received: by 2002:a37:b142:: with SMTP id a63mr8285431qkf.704.1639967536358; Sun, 19 Dec 2021 18:32:16 -0800 (PST) Original-Received: from localhost ([68.237.93.126]) by smtp.gmail.com with ESMTPSA id bl16sm10548170qkb.44.2021.12.19.18.32.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Dec 2021 18:32:15 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::732 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=dick.r.chiang@gmail.com; helo=mail-qk1-x732.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:222762 Archived-At: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Rationalize-window-text-pixel-size.patch Content-Transfer-Encoding: quoted-printable >From 11ce84b93df374e43d91b46cc84cede12893d1b0 Mon Sep 17 00:00:00 2001 From: dickmao Date: Sun, 19 Dec 2021 21:23:15 -0500 Subject: [PATCH] Rationalize window-text-pixel-size Even if 43c4cc2 did anything (it doesn't), it was obviously the wrong way to go about it. Then I saw 914cb7a, I had to do something about it. * doc/lispref/display.texi (Size of Displayed Text): Revert. * src/pgtkfns.c (Fx_show_tip): Revert. * src/xdisp.c (window_text_pixel_size): De-obfuscate. (Fwindow_text_pixel_size): Revert. (Fbuffer_text_pixel_size): Revert. * src/xfns.c (Fx_show_tip): Revert. * test/lisp/emacs-lisp/multisession-tests.el (multi-test--on-conflict-p, multi-test-sqlite-simple, multi-test-sqlite-busy, multi-test-files-simple, multi-test-files-busy, multi-test-files-some-values): You gotta do what you gotta do. * test/src/xdisp-tests.el (xdisp-tests--visible-buffer): `with-temp-buffer` won't cut it for xdisp tests. (xdisp-tests--reconnoiter-image-height, xdisp-tests--scroll-down-leaves-cursor-behind, xdisp-tests--window-text-pixel-size-single-sline, xdisp-tests--window-text-pixel-size-display-property): Test stuff. --- doc/lispref/display.texi | 8 +- src/pgtkfns.c | 3 +- src/w32fns.c | 3 +- src/xdisp.c | 154 +++++---------------- src/xfns.c | 3 +- test/lisp/emacs-lisp/multisession-tests.el | 81 +++++++---- test/src/xdisp-tests.el | 66 +++++++++ 7 files changed, 152 insertions(+), 166 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 98a15404f9..dd996fbe4a 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2086,7 +2086,7 @@ Size of Displayed Text (@pxref{Resizing Windows}) to make a window exactly as large as the text it contains. =20 -@defun window-text-pixel-size &optional window from to x-limit y-limit mod= e-lines ignore-line-at-end +@defun window-text-pixel-size &optional window from to x-limit y-limit mod= e-lines This function returns the size of the text of @var{window}'s buffer in pixels. @var{window} must be a live window and defaults to the selected one. The return value is a cons of the maximum pixel-width @@ -2136,12 +2136,6 @@ Size of Displayed Text height of all of these lines, if present, in the return value. @end defun =20 -The optional argument @var{ignore-line-at-end} controls whether or -not to count the height of text in @var{to}'s screen line as part of -the returned pixel-height. This is useful if your Lisp program is -only interested in the dimensions of text up to and excluding the -visual beginning of @var{to}'s screen line. - @code{window-text-pixel-size} treats the text displayed in a window as a whole and does not care about the size of individual lines. The following function does. diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 44e3d2a37e..1a4f08ca7d 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -3474,8 +3474,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, = 0, try_window (window, pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); /* Calculate size of tooltip window. */ size =3D Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil, - make_fixnum (w->pixel_height), Qnil, - Qnil); + make_fixnum (w->pixel_height), Qnil); /* Add the frame's internal border to calculated size. */ width =3D XFIXNUM (Fcar (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f= ); height =3D XFIXNUM (Fcdr (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_= f); diff --git a/src/w32fns.c b/src/w32fns.c index 02a6d78b51..65463b5261 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -7525,8 +7525,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, = 0, try_window (window, pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); /* Calculate size of tooltip window. */ size =3D Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil, - make_fixnum (w->pixel_height), Qnil, - Qnil); + make_fixnum (w->pixel_height), Qnil); /* Add the frame's internal border to calculated size. */ width =3D XFIXNUM (Fcar (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f= ); height =3D XFIXNUM (Fcdr (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_= f); diff --git a/src/xdisp.c b/src/xdisp.c index 0c35d24c26..d5101457c7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10827,22 +10827,22 @@ in_display_vector_p (struct it *it) && it->dpvec + it->current.dpvec_index !=3D it->dpend); } =20 -/* This is like Fwindow_text_pixel_size but assumes that WINDOW's buffer - is the current buffer. Fbuffer_text_pixel_size calls it after it has - set WINDOW's buffer to the buffer specified by its BUFFER_OR_NAME - argument. */ +/* Return cons pair of WINDOW's cartesian dimensions. */ + static Lisp_Object window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object = to, Lisp_Object x_limit, Lisp_Object y_limit, - Lisp_Object mode_lines, Lisp_Object ignore_line_at_end) + Lisp_Object mode_lines) { struct window *w =3D decode_live_window (window); struct it it; ptrdiff_t start, end, bpos; struct text_pos startp; void *itdata =3D NULL; - int c, max_x =3D 0, max_y =3D 0, x =3D 0, y =3D 0; - int doff =3D 0; + int c, x =3D 0, y =3D 0, start_x =3D 0, start_vpos =3D 0; + + int max_x =3D (RANGED_FIXNUMP (0, x_limit, INT_MAX)) ? XFIXNUM (x_limit)= : INT_MAX; + int max_y =3D (RANGED_FIXNUMP (0, y_limit, INT_MAX)) ? XFIXNUM (y_limit)= : INT_MAX; =20 if (NILP (from)) { @@ -10902,121 +10902,29 @@ window_text_pixel_size (Lisp_Object window, Lisp= _Object from, Lisp_Object to, else end =3D clip_to_bounds (start, fix_position (to), ZV); =20 - if (RANGED_FIXNUMP (0, x_limit, INT_MAX)) - max_x =3D XFIXNUM (x_limit); - else if (!NILP (x_limit)) - max_x =3D INT_MAX; - - if (NILP (y_limit)) - max_y =3D INT_MAX; - else if (RANGED_FIXNUMP (0, y_limit, INT_MAX)) - max_y =3D XFIXNUM (y_limit); - itdata =3D bidi_shelve_cache (); + start_display (&it, w, startp); - int start_y =3D it.current_y; - /* It makes no sense to measure dimensions of region of text that - crosses the point where bidi reordering changes scan direction. - By using unidirectional movement here we at least support the use - case of measuring regions of text that have a uniformly R2L - directionality, and regions that begin and end in text of the - same directionality. */ - it.bidi_p =3D false; - - /* Start at the beginning of the line containing FROM. Otherwise - IT.current_x will be incorrectly set to zero at some arbitrary - non-zero X coordinate. */ + it.last_visible_x =3D min (it.last_visible_x, max_x); + reseat_at_previous_visible_line_start (&it); it.current_x =3D it.hpos =3D 0; - if (IT_CHARPOS (it) !=3D start) - move_it_to (&it, start, -1, -1, -1, MOVE_TO_POS); - - /* Now move to TO. */ - int start_x =3D it.current_x; - int move_op =3D MOVE_TO_POS | MOVE_TO_Y; - int to_x =3D -1; - it.current_y =3D start_y; - /* If FROM is on a newline, pretend that we start at the beginning - of the next line, because the newline takes no place on display. */ - if (FETCH_BYTE (start) =3D=3D '\n') - it.current_x =3D 0; - if (!NILP (x_limit)) - { - it.last_visible_x =3D max_x; - /* Actually, we never want move_it_to stop at to_x. But to make - sure that move_it_in_display_line_to always moves far enough, - we set to_x to INT_MAX and specify MOVE_TO_X. */ - move_op |=3D MOVE_TO_X; - to_x =3D INT_MAX; - } - - void *it2data =3D NULL; - struct it it2; - SAVE_IT (it2, it, it2data); - - x =3D move_it_to (&it, end, to_x, max_y, -1, move_op); - - /* We could have a display property at END, in which case asking - move_it_to to stop at END will overshoot and stop at position - after END. So we try again, stopping before END, and account for - the width of the last buffer position manually. */ - if (IT_CHARPOS (it) > end) - { - end--; - RESTORE_IT (&it, &it2, it2data); - x =3D move_it_to (&it, end, to_x, max_y, -1, move_op); - /* Add the width of the thing at TO, but only if we didn't - overshoot it; if we did, it is already accounted for. Also, - account for the height of the thing at TO. */ - if (IT_CHARPOS (it) =3D=3D end) - { - x +=3D it.pixel_width; - - /* DTRT if ignore_line_at_end is t. */ - if (!NILP (ignore_line_at_end)) - doff =3D (max (it.max_ascent, it.ascent) - + max (it.max_descent, it.descent)); - else - { - it.max_ascent =3D max (it.max_ascent, it.ascent); - it.max_descent =3D max (it.max_descent, it.descent); - } - } - } - else - bidi_unshelve_cache (it2data, true); + move_it_to (&it, start, -1, -1, -1, MOVE_TO_POS); + start_x =3D it.current_x; + start_vpos =3D it.vpos; =20 - if (!NILP (x_limit)) - { - /* Don't return more than X-LIMIT. */ - if (x > max_x) - x =3D max_x; - } + x =3D move_it_to (&it, end, -1, max_y, -1, MOVE_TO_POS | MOVE_TO_Y); + x =3D min (x, max_x); =20 - /* If text spans more than one screen line, we don't need to adjust - the x-span for start_x, since the second and subsequent lines - will begin at zero X coordinate. */ - if (it.current_y > start_y) - start_x =3D 0; - - /* Subtract height of header-line and tab-line which was counted - automatically by start_display. */ - if (!NILP (ignore_line_at_end)) - y =3D (it.current_y + doff - - WINDOW_TAB_LINE_HEIGHT (w) - - WINDOW_HEADER_LINE_HEIGHT (w)); - else - y =3D (it.current_y + it.max_ascent + it.max_descent + doff - - WINDOW_TAB_LINE_HEIGHT (w) - WINDOW_HEADER_LINE_HEIGHT (w)); - - /* Don't return more than Y-LIMIT. */ - if (y > max_y) - y =3D max_y; + /* Subtract header- and tab-line included by start_move_it(). */ + y =3D it.current_y + it.max_ascent + it.max_descent + - WINDOW_TAB_LINE_HEIGHT (w) - WINDOW_HEADER_LINE_HEIGHT (w); + y =3D min (y, max_y); =20 if ((EQ (mode_lines, Qtab_line) || EQ (mode_lines, Qt)) && window_wants_tab_line (w)) - /* Add height of tab-line as requested. */ { + /* Add height of tab-line as requested. */ Lisp_Object window_tab_line_format =3D window_parameter (w, Qtab_line_format); =20 @@ -11052,10 +10960,15 @@ window_text_pixel_size (Lisp_Object window, Lisp_= Object from, Lisp_Object to, =20 bidi_unshelve_cache (itdata, false); =20 - return Fcons (make_fixnum (x - start_x), make_fixnum (y)); + /* X is widest line seen by move_it_forwards() */ + return Fcons (make_fixnum + (it.vpos =3D=3D start_vpos + ? x - start_x /* START to END same sline */ + : x), + make_fixnum (y)); } =20 -DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pix= el_size, 0, 7, 0, +DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pix= el_size, 0, 6, 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 @@ -11102,12 +11015,9 @@ DEFUN ("window-text-pixel-size", Fwindow_text_pixe= l_size, Swindow_text_pixel_siz height of the mode-, tab- or header-line of WINDOW in the return value. If it is the symbol `mode-line', 'tab-line' or `header-line', include only the height of that line, if present, in the return value. If t, -include the height of any of these, if present, in the return value. - -IGNORE-LINE-AT-END, if non-nil, means to not add the height of the -screen line that includes TO to the returned height of the text. */) +include the height of any of these, if present, in the return value. */) (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_lim= it, - Lisp_Object y_limit, Lisp_Object mode_lines, Lisp_Object ignore_line_at= _end) + Lisp_Object y_limit, Lisp_Object mode_lines) { struct window *w =3D decode_live_window (window); struct buffer *b =3D XBUFFER (w->contents); @@ -11120,8 +11030,7 @@ DEFUN ("window-text-pixel-size", Fwindow_text_pixel= _size, Swindow_text_pixel_siz set_buffer_internal_1 (b); } =20 - value =3D window_text_pixel_size (window, from, to, x_limit, y_limit, mo= de_lines, - ignore_line_at_end); + value =3D window_text_pixel_size (window, from, to, x_limit, y_limit, mo= de_lines); =20 if (old_b) set_buffer_internal_1 (old_b); @@ -11171,8 +11080,7 @@ DEFUN ("buffer-text-pixel-size", Fbuffer_text_pixel= _size, Sbuffer_text_pixel_siz set_marker_both (w->old_pointm, buffer, BEG, BEG_BYTE); } =20 - value =3D window_text_pixel_size (window, Qnil, Qnil, x_limit, y_limit, = Qnil, - Qnil); + value =3D window_text_pixel_size (window, Qnil, Qnil, x_limit, y_limit, = Qnil); =20 unbind_to (count, Qnil); =20 diff --git a/src/xfns.c b/src/xfns.c index 30ed358fb2..dc25d7bfca 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -7169,8 +7169,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, = 0, try_window (window, pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); /* Calculate size of tooltip window. */ size =3D Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil, - make_fixnum (w->pixel_height), Qnil, - Qnil); + make_fixnum (w->pixel_height), Qnil); /* Add the frame's internal border to calculated size. */ width =3D XFIXNUM (Fcar (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f= ); height =3D XFIXNUM (Fcdr (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_= f); diff --git a/test/lisp/emacs-lisp/multisession-tests.el b/test/lisp/emacs-l= isp/multisession-tests.el index 1bf0a533a7..981557fd9e 100644 --- a/test/lisp/emacs-lisp/multisession-tests.el +++ b/test/lisp/emacs-lisp/multisession-tests.el @@ -26,6 +26,15 @@ (require 'ert-x) (require 'cl-lib) =20 +(defsubst multi-test--on-conflict-p () + "The 'on conflict' is only supported in sqlite3 v3.24.0 +https://stackoverflow.com/a/51531835/5132008" + (when (bound-and-true-p multisession--db) + (let ((result (with-sqlite-transaction multisession--db + (sqlite-select multisession--db "select sqlite_version()")))) + (version-list-<=3D (version-to-list "3.24.0") + (version-to-list (seq-find #'stringp (cl-first resu= lt))))))) + (ert-deftest multi-test-sqlite-simple () (skip-unless (sqlite-available-p)) (ert-with-temp-file dir @@ -38,6 +47,7 @@ multi-test-sqlite-simple (define-multisession-variable multisession--foo 0 "" :synchronized t) + (skip-unless (multi-test--on-conflict-p)) (should (=3D (multisession-value multisession--foo) 0)) (cl-incf (multisession-value multisession--foo)) (should (=3D (multisession-value multisession--foo) 1)) @@ -56,11 +66,12 @@ multi-test-sqlite-simple :synchronized t) (cl-incf (multisession-value multisession--foo= )))))) (should (=3D (multisession-value multisession--foo) 2))) - (sqlite-close multisession--db) + (when multisession--db + (sqlite-close multisession--db)) (setq multisession--db nil))))) =20 (ert-deftest multi-test-sqlite-busy () - (skip-unless (and t (sqlite-available-p))) + (skip-unless (sqlite-available-p)) (ert-with-temp-file dir :directory t (let ((user-init-file "/tmp/foo.el") @@ -72,6 +83,7 @@ multi-test-sqlite-busy (define-multisession-variable multisession--bar 0 "" :synchronized t) + (skip-unless (multi-test--on-conflict-p)) (should (=3D (multisession-value multisession--bar) 0)) (cl-incf (multisession-value multisession--bar)) (should (=3D (multisession-value multisession--bar) 1)) @@ -93,45 +105,53 @@ multi-test-sqlite-busy (cl-incf (multisession-value multisess= ion--bar)))))))) (while (process-live-p proc) (ignore-error 'sqlite-locked-error - (message "multisession--bar %s" (multisession-value multis= ession--bar)) - ;;(cl-incf (multisession-value multisession--bar)) - ) - (sleep-for 0.1)) - (message "multisession--bar ends up as %s" (multisession-value= multisession--bar)) + (message "multisession--bar %s" (multisession-value multis= ession--bar))) + (accept-process-output nil 0.1)) + (message "bar ends up as %s" (multisession-value multisession-= -bar)) (should (< (multisession-value multisession--bar) 1003))) - (sqlite-close multisession--db) + (when (process-live-p proc) + (kill-process proc)) + (when multisession--db + (sqlite-close multisession--db)) (setq multisession--db nil))))) =20 (ert-deftest multi-test-files-simple () + (skip-unless (sqlite-available-p)) (ert-with-temp-file dir :directory t (let ((user-init-file "/tmp/sfoo.el") (multisession-storage 'files) (multisession-directory dir)) - (define-multisession-variable multisession--sfoo 0 - "" - :synchronized t) - (should (=3D (multisession-value multisession--sfoo) 0)) - (cl-incf (multisession-value multisession--sfoo)) - (should (=3D (multisession-value multisession--sfoo) 1)) - (call-process - (concat invocation-directory invocation-name) - nil t nil - "-Q" "-batch" - "--eval" (prin1-to-string - `(progn - (require 'multisession) - (let ((multisession-directory ,dir) - (multisession-storage 'files) - (user-init-file "/tmp/sfoo.el")) - (define-multisession-variable multisession--sfoo 0 - "" - :synchronized t) - (cl-incf (multisession-value multisession--sfoo)))))) - (should (=3D (multisession-value multisession--sfoo) 2))))) + (unwind-protect + (progn + (define-multisession-variable multisession--sfoo 0 + "" + :synchronized t) + (skip-unless (multi-test--on-conflict-p)) + (should (=3D (multisession-value multisession--sfoo) 0)) + (cl-incf (multisession-value multisession--sfoo)) + (should (=3D (multisession-value multisession--sfoo) 1)) + (call-process + (concat invocation-directory invocation-name) + nil t nil + "-Q" "-batch" + "--eval" (prin1-to-string + `(progn + (require 'multisession) + (let ((multisession-directory ,dir) + (multisession-storage 'files) + (user-init-file "/tmp/sfoo.el")) + (define-multisession-variable multisession--sf= oo 0 + "" + :synchronized t) + (cl-incf (multisession-value multisession--sfo= o)))))) + (should (=3D (multisession-value multisession--sfoo) 2))) + (when multisession--db + (sqlite-close multisession--db)) + (setq multisession--db nil))))) =20 (ert-deftest multi-test-files-busy () - (skip-unless (and t (sqlite-available-p))) + (skip-unless (sqlite-available-p)) (ert-with-temp-file dir :directory t (let ((user-init-file "/tmp/foo.el") @@ -168,6 +188,7 @@ multi-test-files-busy (should (< (multisession-value multisession--sbar) 2000))))) =20 (ert-deftest multi-test-files-some-values () + (skip-unless (sqlite-available-p)) (ert-with-temp-file dir :directory t (let ((user-init-file "/tmp/sfoo.el") diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el index ae4aacd9c7..dd99b28320 100644 --- a/test/src/xdisp-tests.el +++ b/test/src/xdisp-tests.el @@ -21,6 +21,14 @@ =20 (require 'ert) =20 +(defmacro xdisp-tests--visible-buffer (&rest body) + (declare (debug t) (indent 0)) + `(progn + (switch-to-buffer (symbol-name (ert-test-name (ert-running-test)))) + (progn ,@body) + (let (kill-buffer-query-functions) + (kill-buffer (symbol-name (ert-test-name (ert-running-test))))))) + (defmacro xdisp-tests--in-minibuffer (&rest body) (declare (debug t) (indent 0)) `(catch 'result @@ -170,4 +178,62 @@ test-get-display-property (should (equal (get-display-property 2 'height) 2.0)) (should (equal (get-display-property 2 'space-width) 20)))) =20 +(ert-deftest xdisp-tests--reconnoiter-image-height () + "C-v on image extending beyond window should not signal +end-of-buffer." + (skip-unless (not noninteractive)) + (skip-unless (> (window-pixel-height) 300)) + (xdisp-tests--visible-buffer + (dotimes (_ (/ (- (window-pixel-height) 100) (line-pixel-height))) + (insert "line" "\n")) + (insert-image (create-image (expand-file-name + "test/data/image/blank-100x200.png" + source-directory))) + (insert "\n") + (redisplay) + (goto-char (point-min)) + (scroll-up) + (redisplay))) + +(ert-deftest xdisp-tests--scroll-down-leaves-cursor-behind () + "When first line contains accented, and therefore taller +character, e.g., =C3=93scar, scrolling down (moving window-start up) +has resulted in a no-op." + (xdisp-tests--visible-buffer + (insert "=C3=93scar" "\n") + (dotimes (_ (/ (1+ (window-pixel-height)) (line-pixel-height))) + (insert "line" "\n")) + (goto-char (point-max)) + (redisplay) + (scroll-down) + (redisplay) + (should (=3D (window-start) 1)))) + +(ert-deftest xdisp-tests--window-text-pixel-size-single-sline () + "Verify `window-text-pixel-size' handles one screen line spanned." + (xdisp-tests--visible-buffer + (save-excursion + (insert "xxxx")) + (should (=3D (* 2 (frame-char-width)) + (car (window-text-pixel-size + nil (1+ (point-min)) (1- (point-max)))))))) + +(ert-deftest xdisp-tests--window-text-pixel-size-display-property () + "Verify `window-text-pixel-size' returns dimensions including +width of display property." + (xdisp-tests--visible-buffer + (let ((disp-string "ornery")) + (save-excursion + (insert "xxxx")) + (should + (=3D (+ (1- (length disp-string)) + (car (window-text-pixel-size + nil (line-beginning-position) (line-end-position)))) + (progn + (put-text-property (1- (line-end-position)) + (line-end-position) + 'display disp-string) + (car (window-text-pixel-size + nil (line-beginning-position) (line-end-position))))))))) + ;;; xdisp-tests.el ends here --=20 2.26.2 --=-=-= Content-Type: text/plain In Commercial Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10) of 2021-12-19 built on dick Repository revision: fa52e7eee7a9fe2a4b01ce631370a760d46a5c9e Repository branch: dev Windowing system distributor 'The X.Org Foundation', version 11.0.11906000 System Description: Ubuntu 18.04.4 LTS Configured using: 'configure --prefix=/home/dick/.local --with-tree-sitter --enable-dumping-overwrite CC=gcc-10 'CFLAGS=-g3 -O2 -I/home/dick/.local/include/' LDFLAGS=-L/home/dick/.local/lib PKG_CONFIG_PATH=/home/dick/.local/lib/pkgconfig CXX=gcc-10' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON TREE_SITTER LCMS2 LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Magit Minor modes in effect: async-bytecomp-package-mode: t global-git-commit-mode: t shell-dirtrack-mode: t projectile-mode: t flx-ido-mode: t override-global-mode: t winner-mode: t tooltip-mode: t show-paren-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /home/dick/gomacro-mode/gomacro-mode hides /home/dick/.emacs.d/elpa/gomacro-mode-20200326.1103/gomacro-mode /home/dick/.emacs.d/elpa/hydra-20170924.2259/lv hides /home/dick/.emacs.d/elpa/lv-20191106.1238/lv /home/dick/.emacs.d/elpa/magit-3.3.0/magit-section-pkg hides /home/dick/.emacs.d/elpa/magit-section-3.3.0/magit-section-pkg /home/dick/org-gcal.el/org-gcal hides /home/dick/.emacs.d/elpa/org-gcal-0.3/org-gcal /home/dick/.emacs.d/elpa/tree-sitter-20211211.1220/tree-sitter hides /home/dick/.local/share/emacs/28.0.50/lisp/tree-sitter /home/dick/.emacs.d/lisp/json hides /home/dick/.local/share/emacs/28.0.50/lisp/json /home/dick/.emacs.d/elpa/transient-0.3.6/transient hides /home/dick/.local/share/emacs/28.0.50/lisp/transient /home/dick/.emacs.d/elpa/hierarchy-20171221.1151/hierarchy hides /home/dick/.local/share/emacs/28.0.50/lisp/emacs-lisp/hierarchy /home/dick/.local/share/emacs/28.0.50/lisp/emacs-lisp/eieio-compat hides /home/dick/.local/share/emacs/28.0.50/lisp/obsolete/eieio-compat Features: (shadow sort footnote mail-extr gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr pixel-fill kinsoku svg dom gnus-group mm-url gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range gnus-win emacsbug sendmail goto-addr mule-util magit-extras misearch multi-isearch texinfo texinfo-loaddefs tramp-archive tramp-gvfs tramp-cache zeroconf dbus xml tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat parse-time iso8601 ls-lisp ag vc-svn find-dired s vc cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs benchmark vc-git vc-dispatcher bug-reference face-remap magit-patch-changelog magit-patch magit-submodule magit-obsolete magit-popup async-bytecomp async magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff diff-mode git-commit log-edit message yank-media rmc puny dired-x dired dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader pcvs-util add-log magit-core magit-margin magit-transient magit-process with-editor shell pcomplete server magit-mode transient format-spec paredit-ext paredit subed subed-vtt subed-srt subed-common subed-mpv subed-debug subed-config inf-ruby ruby-mode smie company pcase haskell-interactive-mode haskell-presentation-mode haskell-process haskell-session haskell-compile haskell-mode haskell-cabal haskell-utils haskell-font-lock haskell-indentation haskell-string haskell-sort-imports haskell-lexeme haskell-align-imports haskell-complete-module haskell-ghc-support noutline outline flymake-proc flymake warnings etags fileloop generator xref project dabbrev haskell-customize hydra lv use-package-ensure solarized-theme solarized-definitions projectile lisp-mnt mail-parse rfc2231 rfc2047 rfc2045 ietf-drums ibuf-ext ibuffer ibuffer-loaddefs thingatpt magit-autorevert autorevert filenotify magit-git magit-section magit-utils crm dash rx grep compile comint ansi-color gnus nnheader mail-utils mm-util mail-prsvr gnus-util text-property-search time-date flx-ido flx google-translate-default-ui google-translate-core-ui facemenu color ido google-translate-core google-translate-tk google-translate-backend use-package-bind-key bind-key auto-complete easy-mmode advice edmacro kmacro popup cus-edit pp cus-load wid-edit emms-player-mplayer emms-player-simple emms emms-compat cl-extra help-mode use-package-core derived winner ring finder-inf json-reformat-autoloads json-snatcher-autoloads sml-mode-autoloads tornado-template-mode-autoloads info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tree-sitter tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 616961 37623) (symbols 48 34377 4) (strings 32 129257 16009) (string-bytes 1 4378137) (vectors 16 79659) (vector-slots 8 2079074 30314) (floats 8 479 2293) (intervals 56 4800 940) (buffers 992 19)) --=-=-=--