GNU bug report logs - #68786
30.0.50; Horizontal overscroll

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Andrey Listopadov <andreyorst@HIDDEN>; dated Sun, 28 Jan 2024 21:47:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 68786 <at> debbugs.gnu.org:


Received: (at 68786) by debbugs.gnu.org; 29 Jan 2024 18:01:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 29 13:01:33 2024
Received: from localhost ([127.0.0.1]:33409 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rUVwr-0006EB-2s
	for submit <at> debbugs.gnu.org; Mon, 29 Jan 2024 13:01:33 -0500
Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:53258)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andreyorst@HIDDEN>) id 1rUVwp-0006Ds-BL
 for 68786 <at> debbugs.gnu.org; Mon, 29 Jan 2024 13:01:31 -0500
Received: by mail-lf1-x12f.google.com with SMTP id
 2adb3069b0e04-51025cafb51so4197959e87.2
 for <68786 <at> debbugs.gnu.org>; Mon, 29 Jan 2024 10:01:22 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1706551276; x=1707156076; darn=debbugs.gnu.org;
 h=mime-version:message-id:in-reply-to:date:subject:cc:to:from
 :user-agent:references:from:to:cc:subject:date:message-id:reply-to;
 bh=8eQZQpOT8Gc4FN4PV/jxJd3h2AeslaGJo7ZT2/IoKZY=;
 b=H3pRWGj3N9ZpUL5E3F6w+1a7LS0zr4mRsL9dHhXQjYURKxF3h557+SXFpG+NgaWVK+
 8wDcbQkdfUr56hblwwE1rDS8Kw6HYsephwi7w58/xs6RNRvnObWWU6j8Ah5bEF11Vur5
 EEfLOlGnH4xFtfyasaO4XV9GRtzE0ZuEyvopsA9VMqNhsprFsx05Y+Rn56VN8TISkM+H
 bEka7HdPqV3Ajpnpkf5s8nw9/3hpJK4h044fCnNZIA94xR2AoBbDdsx0zCnrg6Vei4FW
 7yftP6oGY85FcXyTv6RhTHYrjyTqyXqhbGh4OeTGKEC/NAPzXk+c4I+8UtPblbpHecd/
 q9SA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1706551276; x=1707156076;
 h=mime-version:message-id:in-reply-to:date:subject:cc:to:from
 :user-agent:references:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=8eQZQpOT8Gc4FN4PV/jxJd3h2AeslaGJo7ZT2/IoKZY=;
 b=ZkfFyy2k8CmRqhRVrO6MXufhpUOIxb2i9bMLWwsMxfxkLDMH1MxIZx7e5fBAV/b2Aj
 08GImRsSxeqGg7baobmpBUaXD8/CmmsfqnmJhiEIvTT7NpnO3n0HtJldmWCgg43Pu/Zf
 JU/5HGZb2LWI4JsVmM0SyhR0UeR2AJ4lSp6WHmROA3ex8QnLxedhXjq08AtRUGtq1/tc
 pUHPibqtIKzBCIKAQRmOmhjoG4Ng+lmP2Siu4Ku/ioZ88c00J1dbILsIjIXnDasWrMv7
 PlAqBhC4sS78AlebTqRO/GkwgY9ejNNHH3uydR5Tebn1pL8v5jF1AaFs6ifQEJV1/qqa
 nqgA==
X-Gm-Message-State: AOJu0YzjjNmd0/3Xy4iEDeTp6ZgB4TTztJOj8VwRHZhITQg5CjpobWoK
 MRVno/dkd5H2WJdy7o5LNYEd3oY8a4iuXhkabeyq3i/rw1acaPrt3FtocOvcs4Y=
X-Google-Smtp-Source: AGHT+IFMUL5F3uhlQVJdUhd8OLluZvQrv4d4/ewvFbyWD6gfnyZRsUNicLfRskn9BsPJ2zOnUCUH6w==
X-Received: by 2002:a05:6512:2209:b0:50e:dfb7:607d with SMTP id
 h9-20020a056512220900b0050edfb7607dmr5055268lfu.55.1706551276146; 
 Mon, 29 Jan 2024 10:01:16 -0800 (PST)
Received: from toolbox.smtp.gmail.com ([185.9.75.213])
 by smtp.gmail.com with ESMTPSA id
 t1-20020ac24c01000000b0050e94329e7csm1180384lfq.269.2024.01.29.10.01.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 29 Jan 2024 10:01:15 -0800 (PST)
References: <871qa1b08i.fsf@HIDDEN> <86msso4abj.fsf@HIDDEN>
User-agent: mu4e 1.8.11; emacs 30.0.50
From: Andrey Listopadov <andreyorst@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#68786: 30.0.50; Horizontal overscroll
Date: Mon, 29 Jan 2024 20:53:34 +0300
In-reply-to: <86msso4abj.fsf@HIDDEN>
Message-ID: <87wmrs9fyt.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 4.8 (++++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Eli Zaretskii writes: > The above can also be done with
 horizontal
 scroll bar, if instead of > dragging the scroll-bar's "thumb" you click on
 the arrow at the right > side of the scroll bar. At least it works here
 (perhaps [...] 
 Content analysis details:   (4.8 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
 [185.9.75.213 listed in zen.spamhaus.org]
 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in
 bl.spamcop.net
 [Blocked - see <https://www.spamcop.net/bl.shtml?185.9.75.213>]
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (andreyorst[at]gmail.com)
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2a00:1450:4864:20:0:0:0:12f listed in]
 [list.dnswl.org]
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-Debbugs-Envelope-To: 68786
Cc: 68786 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 3.8 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Eli Zaretskii writes: > The above can also be done with horizontal
    scroll bar, if instead of > dragging the scroll-bar's "thumb" you click on
    the arrow at the right > side of the scroll bar. At least it works here (perhaps
    [...] 
 
 Content analysis details:   (3.8 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
                             [185.9.75.213 listed in zen.spamhaus.org]
  1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in
                             bl.spamcop.net
                [Blocked - see <https://www.spamcop.net/bl.shtml?185.9.75.213>]
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [2a00:1450:4864:20:0:0:0:12f listed in]
                             [list.dnswl.org]
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (andreyorst[at]gmail.com)
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager


Eli Zaretskii <eliz@HIDDEN> writes:

> The above can also be done with horizontal scroll bar, if instead of
> dragging the scroll-bar's "thumb" you click on the arrow at the right
> side of the scroll bar.  At least it works here (perhaps this depends
> on the toolkit, I don't know).

I'm using GNOME, and in its toolkit the scrollbars are "modern",
i.e. flat and without any buttons.

> So I think the inconsistency is much smaller than you think, and we
> should stop right here and talk about why this makes you uncomfortable
> or requires any changes in your opinion.  I personally find nothing
> bad or unexpected with the ability to scroll past the last visible
> character: after all, if the user doesn't want that, he/she can avoid
> scrolling farther than he/she wants.

The reason I made the piece of code that prevents this is because
usually when I'm scrolling to the right (I'm using line truncation all
the time), I don't want to overshoot the code I want to see.  With the
touchpad it's quite easy to do, because the acceleration of the
scrolling motion is pretty high, but I usually want it to be that high,
otherwise it feels like a /drag/.

> It is true that most other applications don't vary the thumb size, but
> Emacs has always behaved like it does, so changing it to follow the
> other apps is not an option at this point, at least not by default.
>
> Having said that, ...
>
>> I would like to ask for a feature to limit the horizontal scroll by the
>> longest line, much like the horizontal scrollbar works by default. It
>> may not be the longest line in the buffer, as calculating this for huge
>> buffers is probably too impactful unless we can cache the longest line
>> length until the buffer is changed.  Or maybe Emacs already knows the
>> buffer's "dimensions", I don't know.
>
> ... I won't object to such a feature, provided that it's optional and
> OFF by default, and also that it is supported on as many toolkits as
> is practical.  Patches welcome.

Fair enough.  Right now I can't send a patch, because I don't have the
solution for this problem.  The piece of code I sent works for me, but
it's not general by any means, and has a lot of subtle flaws.

Maybe if you could point me out to parts of Emacs that do the
calculation of the longest visible line for the scroll bar so I could
adopt it instead of doing hacky unscallable-face-font-width-based
calculation?  Or maybe help me think of a better way to calculate this.

Thanks!




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68786; Package emacs. Full text available.

Message received at 68786 <at> debbugs.gnu.org:


Received: (at 68786) by debbugs.gnu.org; 29 Jan 2024 12:02:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 29 07:02:27 2024
Received: from localhost ([127.0.0.1]:59191 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rUQLL-0004BS-AR
	for submit <at> debbugs.gnu.org; Mon, 29 Jan 2024 07:02:27 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:51250)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rUQLJ-0004BF-MG
 for 68786 <at> debbugs.gnu.org; Mon, 29 Jan 2024 07:02:26 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rUQL6-0008Cb-2p; Mon, 29 Jan 2024 07:02:12 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=Yywf+k61JvmWRj0ekfXJ3lBpyAfrq7ie808Pu2szOKQ=; b=L3cqOLiHL2eC
 R2EyLEfgo/EcUN/fUvkAI/tvCwTnz5cYFrt52RL1pLgcNwmtKT7zFvZkhHUKor5FqtDg2NWn/H+V8
 ADN/+IkyyXNGwVWxczuypeBtIB+AIpF2RjaucDDnB+QQGqVdyrw8Z1qWfxBEGG8HMs6p7FI2JevC+
 seUH9j32Reya1xUbCroWMSj6l1ogQ1GpZ7MPUJ819DM7ggoD0cSnMKGX8K2WXsTa7xXRkerXmDnOe
 5ZX2Wv+10vQanPjnE4GwGtRFCds7R19ornzIAOl1RaNqhA052Iw+z6v8rMQz1085kYTa0kJW4Ruiu
 /KM0YRle0O5yTwrinGqHWw==;
Date: Mon, 29 Jan 2024 14:02:08 +0200
Message-Id: <86msso4abj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Andrey Listopadov <andreyorst@HIDDEN>
In-Reply-To: <871qa1b08i.fsf@HIDDEN> (message from Andrey Listopadov on
 Sun, 28 Jan 2024 23:41:57 +0300)
Subject: Re: bug#68786: 30.0.50; Horizontal overscroll
References: <871qa1b08i.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68786
Cc: 68786 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Andrey Listopadov <andreyorst@HIDDEN>
> Date: Sun, 28 Jan 2024 23:41:57 +0300
> 
> However, when scrolling to the right with the touchpad (to avoid
> confusion view goes to the right and the text goes to the left), we can
> do this:
> 
> |_____________Emacs____________|
> |ation.                        |
> |ts buffer.                    |
> |                              |
> |                              |
> |                              |
> |______________________________|
> |-------------------------=====|
> |______________________________|
> 
> The scrollbar itself doesn't allow us to go beyond the longest text
> visible text.  Scrolling with the touchpad, however, allows for this.
> We can even do this:
> 
> |_____________Emacs____________|
> |                              |
> |                              |
> |                              |
> |                              |
> |                              |
> |______________________________|
> |----------------------------==|
> |______________________________|
> 
> Or even this:
> 
> |_____________Emacs____________|
> |                              |
> |                              |
> |                              |
> |                              |
> |                              |
> |______________________________|
> |-----------------------------=|
> |______________________________|
> 
> The text is so far left, that the draggable portion of the scrollbar no
> longer shrinks.

The above can also be done with horizontal scroll bar, if instead of
dragging the scroll-bar's "thumb" you click on the arrow at the right
side of the scroll bar.  At least it works here (perhaps this depends
on the toolkit, I don't know).

So I think the inconsistency is much smaller than you think, and we
should stop right here and talk about why this makes you uncomfortable
or requires any changes in your opinion.  I personally find nothing
bad or unexpected with the ability to scroll past the last visible
character: after all, if the user doesn't want that, he/she can avoid
scrolling farther than he/she wants.

It is true that most other applications don't vary the thumb size, but
Emacs has always behaved like it does, so changing it to follow the
other apps is not an option at this point, at least not by default.

Having said that, ...

> I would like to ask for a feature to limit the horizontal scroll by the
> longest line, much like the horizontal scrollbar works by default. It
> may not be the longest line in the buffer, as calculating this for huge
> buffers is probably too impactful unless we can cache the longest line
> length until the buffer is changed.  Or maybe Emacs already knows the
> buffer's "dimensions", I don't know.

... I won't object to such a feature, provided that it's optional and
OFF by default, and also that it is supported on as many toolkits as
is practical.  Patches welcome.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68786; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 Jan 2024 21:46:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 28 16:46:29 2024
Received: from localhost ([127.0.0.1]:58482 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rUCyq-00023w-NV
	for submit <at> debbugs.gnu.org; Sun, 28 Jan 2024 16:46:29 -0500
Received: from lists.gnu.org ([2001:470:142::17]:44040)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andreyorst@HIDDEN>) id 1rUCyn-00023c-Ml
 for submit <at> debbugs.gnu.org; Sun, 28 Jan 2024 16:46:18 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <andreyorst@HIDDEN>)
 id 1rUCya-0007Od-Cx
 for bug-gnu-emacs@HIDDEN; Sun, 28 Jan 2024 16:46:04 -0500
Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <andreyorst@HIDDEN>)
 id 1rUCyP-0000mZ-MH
 for bug-gnu-emacs@HIDDEN; Sun, 28 Jan 2024 16:45:56 -0500
Received: by mail-wm1-x334.google.com with SMTP id
 5b1f17b1804b1-40ef6f10b56so2242845e9.2
 for <bug-gnu-emacs@HIDDEN>; Sun, 28 Jan 2024 13:45:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1706478352; x=1707083152; darn=gnu.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:user-agent:from:to:cc:subject:date:message-id:reply-to;
 bh=/m3+sPYFUBDOwUrPAQG+R95kOkPiuMlA2roFCvJq/iI=;
 b=fmdvJM8axnzT3lhUxyWBqfEeaCVWRUK08N9v1BT0hRm2gd5a0Z3g6MLvUAFJUQb+ju
 UhctEeQK7DUunR8nKBmbBA6wQPavSK0zJrAXNLpeKxq9oEf2AO5yCmI5SIJ+9Wy9PYah
 FvS6FIDpw9hAdFZhPsFz4KodcSXCtdGWmG5pM0YDn7yNsiVGog//biRlZgQd2LwnsH8N
 NUmiNOqqw1udf2He+mqC4MHLpSbv0vb8bFa5s9RwcRmArRINezvUwpPZqNYy2ZrGVd9J
 pNGj8TFUvBoYAP+Cl5A7SzV7N6ELzbpmvurOglas3noA9VnBZcn74z4n1UWFmI30m8FA
 e13g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1706478352; x=1707083152;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:user-agent:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=/m3+sPYFUBDOwUrPAQG+R95kOkPiuMlA2roFCvJq/iI=;
 b=uKYyHqUTUoQAyRC1ub1oq8pNDHtmGOlRYkp/zpE1/xxh9JJOVXD6pg/FSvlw/nwWni
 NR/h/vq0PrmfC1f59ZC/U8Y0sqtNaTkkNUpQ4NqEu4N72qzX/pwo12607Olhj2X8sdhU
 cVStVgD/QgB7wg6e9LfXDQfxgeuB5gybuNKkPCk6caJxY7Md4xSU8epZbexqb/Yzz3Nw
 pTt4JAze9WVrfWLUhqj0hrZ1LOyhy+j3iwlWf58ClQBFVgbLmIOKpCg9pruaVBSwwIGm
 RTr6uiawd1RN+JuuK5S3WbTo2+oETLoXeudV7Ngl1Kn6NOj+1dSZ0KxS+Y5zOCdk/yvf
 HAVw==
X-Gm-Message-State: AOJu0YwT9eZJgYtk37IRfVLmp2ditFeHJNTXctW1jR2SCo3tK0Yar7cx
 5i52ZBqgf1b4m/M0KlynXumMyyRdm/NcLMLpF2ctOmC7rT84SaP9oi2Kky4LvYw=
X-Google-Smtp-Source: AGHT+IHdB5rhezGfvFlXtBCPQU35dlTJsD9lsQ+NwUzP1pYnR2C8wUhSN27hNXt5cW6BWS1sD4VgyA==
X-Received: by 2002:a05:600c:1906:b0:40e:b9fb:103 with SMTP id
 j6-20020a05600c190600b0040eb9fb0103mr2903308wmq.23.1706478351537; 
 Sun, 28 Jan 2024 13:45:51 -0800 (PST)
Received: from toolbox.smtp.gmail.com (kotobank.ch. [195.154.83.132])
 by smtp.gmail.com with ESMTPSA id
 s19-20020a05600c45d300b0040d5a9d6b68sm12165460wmo.6.2024.01.28.13.45.50
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 28 Jan 2024 13:45:51 -0800 (PST)
User-agent: mu4e 1.8.11; emacs 30.0.50
From: Andrey Listopadov <andreyorst@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; Horizontal overscroll
Date: Sun, 28 Jan 2024 23:41:57 +0300
X-Debbugs-Cc: 
Message-ID: <871qa1b08i.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2a00:1450:4864:20::334;
 envelope-from=andreyorst@HIDDEN; helo=mail-wm1-x334.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)


Hello.

Perhaps it is not a bug, but a feature request, although I have seen
examples when the default behavior can be considered a bug by some
people unfamiliar with Emacs.  I'm hardly unfamiliar with Emacs, but I
also consider the default behavior somewhat weird and less useful than
what I'm going to describe here.

Imagine, this is a GUI Emacs with one window, and
`horizontal-scroll-bar-mode' is enabled:

|_____________Emacs____________|
|;; This buffer is for text tha|
|;; To create a file, visit it |
|                              |
|                              |
|                              |
|______________________________|
|=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D------------------| <- horizontal scro=
llbar
|______________________________| <- mode-line & echo area below

I'm a laptop user, and I mostly use the touchpad to navigate through the
text in the window.  Vertical scrolling is handled by the
`pixel-scroll-precision-mode' and I love how smooth the text is being
scrolled with it.

Horizontal scrolling is enabled by setting the `mouse-wheel-tilt-scroll'
variable, so my touchpad allows me to scroll the text in all directions.

As you can see in the drawing above, the `*scratch*' buffer is
displayed, and the text goes beyond the window borders.  This is not the
default behavior, but I enabled line truncation to illustrate.  The
scrollbar is denoted with `=3D' for the draggable portion and `-' for the
rest of the scrollbar.

Now, in `emacs -Q', after enabling line truncation and horizontal
scrolling, let's scroll the text to the right side of the text:

|_____________Emacs____________|
|, and for Lisp evaluation.    |
| and enter text in its buffer.|
|                              |
|                              |
|                              |
|______________________________|
|------------------=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|
|______________________________|

So far so good.

Now, since I'm using the touchpad, I'll also set
`mouse-wheel-tilt-scroll' for this session.  With that, we can scroll
the text back with the touchpad:

|_____________Emacs____________|
|r text that is not saved, and |
| visit it with =E2=80=98C-x C-f=E2=80=99 and e|
|                              |
|                              |
|                              |
|______________________________|
|---------=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D---------|
|______________________________|

However, when scrolling to the right with the touchpad (to avoid
confusion view goes to the right and the text goes to the left), we can
do this:

|_____________Emacs____________|
|ation.                        |
|ts buffer.                    |
|                              |
|                              |
|                              |
|______________________________|
|-------------------------=3D=3D=3D=3D=3D|
|______________________________|

The scrollbar itself doesn't allow us to go beyond the longest text
visible text.  Scrolling with the touchpad, however, allows for this.
We can even do this:

|_____________Emacs____________|
|                              |
|                              |
|                              |
|                              |
|                              |
|______________________________|
|----------------------------=3D=3D|
|______________________________|

Or even this:

|_____________Emacs____________|
|                              |
|                              |
|                              |
|                              |
|                              |
|______________________________|
|-----------------------------=3D|
|______________________________|

The text is so far left, that the draggable portion of the scrollbar no
longer shrinks.

Two parts are counter-intuitive to most people I know.

The first one is that the scrollbar only allows for scrolling as far as
the longest VISIBLE line. In most other software that provide text
editing capabilities, the scrollable area is a rectangle shape that
wraps the longest line in the entire buffer and the total amount of
lines.  Something like this:

        window
        width
     <----------->
      __________________
   ^ |some line  |     | ^
   : |some line  |     | :
w  h |           |     | s
i  e |longer line|     | c
n  i |           |     | r  h
d  g |           |     | o  e
o  h |           |     | l  i
w  t |           |     | l  g
   : |           |     |    h
   v |-----------|     | b  t
     |the longest| line| o
     |           |     | x
     |           |     | :
     |the last li|ne   | v
     <---------------->
        scroll box
           width

I hope you can decypher the dimensions of the window and the scroll box.

Emacs, however, uses the vertical size of the scroll box conventionally
but limits the horizontal size to the longest visible line.

The second unconventional part is that we can increase the width of the
scroll box by simply scrolling with the touchpad.  Usually, that's not
the case. I know that in Emacs we can also scroll beyond the last line
in the document for editing convenience, and the behavior of the
horizontal scroll can be described similarly, but the behavior of the
scrollbars doesn't match.

For instance, we can scroll past the last line of text with the vertical
scroll bar, but we can't do the same with the horizontal scrollbar.  We
can't scroll horizontally long past the last character in the line, but
we can't scroll vertically long past the last line in the buffer.

I've been using the following piece of code for some years to workaround
this problem:

(defun truncated-lines-p ()
  "Non-nil if any line is longer than `window-width' + `window-hscroll'.

Returns t if any line exceeds the right border of the window.
Used for stopping scroll from going beyond the longest line.
Based on `so-long-detected-long-line-p'."
  (let ((buffer (current-buffer))
        (tabwidth tab-width))
    (or (> (buffer-size buffer) 1000000) ; avoid searching in huge buffers
        (with-temp-buffer
          (insert-buffer-substring buffer)
          (setq-local tab-width tabwidth)
          (untabify (point-min) (point-max))
          (goto-char (point-min))
          (let* ((window-width
                  ;; this computes a more accurate width rather than `windo=
w-width', and respects
                  ;; `text-scale-mode' font width.
                  (/ (window-body-width nil t) (window-font-width)))
                 (hscroll-offset
                  ;; `window-hscroll' returns columns that are not affected=
 by
                  ;; `text-scale-mode'.  Because of that, we have to recomp=
ute the correct
                  ;; `window-hscroll' by multiplying it with a non-scaled v=
alue and
                  ;; dividing it with a scaled width value, rounding it to =
the upper
                  ;; boundary.  Since there's no way to get unscaled value,=
 we have to get
                  ;; a width of a face that is not scaled by `text-scale-mo=
de', such as
                  ;; `window-divider' face.
                  (ceiling (/ (* (window-hscroll) (window-font-width nil 'w=
indow-divider))
                              (float (window-font-width)))))
                 (line-number-width
                  ;; compensate line numbers width
                  (if (bound-and-true-p display-line-numbers-mode)
                      (- display-line-numbers-width)
                    0))
                 (threshold (+ window-width hscroll-offset line-number-width
                               -2))) ; compensate imprecise calculations
            (catch 'excessive
              (while (not (eobp))
                (let ((start (point)))
                  (save-restriction
                    (narrow-to-region start (min (+ start 1 threshold)
                                                 (point-max)))
                    (forward-line 1))
                  (unless (or (bolp)
                              (and (eobp) (<=3D (- (point) start)
                                              threshold)))
                    (throw 'excessive t))))))))))

This function checks if any lines in the buffer exceed the width of the
window.  I tried my best to take into account things like text scaling,
width of the line numbers, and horizontal scroll offset.  It works
reliably enough, although not as precise as the horizontal scrollbar.

I use it with the following advice:

(define-advice scroll-left (:before-while (&rest _) prevent-overscroll)
  (and truncate-lines
       (not (memq major-mode no-hscroll-modes))
       (truncated-lines-p)))

This function is not cheap, as it walks through every line in the
buffer, calculating its width, so I restrict this function to buffers
smaller than 1000000 characters. I also have to `untabify' the whole
buffer in a temporary buffer because tab characters don't play too well
with width calculation.

Sorry for such a long explanation of the issue, but I can't describe it
in shorter terms, because I already tried a few years back on Reddit,
and nobody understood the problem I'm describing.

I would like to ask for a feature to limit the horizontal scroll by the
longest line, much like the horizontal scrollbar works by default. It
may not be the longest line in the buffer, as calculating this for huge
buffers is probably too impactful unless we can cache the longest line
length until the buffer is changed.  Or maybe Emacs already knows the
buffer's "dimensions", I don't know.

Hope my explanation was clear enough.


In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2024-01-28 built on toolbox
Repository revision: adf32eb69ea34b9c057c9a4321e5f05b00a7c940
Repository branch: master
System Description: Fedora Linux 38 (Container Image)

Configured using:
 'configure --without-compress-install --with-native-compilation=3Dyes
 --with-pgtk --with-mailutils --with-xwidgets
 --prefix=3D/var/home/alist/.local'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER XIM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  outline-minor-mode: t
  electric-pair-mode: t
  isayt-mode: t
  savehist-mode: t
  delete-selection-mode: t
  pixel-scroll-precision-mode: t
  global-auto-revert-mode: t
  repeat-mode: t
  vertico-mode: t
  marginalia-mode: t
  corfu-popupinfo-mode: t
  global-corfu-mode: t
  corfu-mode: t
  global-region-bindings-mode: t
  recentf-mode: t
  server-mode: t
  common-lisp-modes-mode: t
  override-global-mode: t
  puni-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  hs-minor-mode: t

Load-path shadows:
/var/home/alist/.config/emacs/elpa/transient-20240121.2000/transient hides =
/var/home/alist/.local/share/emacs/30.0.50/lisp/transient
/var/home/alist/.config/emacs/elpa/modus-themes-20240104.1122/theme-loaddef=
s hides /var/home/alist/.local/share/emacs/30.0.50/lisp/theme-loaddefs

Features:
(shadow mail-extr sort emacsbug tabify help-fns radix-tree misearch
multi-isearch mu4e mu4e-org mu4e-main mu4e-view mu4e-headers
mu4e-compose mu4e-draft mu4e-actions smtpmail mu4e-search mu4e-lists
mu4e-bookmarks mu4e-mark mu4e-message flow-fill hl-line mu4e-contacts
mu4e-update mu4e-folders mu4e-server mu4e-context mu4e-vars mu4e-helpers
mu4e-config magit-bookmark bookmark ido puni pulse color vc-hg vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference flyspell
ispell magit-extras face-remap vc-git vc-dispatcher vertico-directory
mule-util ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls
dig gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group
gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7
nnoo parse-time gnus-spec gnus-int gnus-range gnus-win gnus nnheader
range ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex
iso8601 ol-bbdb ol-w3m ol-doi org-link-doi org-tempo tempo cus-start
blog org-capture org-refile ob-fennel fennel-proto-repl fennel-mode
thingatpt inf-lisp xref magit-submodule 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 sendmail yank-media puny rfc822 mml mml-sec epa epg
rfc6068 epg-config gnus-util 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 magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
magit-mode transient magit-git magit-base magit-section cursor-sensor
crm project ob-lua ob-shell shell org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-src ob-comint org-pcomplete pcomplete
org-list org-footnote org-faces org-entities time-date ob-emacs-lisp
ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys
oc org-loaddefs find-func cal-menu calendar cal-loaddefs org-compat
org-version org-macs format-spec noutline outline elec-pair isayt
disp-table hideshow savehist delsel pixel-scroll cua-base autorevert
filenotify repeat vertico marginalia corfu-popupinfo cape corfu compat
region-bindings recentf tree-widget init gnome-proxy gsettings s
gvariant parsec dash clojure-compilation-mode derived compile
text-property-search comint ansi-osc ansi-color ring server treesit
dired dired-loaddefs use-package-delight formfeed
modus-vivendi-tritanopia-theme modus-operandi-tritanopia-theme
modus-vivendi-deuteranopia-theme modus-operandi-deuteranopia-theme
modus-vivendi-tinted-theme modus-operandi-tinted-theme
modus-vivendi-theme modus-operandi-theme modus-themes dbus xml
common-lisp-modes novice cus-edit pp cus-load wid-edit font mode-line
messages defaults edmacro kmacro functions use-package-bind-key bind-key
local-config delight comp comp-cstr warnings icons comp-run comp-common
rx use-package-ensure cl-extra help-mode use-package-core early-init
finder-inf blog-autoloads cape-autoloads clj-decompiler-autoloads
clj-refactor-autoloads cider-autoloads clojure-mode-autoloads
common-lisp-modes-autoloads consult-autoloads corfu-terminal-autoloads
corfu-autoloads csv-mode-autoloads delight-autoloads eat-autoloads
expand-region-autoloads fennel-mode-autoloads geiser-guile-autoloads
geiser-autoloads gnome-proxy-autoloads gsettings-autoloads
gvariant-autoloads inflections-autoloads isayt-autoloads
jdecomp-autoloads lsp-java-autoloads lsp-metals-autoloads
dap-mode-autoloads lsp-docker-autoloads bui-autoloads
lsp-treemacs-autoloads lsp-mode-autoloads f-autoloads
marginalia-autoloads markdown-mode-autoloads
message-view-patch-autoloads magit-autoloads pcase
magit-section-autoloads git-commit-autoloads modus-themes-autoloads
mu4e-alert-autoloads alert-autoloads log4e-autoloads gntp-autoloads
multiple-cursors-autoloads orderless-autoloads ox-hugo-autoloads
package-lint-flymake-autoloads package-lint-autoloads paredit-autoloads
parsec-autoloads parseedn-autoloads parseclj-autoloads
phi-search-autoloads popon-autoloads puni-autoloads easy-mmode
queue-autoloads racket-mode-autoloads region-bindings-autoloads
request-autoloads scala-mode-autoloads separedit-autoloads
edit-indirect-autoloads sesman-autoloads sly-autoloads spinner-autoloads
sql-indent-autoloads tomelr-autoloads transient-autoloads
treemacs-autoloads cfrs-autoloads posframe-autoloads ht-autoloads
hydra-autoloads lv-autoloads pfuture-autoloads ace-window-autoloads
avy-autoloads s-autoloads dash-autoloads vertico-autoloads
vundo-autoloads with-editor-autoloads info compat-autoloads
yaml-autoloads yaml-mode-autoloads yasnippet-autoloads
zig-mode-autoloads reformatter-autoloads package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win
term/common-win pgtk-dnd tool-bar dnd fontset image regexp-opt fringe
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 nadvice seq simple cl-generic indonesian philippine
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 abbrev obarray oclosure
cl-preloaded button loaddefs theme-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 xwidget-internal dbusbind inotify dynamic-setting
system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty
move-toolbar make-network-process native-compile emacs)

Memory information:
((conses 16 871826 200523) (symbols 48 42386 0)
 (strings 32 199102 4537) (string-bytes 1 6230251) (vectors 16 63320)
 (vector-slots 8 768925 33723) (floats 8 886 2057)
 (intervals 56 2159 854) (buffers 984 19))

--=20
Andrey Listopadov




Acknowledgement sent to Andrey Listopadov <andreyorst@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#68786; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 29 Jan 2024 18:15:01 UTC

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