Subject: bug#57813: Icon images are non-functional

From: Juri Linkov <[email-masked]>
Date: Sun, 18 Sep 2022 21:46:07 +0300

>> Here is a preliminary patch, but using buffer-local left-margin-width
>> exhibits strange behavior: margins don't always appear immediately
>> after switching the buffer.
>
> Margins are specific to a window, not to a buffer.  See the
> description of set-window-margins in the ELisp manual, and the
> accompanying description of set-window-buffer there.

 -- Function: set-window-buffer window buffer-or-name &optional
          keep-margins
     ...
     By default, this function resets WINDOW’s position, display
     margins, fringe widths, and scroll bar settings, based on the local
     variables in the specified buffer.  However, if the optional
     argument KEEP-MARGINS is non-‘nil’, it leaves WINDOW’s display
     margins, fringes and scroll bar settings alone.

KEEP-MARGINS is nil by default, so buffer-local 'left-margin-width'
should work as described:

 -- Variable: left-margin-width
     This variable specifies the width of the left margin, in character
     cell (a.k.a. “column”) units.  It is buffer-local in all buffers.
     A value of ‘nil’ means no left marginal area.

And indeed, 'left-margin-width' works fine.  The only problem is
with 'C-h n' that doesn't show margins immediately, only after
switching to another buffer and back.  Then afterwards buffer-local
margins are kept in etc/NEWS as well.  It can be fixed by:

diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el
index 88e8948060..9b99740290 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -80,6 +80,7 @@ emacs-news--mode-common
               outline-minor-mode-cycle t
               outline-minor-mode-highlight 'append)
   (outline-minor-mode)
+  (set-window-buffer nil (current-buffer))
   (emacs-etc--hide-local-variables))