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

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

blinking the modeline


From: Rob Meyer
Subject: blinking the modeline
Date: 23 Apr 2003 07:07:08 -0700

Hi, I'm pretty much a newbie to Emacs and Emacs lisp. I've been
working on the first function that I really need, and was hoping
someone out there could give me some advice. I've been working through
the intro guide and the reference guide, but can't really find what
I'm looking for there (yet at least).

What I'm trying to do is flash the mode line every 180 seconds or so
while Emacs is idle. The firewalls at work close the tcp conduit if
there is no activity for some ridiculously low timeout (5 minutes or
so). I could of course suspend Emacs and do my usual trick, "iostat
180", but I'd rather do it in emacs. I've figured out that
run-with-idle-timer won't really do what I want since it will only run
once and I'll have to figure out something more complex there. I
thought that would be the hard party, but....

So flashing the mode-line with mode-line-inverse-video seemed like the
path of least resistance. However, I don't seem to be able to "flash"
it. It will invert, but then not invert back within the same function.
Example:

This function works okay and inverts the mode-line:

(defun ml-test ()
  "return the value of inverse-mode-line"
  (interactive)
  (message "1: %s" mode-line-inverse-video)
  (setq mode-line-inverse-video (not mode-line-inverse-video))
  (sleep-for 1)
  (message "2: %s" mode-line-inverse-video)
)

And the messages are what I would expect: (t, then nil). If I run it
again (running with M-x ml-test), it inverts back (and prints nil,
then t). So far so good. However, this function:

(defun blink-mode-line ()
  "Blink the left character of the mode line"
  (interactive)
  (message "1: %s" mode-line-inverse-video)
  (sleep-for 1)
  (setq mode-line-inverse-video (not mode-line-inverse-video))
  (message "2: %s" mode-line-inverse-video)
  (force-mode-line-update)
  (sleep-for 1)
  (setq mode-line-inverse-video (not mode-line-inverse-video))
  (message "3: %s" mode-line-inverse-video)
)

Does nothing but print the messages, which strangely enough are as I
would expect (t, nil, then t). But no mode-line change at all. If I
comment out the
second setq, then it does change the mode-line once, leaving it the
opposite of it's original state after running. But nothing I do seems
to be able to convince Emacs to flash the mode-line.

I don't have to flash it; I could just turn on/off a "-" at the
begnning or something by messing with the format, but I thought this
would be easier, and now I'm just trying to figure out why it's not
working...a pride thing. :-) Is the change maybe getting optimized
away? That's the only real thing I can think of; or some
misunderstanding on my part of how to set variables within a
function....

Thanks for any suggestions you can give!


reply via email to

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