GNU bug report logs - #17065
24.3.50; Revise line 5944 of window.el to use `window-width`, instead of `window-total-width`.

Previous Next

Package: emacs;

Reported by: Keith David Bershatsky <esq <at> lawlist.com>

Date: Sat, 22 Mar 2014 01:34:01 UTC

Severity: minor

Found in version 24.3.50

To reply to this bug, email your comments to 17065 AT debbugs.gnu.org.

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#17065; Package emacs. (Sat, 22 Mar 2014 01:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Keith David Bershatsky <esq <at> lawlist.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 22 Mar 2014 01:34:02 GMT) Full text and rfc822 format available.

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

From: Keith David Bershatsky <esq <at> lawlist.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50;
 Revise line 5944 of window.el to use `window-width`, instead of
 `window-total-width`.
Date: Fri, 21 Mar 2014 17:32:59 -0800
As to line 5944 of `window.el` -- i.e., `(delta (- new-width (window-total-width window))))` -- the usage of `window-total-width` prevents the user from precisely setting the `window-width` when using *a number* as part of the `alist` -- e.g., `'((window-width . 82))`.  This can be demonstrated by the following example:

(defun broken-example ()
  (interactive)
  (window--display-buffer
   ;; buffer
   (get-buffer-create "*test*")
   ;; window
   (split-window (selected-window) nil 'right)
   ;; type
   'window
   ;; alist
   '((window-width . 82))
   ;; dedicated
   t) 
  (message "Window Width:  %s" (window-width (get-buffer-window "*test*"))) )

As the Emacs team is well aware, the internal function `window--display-buffer` is used by no less than eleven (11) other functions within the `display-buffer` family of functions.  Any of those eleven (11) functions that rely upon `window--display-buffer` for setting the `window-width` with an `alist` in the form of *a number* -- e.g., `'((window-width . 82))` -- will suffer from this problem.

My proposed solution would be to replace `window-total-width` with `window-width`.  However, I must admit that I do not have sufficient knowledge / expertise to know under what circumstance the `window-total-width` would be used -- I only know that this is what causes the inability to properly set the `window-width` when using many of the `display-buffer` family of functions.

Here is a link to the thread that I opened on stackoverflow.com on this same issue:

http://stackoverflow.com/questions/22565759/window-display-buffer-how-to-precisely-set-window-width-at-time-of-creation/22572176#22572176

Thanks,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

In GNU Emacs 24.3.50.1 (x86_64-apple-darwin10.8.0, NS apple-appkit-1038.36)
 of 2014-03-19 on MP.local
Repository revision: 116808 rgm <at> gnu.org-20140320012152-sdi1j3d5gu6uzm81
Windowing system distributor `Apple', version 10.3.1038
Configured using:
 `configure --with-ns'

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
  whitespace-mode: t
  linum-mode: t
  hl-line-mode: t
  lawlist-delete-selection-mode: t
  global-lawlist-scroll-bar-mode: t
  lawlist-scroll-bar-mode: t
  flyspell-mode: t
  shell-dirtrack-mode: t
  desktop-save-mode: t
  tabbar-mode: t
  highlight-parentheses-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Recent input:
<escape> x r e p o r t - e m a c s - b u g <return
>

Recent messages:
Loading /Users/HOME/.0.data/.0.emacs/init.el (source)...
Loading /Users/HOME/.0.data/.0.emacs/.multiple_cursors...done
Loading /Users/HOME/.0.data/.0.emacs/init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Starting new Ispell process /Users/HOME/.0.data/.0.emacs/elpa/bin/aspell with english dictionary...
Wrote /Users/HOME/.0.data/.0.emacs/.lock

Load-path shadows:
/Users/HOME/.0.data/.0.emacs/elpa/flim/md4 hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/md4
/Users/HOME/.0.data/.0.emacs/elpa/flim/hex-util hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/hex-util
/Users/HOME/.0.data/.0.emacs/elpa/flim/sasl hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/sasl
/Users/HOME/.0.data/.0.emacs/elpa/flim/sasl-ntlm hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/sasl-ntlm
/Users/HOME/.0.data/.0.emacs/elpa/flim/sasl-digest hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/sasl-digest
/Users/HOME/.0.data/.0.emacs/elpa/flim/sasl-cram hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/sasl-cram
/Users/HOME/.0.data/.0.emacs/elpa/flim/ntlm hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/ntlm
/Users/HOME/.0.data/.0.emacs/elpa/flim/hmac-md5 hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/hmac-md5
/Users/HOME/.0.data/.0.emacs/elpa/flim/hmac-def hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/net/hmac-def
/Users/HOME/.0.data/.0.emacs/elpa/wanderlust/rfc2368 hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/mail/rfc2368
/Users/HOME/.0.data/.0.emacs/elpa/wanderlust/utf7 hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/gnus/utf7
/Users/HOME/.0.data/.0.emacs/elpa/semi/smime hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/gnus/smime
/Users/HOME/.0.data/.0.emacs/elpa/semi/pgg hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/pgg
/Users/HOME/.0.data/.0.emacs/elpa/semi/pgg-pgp5 hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/pgg-pgp5
/Users/HOME/.0.data/.0.emacs/elpa/semi/pgg-pgp hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/pgg-pgp
/Users/HOME/.0.data/.0.emacs/elpa/semi/pgg-parse hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/pgg-parse
/Users/HOME/.0.data/.0.emacs/elpa/semi/pgg-gpg hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/pgg-gpg
/Users/HOME/.0.data/.0.emacs/elpa/semi/pgg-def hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/pgg-def
/Users/HOME/.0.data/.0.emacs/elpa/utilities/longlines hides /Users/HOME/.0.data/.0.emacs/Emacs_03_19_2014.app/Contents/Resources/lisp/obsolete/longlines

Features:
(shadow wl-mime mime-edit pgg-parse pccl pccl-20 signature mime-setup
mail-mime-setup semi-setup mime-pgp pgg-def mime-play filename
mime-image modb-standard elmo-imap4 time-stamp emacsbug bbdb-autoloads
init-wl wl-demo wl-draft eword-encode wl-template sendmail elmo-net
elmo-cache elmo-map elmo-dop wl-news wl-address wl-thread wl-folder wl
wl-e21 wl-spam wl-action wl-summary wl-refile wl-util pp elmo-flag
elmo-localdir wl-message elmo-mime mmelmo-buffer mmelmo-imap mime-view
mime-conf calist semi-def mmimap mime-parse mmbuffer mmgeneric
elmo-multi elmo-spam elsp-header elsp-generic elmo elmo-signal
wl-highlight wl-vars wl-version epg-config elmo-msgdb modb
modb-generic modb-entity luna mime elmo-util emu invisible inv-23 poem
poem-e20 poem-e20_3 utf7 eword-decode mel mime-def alist std11
mcharset mcs-20 mcs-e20 pces pces-e20 pces-20 broken pcustom elmo-date
elmo-vars elmo-version path-util poe pym static apel-ver product
w3m-load mime-w3m w3m browse-url doc-view jka-compr image-mode
w3m-hist w3m-fb bookmark-w3m w3m-ems w3m-ccl ccl w3m-favicon w3m-image
w3m-proc w3m-util disp-table whitespace linum hl-line
multiple-cursors-autoloads package savehist lawlist-calculator
ps-print ps-def lpr flyspell ispell auto-save-buffers-enhanced bbdb
timezone find-func dired-aux dired yasnippet help-mode
multiple-cursors mc-separate-operations rectangular-region-mode
mc-mark-more thingatpt mc-cycle-cursors mc-edit-lines
multiple-cursors-core rect saveplace lawlist-tex-mode pcase compile
shell pcomplete comint ansi-color ring skeleton compare-w desktop
frameset init-tabbar tabbar lawlist-org lawlist-calendar advice
edmacro kmacro derived org-toodledo mailcap-toodledo lawlist-tls
http-post-simple url-http tls url-auth url-gw url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util url-parse auth-source eieio byte-opt bytecomp byte-compile
cconv eieio-core password-cache url-vars mailcap json xml w3mexcerpt
noutline outline easy-mmode gnus-sum nnoo gnus-group gnus-undo nnmail
mail-source gnus-start gnus-spec gnus-int gnus-range message cl-macs
gv format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader gnus-win gnus gnus-ems nnheader gnus-util
mail-utils mm-util help-fns mail-prsvr wid-edit cl cl-loaddefs cl-lib
highlight-parentheses redo time-date tooltip electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer 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 make-network-process
cocoa ns multi-tty emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17065; Package emacs. (Sat, 22 Mar 2014 09:42:01 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#17065: 24.3.50;
 Revise line 5944 of window.el to use `window-width`,
 instead of `window-total-width`.
Date: Sat, 22 Mar 2014 10:41:00 +0100
> (defun broken-example ()
>    (interactive)
>    (window--display-buffer
>     ;; buffer
>     (get-buffer-create "*test*")
>     ;; window
>     (split-window (selected-window) nil 'right)
>     ;; type
>     'window
>     ;; alist
>     '((window-width . 82))
>     ;; dedicated
>     t)
>    (message "Window Width:  %s" (window-width (get-buffer-window "*test*"))) )

Conceptually, the `window-width' alist entry specifies the new total
width of the window, including fringes, scrollbars and vertical
dividers.  You mean that specifiying the number of text columns is more
intuitive?  I might agree, but unfortunately _all_ window resizing
functions intepret "width" in terms of the total width of a window.
Making an exception for this special case would only increase the
confusion.

The confusion has historical reasons and was not considered important,
likely so, because side-by-side windows are in use more frequently only
over the past years.  If, with emacs -Q, I do

(let ((window (split-window (selected-window) -20 'right)))
  (window-body-width window))

I get 16 text columns for the new window which is likely not what I
expected as someone using this function for the first time with an
explicit SIZE argument.

In any case, I will have to adjust some doc-strings and the Elisp
manual.  So far the only hint is the doc-string of `split-window-right'
which says

  Here, SIZE includes the width of the window's scroll bar; if there are
  no scroll bars, it includes the width of the divider column to the
  window's right, if any.

but I'm struggling with this issue ever since.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17065; Package emacs. (Sat, 23 Oct 2021 05:10:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 17065 <at> debbugs.gnu.org
Subject: Re: bug#17065: 24.3.50; Revise line 5944 of window.el to use
 `window-width`, instead of `window-total-width`.
Date: Fri, 22 Oct 2021 22:09:28 -0700
martin rudalics <rudalics <at> gmx.at> writes:

>> (defun broken-example ()
>>    (interactive)
>>    (window--display-buffer
>>     ;; buffer
>>     (get-buffer-create "*test*")
>>     ;; window
>>     (split-window (selected-window) nil 'right)
>>     ;; type
>>     'window
>>     ;; alist
>>     '((window-width . 82))
>>     ;; dedicated
>>     t)
>>    (message "Window Width:  %s" (window-width (get-buffer-window "*test*"))) )
>
> Conceptually, the `window-width' alist entry specifies the new total
> width of the window, including fringes, scrollbars and vertical
> dividers.  You mean that specifiying the number of text columns is more
> intuitive?  I might agree, but unfortunately _all_ window resizing
> functions intepret "width" in terms of the total width of a window.
> Making an exception for this special case would only increase the
> confusion.
>
> The confusion has historical reasons and was not considered important,
> likely so, because side-by-side windows are in use more frequently only
> over the past years.  If, with emacs -Q, I do
>
> (let ((window (split-window (selected-window) -20 'right)))
>   (window-body-width window))
>
> I get 16 text columns for the new window which is likely not what I
> expected as someone using this function for the first time with an
> explicit SIZE argument.
>
> In any case, I will have to adjust some doc-strings and the Elisp
> manual.  So far the only hint is the doc-string of `split-window-right'
> which says
>
>   Here, SIZE includes the width of the window's scroll bar; if there are
>   no scroll bars, it includes the width of the divider column to the
>   window's right, if any.
>
> but I'm struggling with this issue ever since.

(That was 7.5 years ago.)

Is any of the above still an issue these days?




Added tag(s) moreinfo. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 23 Oct 2021 05:10:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17065; Package emacs. (Sun, 24 Oct 2021 09:49:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 17065 <at> debbugs.gnu.org
Subject: Re: bug#17065: 24.3.50; Revise line 5944 of window.el to use
 `window-width`, instead of `window-total-width`.
Date: Sun, 24 Oct 2021 11:48:02 +0200
> Is any of the above still an issue these days?

I'll fix this in way that one has to provide an alist entry as

(window-width . (body-columns . 40))

to get a window with a text area that is forty frame columns wide.

martin




Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 29 Nov 2021 19:30:06 GMT) Full text and rfc822 format available.

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

Previous Next


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