GNU bug report logs - #66128
28.2; visible-bell breaks setterm --inversescreen on

Previous Next

Package: emacs;

Reported by: tom <at> logand.com

Date: Wed, 20 Sep 2023 20:16:01 UTC

Severity: normal

Found in version 28.2

To reply to this bug, email your comments to 66128 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#66128; Package emacs. (Wed, 20 Sep 2023 20:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to tom <at> logand.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 20 Sep 2023 20:16:02 GMT) Full text and rfc822 format available.

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

From: tom <at> logand.com
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; visible-bell breaks setterm --inversescreen on
Date: Wed, 20 Sep 2023 22:14:49 +0200

in black linux console:

   $ setterm --inversescreen on

after that, in white linux console:

   $ emacs -Q --eval '(setq visible-bell t)'

all looks fine, emacs background is white
now press page-up key to trigger visual bell
and suddenly emacs background is black
visual bell should preserve terminal colors

the same problem is in a X based terminals but with the command:

   $ emacs -nw -Q --eval '(setq visible-bell t)'



In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
System Description: NixOS 23.05 (Stoat)

Configured using:
 'configure
 --prefix=/nix/store/5vx99s8cjzv8hcirly8g06alhjz0zaba-emacs-28.2
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-native-compilation'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $EMACSLOADPATH: 
  value of $EMACSNATIVELOADPATH: /nix/store/bvkjcb6pzd3d51q9j7yhf3bhljxlvb95-emacs-packages-deps/share/emacs/native-lisp::
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  eev-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-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
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/git/emacs-unoffice/junk hides ~/git/emacs-pdf/junk
~/git/emacs-unoffice/junk hides ~/git/emacs-framebuffer/junk
/run/current-system/sw/share/emacs/site-lisp/site-start hides /nix/store/bvkjcb6pzd3d51q9j7yhf3bhljxlvb95-emacs-packages-deps/share/emacs/site-lisp/site-start
/run/current-system/sw/share/emacs/site-lisp/site-start hides /nix/store/5vx99s8cjzv8hcirly8g06alhjz0zaba-emacs-28.2/share/emacs/site-lisp/site-start
/nix/store/bvkjcb6pzd3d51q9j7yhf3bhljxlvb95-emacs-packages-deps/share/emacs/site-lisp/elpa/transient-20230602.2121/transient hides /nix/store/5vx99s8cjzv8hcirly8g06alhjz0zaba-emacs-28.2/share/emacs/28.2/lisp/transient
/nix/store/bvkjcb6pzd3d51q9j7yhf3bhljxlvb95-emacs-packages-deps/share/emacs/site-lisp/elpa/let-alist-1.0.6/let-alist hides /nix/store/5vx99s8cjzv8hcirly8g06alhjz0zaba-emacs-28.2/share/emacs/28.2/lisp/emacs-lisp/let-alist

Features:
(shadow sort mail-extr emacsbug sendmail term/xterm xterm elm-mode
elm-interactive elm-font-lock elm-indent-simple elm-indent elm-imenu
elm-format reformatter elm-tags elm-util pulse color let-alist f
f-shortdoc shortdoc elm-defuns bmenu watch term2 shell2 vc-git
vc-dispatcher emacs-btap ffap emacs-unoffice view org ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint
org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp
ob-core ob-eval org-table oc-basic bibtex iso8601 ol org-keys oc
org-compat org-macs org-loaddefs find-func emacs-pdf printing ps-print
ps-print-loaddefs ps-def lpr emacs-framebuffer eev-beginner eev-load
eev-rcirc eev-videolinks eev-audiovideo eev-wconfig eev-rstdoc
eev-helpful eev-kla eev-testblocks eev-edit eev-pdflike eejump eev-brxxx
eev-code eev-hlinks eev-tlinks eev-wrap eev-env eev-elinks eev-plinks
eev-blinks eev-template0 eev-anchors eev-codings eepitch disp-table
eev-mode eev-eval eev-multiwindow eev-flash eev-intro dumb-jump popup s
email-eww cltl clhs notmuch notmuch-tree notmuch-jump notmuch-hello
notmuch-show notmuch-print notmuch-crypto notmuch-mua notmuch-message
notmuch-draft notmuch-maildir-fcc notmuch-address notmuch-company
notmuch-parser notmuch-wash coolj goto-addr icalendar diary-lib
diary-loaddefs cal-menu calendar cal-loaddefs notmuch-tag notmuch-lib
notmuch-compat hl-line mm-view mml-smime smime dig eww-lnum eww xdg
url-queue shr kinsoku svg xml dom mm-url gnus nnheader wid-edit
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 git-commit log-edit message rmc puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util rmail rmail-loaddefs time-date 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 autorevert filenotify magit-margin magit-transient
magit-process with-editor comp comp-cstr warnings rx shell pcomplete
server magit-mode transient cl-extra help-mode magit-git magit-base
magit-section format-spec cursor-sensor crm dash compat compat-29
diff-mode paredit slime-asdf grep slime-fancy slime-indentation
slime-cl-indent cl-indent 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 apropos compile
text-property-search etags fileloop generator xref project arc-mode
archive-mode noutline outline pp comint ansi-color ring hyperspec
thingatpt picolisp tsm easy-mmode edmacro kmacro pcase slime-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 subr-x map url-vars seq byte-opt gv 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 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
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 437231 11723)
 (symbols 48 32051 0)
 (strings 32 122018 4648)
 (string-bytes 1 4605735)
 (vectors 16 57338)
 (vector-slots 8 976678 13985)
 (floats 8 643 306)
 (intervals 56 425 0)
 (buffers 992 12))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Thu, 21 Sep 2023 05:01:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: tom <at> logand.com
Cc: 66128 <at> debbugs.gnu.org
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Thu, 21 Sep 2023 08:00:19 +0300
> From: tom <at> logand.com
> Date: Wed, 20 Sep 2023 22:14:49 +0200
> 
> 
> 
> in black linux console:
> 
>    $ setterm --inversescreen on
> 
> after that, in white linux console:
> 
>    $ emacs -Q --eval '(setq visible-bell t)'
> 
> all looks fine, emacs background is white
> now press page-up key to trigger visual bell
> and suddenly emacs background is black
> visual bell should preserve terminal colors

Emacs just sends to the terminal the sequence defined by the "vb"
termcap capability.  Is that not correct when the screen colors are
inverted?  Is this perhaps the problem of the terminal?

Btw, we always use the termcap's "vb", even when terminfo is
available; should we use the terminfo's "flash" instead?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Fri, 22 Sep 2023 20:19:02 GMT) Full text and rfc822 format available.

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

From: Tomas Hlavaty <tom <at> logand.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 66128 <at> debbugs.gnu.org
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Fri, 22 Sep 2023 22:18:14 +0200
Hi Eli,

thanks for the quick reply.

On Thu 21 Sep 2023 at 08:00, Eli Zaretskii <eliz <at> gnu.org> wrote:
> Emacs just sends to the terminal the sequence defined by the "vb"
> termcap capability.  Is that not correct when the screen colors are
> inverted?

I do not know.

> Is this perhaps the problem of the terminal?

No, I get the same behaviour in xfce4-terminal and kitty, so this does
not seem to be specific problem with the linux console.

I think I wrote it in the bug report too, under an X based terminal:

   $ emacs -nw -Q --eval '(setq visible-bell t)'

then press PgUp.

> Btw, we always use the termcap's "vb", even when terminfo is
> available; should we use the terminfo's "flash" instead?

I do not know.

Regards,

Tomas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Sat, 23 Sep 2023 05:40:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tomas Hlavaty <tom <at> logand.com>, Thomas Dickey <dickey <at> his.com>
Cc: 66128 <at> debbugs.gnu.org
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Sat, 23 Sep 2023 08:38:53 +0300
> From: Tomas Hlavaty <tom <at> logand.com>
> Cc: 66128 <at> debbugs.gnu.org
> Date: Fri, 22 Sep 2023 22:18:14 +0200
> 
> On Thu 21 Sep 2023 at 08:00, Eli Zaretskii <eliz <at> gnu.org> wrote:
> > Emacs just sends to the terminal the sequence defined by the "vb"
> > termcap capability.  Is that not correct when the screen colors are
> > inverted?
> 
> I do not know.
> 
> > Is this perhaps the problem of the terminal?
> 
> No, I get the same behaviour in xfce4-terminal and kitty, so this does
> not seem to be specific problem with the linux console.
> 
> I think I wrote it in the bug report too, under an X based terminal:
> 
>    $ emacs -nw -Q --eval '(setq visible-bell t)'
> 
> then press PgUp.
> 
> > Btw, we always use the termcap's "vb", even when terminfo is
> > available; should we use the terminfo's "flash" instead?
> 
> I do not know.

Thomas, could you perhaps help us out here?  This is about sending the
"visible bell" sequence to a terminal after "setterm --inversescreen on".
The original report is:

    $ setterm --inversescreen on
    $ emacs -Q --eval '(setq visible-bell t)'

  Then in Emacs do something that causes a bell, like try moving beyond
  the buffer's end.  This causes the Emacs background to become white,
  i.e. the visible-bell somehow countermands the inversescreen state.

Can you think of any reason for this behavior?  Do terminals honor
inversescreen when they perform the visible-bell function?  Emacs just
sends the sequence reported by the "vb" termcap capability of the
terminal when the visible-bell is triggered.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Mon, 25 Sep 2023 00:08:01 GMT) Full text and rfc822 format available.

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

From: Thomas Dickey <dickey <at> his.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 66128 <at> debbugs.gnu.org, Thomas Dickey <dickey <at> his.com>,
 Tomas Hlavaty <tom <at> logand.com>
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Sun, 24 Sep 2023 20:07:03 -0400
[Message part 1 (text/plain, inline)]
On Sat, Sep 23, 2023 at 08:38:53AM +0300, Eli Zaretskii wrote:
> > From: Tomas Hlavaty <tom <at> logand.com>
> > Cc: 66128 <at> debbugs.gnu.org
> > Date: Fri, 22 Sep 2023 22:18:14 +0200
> > 
> > On Thu 21 Sep 2023 at 08:00, Eli Zaretskii <eliz <at> gnu.org> wrote:
> > > Emacs just sends to the terminal the sequence defined by the "vb"
> > > termcap capability.  Is that not correct when the screen colors are
> > > inverted?
> > 
> > I do not know.
> > 
> > > Is this perhaps the problem of the terminal?
> > 
> > No, I get the same behaviour in xfce4-terminal and kitty, so this does
> > not seem to be specific problem with the linux console.
> > 
> > I think I wrote it in the bug report too, under an X based terminal:
> > 
> >    $ emacs -nw -Q --eval '(setq visible-bell t)'
> > 
> > then press PgUp.
> > 
> > > Btw, we always use the termcap's "vb", even when terminfo is
> > > available; should we use the terminfo's "flash" instead?
> > 
> > I do not know.
> 
> Thomas, could you perhaps help us out here?  This is about sending the
> "visible bell" sequence to a terminal after "setterm --inversescreen on".
> The original report is:
> 
>     $ setterm --inversescreen on

setterm doesn't have any special way of manipulating the terminal -
it uses the same escape sequences that emacs would

>     $ emacs -Q --eval '(setq visible-bell t)'
> 
>   Then in Emacs do something that causes a bell, like try moving beyond
>   the buffer's end.  This causes the Emacs background to become white,
>   i.e. the visible-bell somehow countermands the inversescreen state.
> 
> Can you think of any reason for this behavior?  Do terminals honor

https://github.com/util-linux/util-linux/blob/master/term-utils/setterm.c

https://github.com/util-linux/util-linux/blob/1e0ad14b3ac08d855cda6de346a65f9b834e00db/term-utils/setterm.c#L1005

	/* -inversescreen [on|off]. */
	if (ctl->opt_inversescreen)
		fputs(ctl->opt_invsc_on ? "\033[?5h" : "\033[?5l", stdout);

man console_codes

       ESC [ ? 5 h
              DECSCNM (default off): Set reverse-video mode.

but visual-bell can be the same thing

The "vb" termcap capability is found with "man 5 terminfo"

          flash_screen                flash     vb     visible bell (may
                                                       not move cursor)

to be "flash" in terminfo,
and "infocmp linux" shows

	flash=\E[?5h$<200/>\E[?5l,

which is to say,
	turn reverse-video on
	wait 200 milliseconds
	turn reverse-video off

> inversescreen when they perform the visible-bell function?  Emacs just
> sends the sequence reported by the "vb" termcap capability of the
> terminal when the visible-bell is triggered.
> 
> Thanks.

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
https://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Mon, 25 Sep 2023 05:05:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: dickey <at> his.com
Cc: 66128 <at> debbugs.gnu.org, tom <at> logand.com
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Mon, 25 Sep 2023 08:03:38 +0300
> Date: Sun, 24 Sep 2023 20:07:03 -0400
> From: Thomas Dickey <dickey <at> his.com>
> Cc: Tomas Hlavaty <tom <at> logand.com>, Thomas Dickey <dickey <at> his.com>,
> 	66128 <at> debbugs.gnu.org
> 
> setterm doesn't have any special way of manipulating the terminal -
> it uses the same escape sequences that emacs would
> 
> >     $ emacs -Q --eval '(setq visible-bell t)'
> > 
> >   Then in Emacs do something that causes a bell, like try moving beyond
> >   the buffer's end.  This causes the Emacs background to become white,
> >   i.e. the visible-bell somehow countermands the inversescreen state.
> > 
> > Can you think of any reason for this behavior?  Do terminals honor
> 
> https://github.com/util-linux/util-linux/blob/master/term-utils/setterm.c
> 
> https://github.com/util-linux/util-linux/blob/1e0ad14b3ac08d855cda6de346a65f9b834e00db/term-utils/setterm.c#L1005
> 
> 	/* -inversescreen [on|off]. */
> 	if (ctl->opt_inversescreen)
> 		fputs(ctl->opt_invsc_on ? "\033[?5h" : "\033[?5l", stdout);
> 
> man console_codes
> 
>        ESC [ ? 5 h
>               DECSCNM (default off): Set reverse-video mode.
> 
> but visual-bell can be the same thing
> 
> The "vb" termcap capability is found with "man 5 terminfo"
> 
>           flash_screen                flash     vb     visible bell (may
>                                                        not move cursor)
> 
> to be "flash" in terminfo,
> and "infocmp linux" shows
> 
> 	flash=\E[?5h$<200/>\E[?5l,
> 
> which is to say,
> 	turn reverse-video on
> 	wait 200 milliseconds
> 	turn reverse-video off

Thanks.  So Emacs should ideally reverse the sequence when the
terminal is in the reverse-video mode, or at least send the "\033[?5h"
sequence after sending "flash"?  But can Emacs know that the terminal
is in this mode at startup?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Mon, 25 Sep 2023 08:08:02 GMT) Full text and rfc822 format available.

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

From: Thomas Dickey <dickey <at> his.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 66128 <at> debbugs.gnu.org, tom <at> logand.com, dickey <at> his.com
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Mon, 25 Sep 2023 04:07:22 -0400
[Message part 1 (text/plain, inline)]
On Mon, Sep 25, 2023 at 08:03:38AM +0300, Eli Zaretskii wrote:
...
> Thanks.  So Emacs should ideally reverse the sequence when the
> terminal is in the reverse-video mode, or at least send the "\033[?5h"
> sequence after sending "flash"?  But can Emacs know that the terminal
> is in this mode at startup?

I don't see how - the usual way (an escape sequence which returns this
information) is not documented for Linux in console_codes.

Lacking that, you'd rely upon the user to tell Emacs what to do.

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
https://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66128; Package emacs. (Mon, 25 Sep 2023 08:52:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: dickey <at> his.com
Cc: 66128 <at> debbugs.gnu.org, tom <at> logand.com
Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on
Date: Mon, 25 Sep 2023 11:50:39 +0300
> Date: Mon, 25 Sep 2023 04:07:22 -0400
> From: Thomas Dickey <dickey <at> his.com>
> Cc: dickey <at> his.com, tom <at> logand.com, 66128 <at> debbugs.gnu.org
> 
> On Mon, Sep 25, 2023 at 08:03:38AM +0300, Eli Zaretskii wrote:
> ...
> > Thanks.  So Emacs should ideally reverse the sequence when the
> > terminal is in the reverse-video mode, or at least send the "\033[?5h"
> > sequence after sending "flash"?  But can Emacs know that the terminal
> > is in this mode at startup?
> 
> I don't see how - the usual way (an escape sequence which returns this
> information) is not documented for Linux in console_codes.
> 
> Lacking that, you'd rely upon the user to tell Emacs what to do.

I see.  I guess we will need to ask such users to customize the
inverse-video variable to a non-nil value, and then change
tty_ring_bell accordingly.

Thanks.




This bug report was last modified 222 days ago.

Previous Next


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