Subject: Re: bug#74876: 31.0.50; Force fringe refresh / force-window-update not affecting fringes

From: Michal Nazarewicz <[email-masked]>
Date: Sat, 14 Dec 2024 22:39:19 +0100

On Sat, Dec 14 2024, Eli Zaretskii wrote:
> Can you show a simple Lisp which could be used to investigate the
> behavior and perhaps see how what you want could be enabled?

---- >% ----------------------------------------------------------------

(defvar-local adob-remapping nil)
(put 'adob-remapping 'permanent-local nil)

(defface adob-test '((t :background "red")) "Test")

(defun adob-test-for-each-window (func)
  (save-current-buffer
    (dolist (frame (frame-list))
      (dolist (wnd (window-list frame))
        (set-buffer (window-buffer wnd))
        (when (funcall func wnd)
          (force-window-update wnd))))))

(defun adob-test-update ()
  (let ((face '(:filtered (:window adob-test t) adob-test))
        (selected-window (selected-window)))
    (adob-test-for-each-window
     (lambda (wnd)
       (let ((val (eq wnd selected-window)) update)
         (unless adob-remapping
           (setq adob-remapping (face-remap-add-relative 'fringe face)
                 update t))
         (unless (eq val (window-parameter wnd 'adob-test))
           (set-window-parameter wnd 'adob-test val)
           (setq update t))
         update)))))

(defun adob-test-on ()
  (interactive)
  (adob-test-update)
  (add-hook 'post-command-hook #'adob-test-update))

(defun adob-test-off ()
  (interactive)
  (remove-hook 'post-command-hook #'adob-test-update)
  (adob-test-for-each-window
   (lambda (wnd)
     (when adob-remapping
       (face-remap-remove-relative adob-remapping)
       (setq adob-remapping nil)
       t))))

; (adob-test-on) to enable
; (adob-test-off) to disable

---- %< ----------------------------------------------------------------

1. Open two windows with two long buffers.
2. M-x adob-test-on RET
3. Scroll current window with M-v.
4. Switch to the other window with C-x o.
4. Scroll other window with C-M-v.

Expected: at all times, the fringes of the selected window are red while
fringes of the other window are grey.

Observed: Fringes are updated only when window is scrolled and new lines
are shown.

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