unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: 2QdxY4RzWzUUiLuE@potatochowder.com
To: Ken Goldman <kgoldman@us.ibm.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Refresh display after changing variable
Date: Tue, 3 Aug 2021 10:00:00 -0700	[thread overview]
Message-ID: <YQl2EDLvWhSmQ5cA@scrozzle> (raw)
In-Reply-To: <080b7d73-e4c8-eaf4-fc92-60f28bee288f@us.ibm.com>

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



  parent reply	other threads:[~2021-08-03 17:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 16:49 Refresh display after changing variable Ken Goldman
2021-08-02 17:03 ` Eli Zaretskii
2021-08-02 19:36   ` Ken Goldman
2021-08-02 19:40     ` Eli Zaretskii
2021-08-02 20:56       ` Michael Heerdegen
2021-08-02 21:26         ` 2QdxY4RzWzUUiLuE
2021-08-03 15:42           ` Ken Goldman
2021-08-03 15:52             ` Eli Zaretskii
2021-08-03 16:17               ` Ken Goldman
2021-08-03 17:00             ` 2QdxY4RzWzUUiLuE [this message]
2021-08-03 17:03               ` Eli Zaretskii
2021-08-04 20:17               ` Ken Goldman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YQl2EDLvWhSmQ5cA@scrozzle \
    --to=2qdxy4rzwzuuilue@potatochowder.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=kgoldman@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).