help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Refresh display after changing variable


From: Ken Goldman
Subject: Re: Refresh display after changing variable
Date: Wed, 4 Aug 2021 16:17:21 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0

On 8/3/2021 1:00 PM, 2QdxY4RzWzUUiLuE@potatochowder.com wrote:
On 2021-08-03 at 11:42:45 -0400,
Ken Goldman <kgoldman@us.ibm.com> wrote:

On 8/2/2021 5:26 PM, 2QdxY4RzWzUUiLuE@potatochowder.com wrote:
On 2021-08-02 at 22:56:41 +0200,
Michael Heerdegen <michael_heerdegen@web.de> wrote:

Eli Zaretskii <eliz@gnu.org> writes:

From: Ken Goldman <kgoldman@us.ibm.com>
Date: Mon, 2 Aug 2021 15:36:01 -0400

     (defun kg-toggle-whitespace-line-column ()
        "Toggle whitespace line column between 80 and 101"
        (interactive)
        (setq whitespace-line-column (if (= whitespace-line-column
80) 101 80))
        (whitespace-mode 1))

FWIW, I have the following snippet in a function I wrote to change
tab-width:

    (let ((w (get-buffer-window (current-buffer))))
      (set-window-start w (window-start w)))

and a note that I stole that snippet from scroll-bar-maybe-window-start
in scroll-bar.el.  That function doesn't exist anymore (in Emacs 27.2),
but scroll-bar-set-window-start in scroll-bar.el does end as follows:

      (set-window-start window (point))))))

That line, in the function, yields

kg-toggle-whitespace-line-column: Symbol’s value as variable is void: window

Yeah, sorry; window (the variable) is extracted near the beginning of
scroll-bar-set-window-start from one of a piece of the scroll bar event
that triggered the function call.

My point was that current Emacs code uses set-window-start to force a
redraw.  Try something like this:

     (set-window-start (get-buffer-window) (point))

(There might be simpler ways to get the current window, and I'm sure
someone will point them out to me, but that should work as a replacement
for your (whitespace-mode 1)).

That scrolls the buffer so that the cursor is at the top of the window.
However, it does not redo the colors.  So far, revert-buffer is
the only function that works.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]