unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74876: 31.0.50; Force fringe refresh / force-window-update not affecting fringes
@ 2024-12-14 19:31 Michal Nazarewicz
  2024-12-14 20:28 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Nazarewicz @ 2024-12-14 19:31 UTC (permalink / raw)
  To: 74876

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»





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#74876: 31.0.50; Force fringe refresh / force-window-update not affecting fringes
  2024-12-14 19:31 bug#74876: 31.0.50; Force fringe refresh / force-window-update not affecting fringes Michal Nazarewicz
@ 2024-12-14 20:28 ` Eli Zaretskii
  2024-12-14 21:39   ` Michal Nazarewicz
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-12-14 20:28 UTC (permalink / raw)
  To: Michal Nazarewicz; +Cc: 74876

> From: Michal Nazarewicz <mina86@mina86.com>
> Date: Sat, 14 Dec 2024 20:31:00 +0100
> 
> 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.

Yes, because redrawing the fringes is expensive, especially in large
frames.  So I'm not surprised that you see what you see, since no one
expected the fringe face to be changed frequently during the session.

> 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.

Can you show a simple Lisp which could be used to investigate the
behavior and perhaps see how what you want could be enabled?  It is
not easy to do that by having the code of the whole package.
Presumably, what the package does to dynamically change the face of
the fringe can be done by a short Lisp function, which could then be
used from "emacs -Q" to see what prevents the fringe face from being
updated immediately.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#74876: 31.0.50; Force fringe refresh / force-window-update not affecting fringes
  2024-12-14 20:28 ` Eli Zaretskii
@ 2024-12-14 21:39   ` Michal Nazarewicz
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Nazarewicz @ 2024-12-14 21:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74876

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»





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-14 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-14 19:31 bug#74876: 31.0.50; Force fringe refresh / force-window-update not affecting fringes Michal Nazarewicz
2024-12-14 20:28 ` Eli Zaretskii
2024-12-14 21:39   ` Michal Nazarewicz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).