GNU bug report logs - #41737
26.3; (window-text-pixel-size) in console

Previous Next

Package: emacs;

Reported by: Tomas Hlavaty <tom <at> logand.com>

Date: Sat, 6 Jun 2020 15:47:01 UTC

Severity: normal

Found in version 26.3

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41737 in the body.
You can then email your comments to 41737 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41737; Package emacs. (Sat, 06 Jun 2020 15:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tomas Hlavaty <tom <at> logand.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 06 Jun 2020 15:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tomas Hlavaty <tom <at> logand.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.3; (window-text-pixel-size) in console
Date: Sat, 06 Jun 2020 14:47:14 +0200
Hi,

(window-text-pixel-size) in console seems to be wrong.

The width seems to the width of the (visible) window.

The height seems to be number of lines in a file.  However, when
evaluated in notmuch thread, the cdr of the return value is a number
which I cannot interpret (it is not number of lines in the buffer and it
is now height of the visible window).

   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 the
   maximum pixel-height of all text lines.

I suppose that pixel in console is one character.

   the maximum pixel-width of any text line

but this does not seem to be true.  I have file with long line but it
still returns number of visible columns.

   maximum pixel-height of all text lines

It is not clean, what does that mean and the returned number doesn't
seem to be useful for anything.

Thanks,

Tomas


In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10)
Recent messages:
Mark set
Making completion list...
(96 . 218)
next-line: End of buffer [7 times]
Mark set
Quit
Mark set
Quit
Mark set
C-x C-g is undefined

Configured using:
 'configure
 --prefix=/nix/store/qc9ipxcjcf33izlavkbj3jsqvwfcf602-emacs-26.3
 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft
 CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX
GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD

Important settings:
  value of $EMACSLOADPATH: /nix/store/bp2z6hf7yxcsygrr1pblbid3i9lh065v-emacs-packages-deps/share/emacs/site-lisp:
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: utf-8-unix

Major mode: notmuch-show

Minor modes in effect:
  gpm-mouse-mode: t
  global-magit-file-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  show-paren-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-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
  visual-line-mode: t
  transient-mark-mode: t

Load-path shadows:
/run/current-system/sw/share/emacs/site-lisp/password-store hides /nix/store/bp2z6hf7yxcsygrr1pblbid3i9lh065v-emacs-packages-deps/share/emacs/site-lisp/elpa/password-store-20190929.1627/password-store
/nix/store/bp2z6hf7yxcsygrr1pblbid3i9lh065v-emacs-packages-deps/share/emacs/site-lisp/site-start hides /nix/store/qc9ipxcjcf33izlavkbj3jsqvwfcf602-emacs-26.3/share/emacs/site-lisp/site-start
/nix/store/bp2z6hf7yxcsygrr1pblbid3i9lh065v-emacs-packages-deps/share/emacs/site-lisp/elpa/auth-source-pass-20191126.1242/auth-source-pass hides /nix/store/qc9ipxcjcf33izlavkbj3jsqvwfcf602-emacs-26.3/share/emacs/26.3/lisp/auth-source-pass
/nix/store/bp2z6hf7yxcsygrr1pblbid3i9lh065v-emacs-packages-deps/share/emacs/site-lisp/elpa/let-alist-1.0.6/let-alist hides /nix/store/qc9ipxcjcf33izlavkbj3jsqvwfcf602-emacs-26.3/share/emacs/26.3/lisp/emacs-lisp/let-alist

Features:
(shadow emacsbug vc-git network-stream starttls url-http tls gnutls
url-gw nsm url-cache url-auth mailalias sendmail feedmail sort
gnus-alias mail-extr mule-util misearch multi-isearch notmuch-jump
t-mouse term/linux elec-pair finder-inf info pdf printing ps-print
ps-print-loaddefs ps-def lpr unoffice framebuffer hydra lv dumb-jump
popup f s elfeed-show elfeed-search magit-bookmark bookmark elfeed-csv
elfeed elfeed-curl elfeed-log elfeed-db elfeed-lib xml-query email-eww
cltl clhs notmuch hl-line notmuch-hello notmuch-tree notmuch-show
notmuch-print notmuch-crypto notmuch-mua notmuch-message notmuch-draft
notmuch-maildir-fcc notmuch-address notmuch-company notmuch-parser
notmuch-wash coolj notmuch-query goto-addr icalendar diary-lib
diary-loaddefs notmuch-tag notmuch-lib notmuch-compat mm-view mml-smime
smime dig eww-lnum eww mm-url gnus nnheader wid-edit url-queue url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap shr svg xml dom magit-submodule
magit-obsolete 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
package url-handlers url-parse auth-source url-vars magit-repos
magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode
magit-core magit-autorevert autorevert filenotify magit-margin
magit-transient magit-process magit-mode git-commit transient magit-git
magit-section magit-utils crm log-edit message rmc puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log with-editor
cl-extra help-mode async-bytecomp async shell server subr-x dash
diff-mode ob-ledger org-element avl-tree generator org org-macro
org-footnote org-pcomplete pcomplete org-list org-faces org-entities
org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table
ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs
paredit edmacro kmacro slime-asdf grep slime-fancy slime-trace-dialog
slime-fontifying-fu slime-package-fu slime-references
slime-compiler-notes-tree advice slime-scratch slime-presentations
bridge slime-macrostep macrostep slime-mdot-fu slime-enclosing-context
slime-fancy-trace slime-fancy-inspector slime-fuzzy slime-c-p-c
slime-autodoc slime-editing-commands slime-repl slime-parse slime
compile etags xref cl-seq project eieio eieio-core eieio-loaddefs
arc-mode archive-mode noutline outline easymenu pp comint ansi-color
ring hyperspec thingatpt browse-url slime-autoloads picolisp tsm
easy-mmode cl-macs cl time-date paren cus-start cus-load seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib disp-table tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win
x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame 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 charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 351465 36274)
 (symbols 48 43865 6)
 (miscs 40 3116 3771)
 (strings 32 115935 3694)
 (string-bytes 1 4549539)
 (vectors 16 43596)
 (vector-slots 8 821982 19876)
 (floats 8 398 374)
 (intervals 56 4673 304)
 (buffers 992 21))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41737; Package emacs. (Sat, 06 Jun 2020 17:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 41737 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tomas Hlavaty <tom <at> logand.com>
Cc: 41737 <at> debbugs.gnu.org
Subject: Re: bug#41737: 26.3; (window-text-pixel-size) in console
Date: Sat, 06 Jun 2020 19:57:51 +0300
> From: Tomas Hlavaty <tom <at> logand.com>
> Date: Sat, 06 Jun 2020 14:47:14 +0200
> 
> (window-text-pixel-size) in console seems to be wrong.

I don't think it's wrong, I think the doc string needs clarification
(which I just did).

> The width seems to the width of the (visible) window.

If the text is as wide or wider than the window, then by default this
is what is expected, yes.

> The height seems to be number of lines in a file.

On a TTY frame, yes.

> However, when evaluated in notmuch thread, the cdr of the return
> value is a number which I cannot interpret (it is not number of
> lines in the buffer and it is now height of the visible window).

I'd need to see an example to respond to that.  But maybe using the
new doc string (below) you will be able to understand what happens in
that use case as well.

>    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 the
>    maximum pixel-height of all text lines.
> 
> I suppose that pixel in console is one character.

Yes, that is a general rule in TTY frames.

>    the maximum pixel-width of any text line
> 
> but this does not seem to be true.  I have file with long line but it
> still returns number of visible columns.

Right, by default text beyond window's width is ignored.  It was not
immediately clear from the doc string; I hope it is more clear now.

>    maximum pixel-height of all text lines
> 
> It is not clean, what does that mean and the returned number doesn't
> seem to be useful for anything.

I clarified that as well.

The doc string now says:

  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 the pixel-height of all the text lines in the accessible portion
  of buffer text.

  This function exists to allow Lisp programs to adjust the dimensions
  of WINDOW to the buffer text it needs to display.

  The optional argument FROM, if non-nil, specifies the first text
  position to consider, and defaults to the minimum accessible position
  of the buffer.  If FROM is t, it stands for the minimum accessible
  position that starts a non-empty line.  TO, if non-nil, specifies the
  last text position and defaults to the maximum accessible position of
  the buffer.  If TO is t, it stands for the maximum accessible position
  that ends a non-empty line.

  The optional argument X-LIMIT, if non-nil, specifies the maximum X
  coordinate beyond which the text should be ignored.  It is therefore
  also the maximum width that the function can return.  X-LIMIT nil or
  omitted means to use the pixel-width of WINDOW's body.  This default
  means text of truncated lines wider than the window will be ignored;
  specify a large value for X-LIMIT if lines are truncated and you need
  to account for the truncated text.  Use nil for X-LIMIT if you want to
  know how high WINDOW should become in order to fit all of its buffer's
  text with the width of WINDOW unaltered.  Use the maximum width WINDOW
  may assume if you intend to change WINDOW's width.  Since calculating
  the width of long lines can take some time, it's always a good idea to
  make this argument as small as possible; in particular, if the buffer
  contains long lines that shall be truncated anyway.

  The optional argument Y-LIMIT, if non-nil, specifies the maximum Y
  coordinate beyond which the text is to be ignored; it is therefore
  also the maxcomp height that the function can return (excluding the
  height of the mode- or header-line, if any).  Y-LIMIT nil or omitted
  means consider all of the accessible portion of buffer text up to the
  position specified by TO.  Since calculating the text height of a
  large buffer can take some time, it makes sense to specify this
  argument if the size of the buffer is large or unknown.

  Optional argument MODE-AND-HEADER-LINE nil or omitted means do not
  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.




Reply sent to Stefan Kangas <stefan <at> marxist.se>:
You have taken responsibility. (Thu, 13 Aug 2020 01:02:02 GMT) Full text and rfc822 format available.

Notification sent to Tomas Hlavaty <tom <at> logand.com>:
bug acknowledged by developer. (Thu, 13 Aug 2020 01:02:02 GMT) Full text and rfc822 format available.

Message #13 received at 41737-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 41737-done <at> debbugs.gnu.org, Tomas Hlavaty <tom <at> logand.com>
Subject: Re: bug#41737: 26.3; (window-text-pixel-size) in console
Date: Wed, 12 Aug 2020 18:01:31 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Tomas Hlavaty <tom <at> logand.com>
>> Date: Sat, 06 Jun 2020 14:47:14 +0200
>>
>> (window-text-pixel-size) in console seems to be wrong.
>
> I don't think it's wrong, I think the doc string needs clarification
> (which I just did).
>
>> The width seems to the width of the (visible) window.
>
> If the text is as wide or wider than the window, then by default this
> is what is expected, yes.
>
>> The height seems to be number of lines in a file.
>
> On a TTY frame, yes.
>
>> However, when evaluated in notmuch thread, the cdr of the return
>> value is a number which I cannot interpret (it is not number of
>> lines in the buffer and it is now height of the visible window).
>
> I'd need to see an example to respond to that.  But maybe using the
> new doc string (below) you will be able to understand what happens in
> that use case as well.
>
>>    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 the
>>    maximum pixel-height of all text lines.
>>
>> I suppose that pixel in console is one character.
>
> Yes, that is a general rule in TTY frames.
>
>>    the maximum pixel-width of any text line
>>
>> but this does not seem to be true.  I have file with long line but it
>> still returns number of visible columns.
>
> Right, by default text beyond window's width is ignored.  It was not
> immediately clear from the doc string; I hope it is more clear now.
>
>>    maximum pixel-height of all text lines
>>
>> It is not clean, what does that mean and the returned number doesn't
>> seem to be useful for anything.
>
> I clarified that as well.

That was 9 weeks ago, and, given the lack of updates since, it seems
like all issues here are resolved.  I'm therefore closing this bug
report.

Best regards,
Stefan Kangas




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 10 Sep 2020 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 225 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.