Subject: 31.0.50; Force fringe refresh / force-window-update not affecting fringes
From: Michal Nazarewicz <[email-masked]>
To: [email-masked]
Date: Sat, 14 Dec 2024 20:31:00 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

I’m implementing fringe dimming in non-selected windows as an extension
of the NonGNU ELPA auto-dim-other-buffers package (see
<https://github.com/mina86/auto-dim-other-buffers.el/issues/27>).

<https://github.com/mina86/auto-dim-other-buffers.el/tree/fringes> is
a test code which tries to achieve it.  The expected behaviour is that
after enabling auto-dim-other-buffers-mode defined there, as you switch
between windows, the fringes of non-selected windows will be red.

Alas, it appears that fringes are redrawn lazily such that changing
window does not refresh the fringes.

For a bit more context, the package uses face-remap-add-relative and
:filtered faces, i.e. something like:

    (face-remap-add-relative
     'fringe
     '(:filtered (:window adob--dim t) auto-dim-other-buffers-fringe-face))

I’ve tried toggling fringe-mode when forcing window update with the
below code, but it did not do the trick.

    (defun adob--force-window-update (object)
      (force-window-update object)
      ;; Force fringes to be updated
      (when fringe-mode
        (dolist (wnd (if (windowp object)
                         (list object)
                       (get-buffer-window-list object nil t)))
          (let* ((frame  (window-frame wnd))
                 (params (frame-parameters frame))
                 (left   (alist-get 'left-fringe  params))
                 (right  (alist-get 'right-fringe params)))
            (when (and left right)
              (modify-frame-parameters
               frame '((left-fringe nil) (right-fringe nil)))
              (modify-frame-parameters
               frame `((left-fringe . ,left) (right-fringe . ,right))))))))

I think what I’d like is for force-window-update to force full fringe
redraw?  Honestly, I haven’t yet dug through all of the window and
fringe code so I’m not entirely sure where the main issue lays.

Configured using:
 'configure --prefix=/usr/local --enable-link-time-optimization
 --with-native-compilation=aot --without-dbus --without-gconf
 --without-gpm --without-gsettings --without-pop --without-selinux
 --without-systemd --without-toolkit-scroll-bars --with-x
 --with-x-toolkit=gtk3 --with-xinput2 --with-xml2 --with-tree-sitter
 'CFLAGS=-O2 -mtune=native -march=native -fstack-protector'
 'CPPFLAGS=-O2 -mtune=native -march=native -fstack-protector'
 'CXXFLAGS=-O2 -mtune=native -march=native -fstack-protector''

Configured features:
CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBSYSTEMD LIBXML2
MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS
TIFF TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_GB.utf8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  server-mode: t
  form-feed-mode: t
  auto-dim-other-buffers-mode: t
  global-auto-revert-mode: t
  icomplete-mode: t
  global-num3-mode: t
  num3-mode: t
  global-whitespace-mode: t
  whitespace-mode: t
  global-flyspell-mode: t
  remember-notes-mode: t
  delete-selection-mode: t
  windmove-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/mpn/.config/emacs/elpa/transient-20210525.1141/transient hides /usr/local/share/emacs/31.0.50/lisp/transient
~/.config/emacs/custom hides /usr/local/share/emacs/31.0.50/lisp/custom

Features:
(shadow emacsbug sort mail-extr 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 format-spec notmuch-wash diff-mode
track-changes coolj goto-addr icalendar notmuch-tag notmuch-lib
notmuch-compat pcase hl-line mm-view mml-smime smime gnutls dig
gnus-alias rot13 message sendmail yank-media puny dired dired-loaddefs
rfc822 mml mml-sec epa derived 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
cus-edit wid-edit dabbrev checkdoc lisp-mnt shortdoc crm avy misearch
multi-isearch cus-start cus-load pulse color pp cl-print help-fns
radix-tree time-date auto-package-update easy-mmode dash descr-text
server flyspell form-feed init sgml-mode facemenu dom
auto-dim-other-buffers face-remap autorevert filenotify comp comp-cstr
cl-extra help-mode warnings comp-run comp-common rx icomplete num3-mode
disp-table whitespace compile text-property-search comint ansi-osc
ansi-color ring ispell remember advice browse-kill-ring delsel ffap
thingatpt windmove diary-lib diary-loaddefs cal-menu calendar
cal-loaddefs auto-dim-other-buffers-autoloads avy-autoloads
browse-kill-ring-autoloads csv-mode-autoloads evil-autoloads
gnu-elpa-keyring-update-autoloads gnus-alias-autoloads finder-inf
markdown-mode-autoloads notmuch-autoloads protobuf-mode-autoloads
sed-mode-autoloads info vterm-autoloads package browse-url xdg 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 icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
early-init rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen 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 inotify dynamic-setting font-render-setting cairo gtk x-toolkit
xinput2 x multi-tty move-toolbar make-network-process native-compile
emacs)

Memory information:
((conses 16 257215 704427) (symbols 48 34587 67)
 (strings 32 82254 29315) (string-bytes 1 2545384) (vectors 16 34779)
 (vector-slots 8 825430 881688) (floats 8 257 4262)
 (intervals 56 3296 6731) (buffers 992 19))

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»