Subject: 28.0.50; auto-hscroll-mode/current-line + show-paren-mode + gnus-summary-mode = bug

From: Stephen Berman <[email-masked]>
Date: Tue, 06 Oct 2020 20:53:53 +0200

I have observed a quirk in auto hscrolling the current line under
specific conditions.  I have only seen it in gnus-summary-mode, but
there can reproduce it reliably with the following recipe:

0. Save the attached email to a file.
1. emacs -Q
2. Type `M-x gnus' and enter `y' at the prompt to continue.
3. Type `Gf' and at the prompt enter the saved email file and then RET.
4. You should now be in the Gnus group buffer showing a document group
   created from that file; press RET to enter the group.  You should now
   be in a Gnus summary buffer containing only one line listing the
   saved email with point on that line.
5. Type `M-x customize-option RET auto-hscroll-mode RET' and in the
   Custom buffer select `Scroll only the current line' from the Value
   Menu and `Set for current session' from the State menu.  Type `q' to
   return to the Gnus summary buffer.
6. As a sanity check, type `C-e', moving point to the end of the line,
   which contains the email Subject line ending with `(this is a
   test)'.  Notice that the line remains scrolled with point after the
   closing paren: (point) -> 119.  Type `C-a' to move point to the
   beginning of the line.
7. From the Options menu check the item `Highlight Matching Parentheses'.
8. Type `C-e' again.
=> You should see the line scroll left to show the end of the line and
   then immediately scroll back, but with point remaining at 119, so the
   cursor is not visible.
9. If you now uncheck `Highlight Matching Parentheses' in the Options
   menu, hscrolling works again as expected, as in step 6.

I can reproduce this problem in Emacs 26, 27 and master, but I have only
been able to reproduce it in Gnus summary buffers, and only on the last
line of the summary and only when this line is longer than window-width
(so that hscrolling can happen) and the line ends with a pair of paren
characters (brackets and braces also show the effect) and
show-paren-mode is enabled.  Sometimes I have seen the hscroll get
restored after a several seconds, but other times this does not happen
(though I haven't tried waiting for more than maybe 15-20 seconds).
Non-final lines in the summary buffer that end with paren characters do
not show the anomalous hscrolling.  When I copy such a line to another
buffer and change that buffer's major mode to gnus-summary-mode, I
cannot reproduce the problem.

In GNU Emacs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.17, cairo version 1.17.3)
 of 2020-10-06 built on strobe-jhalfs
Repository revision: bcd09e9869a3f371024286d25743ebaf17f0be9d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Linux From Scratch SVN-20200401

Configured using:
 'configure 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD PDUMPER LCMS2

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