unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* blinking the modeline
@ 2003-04-23 14:07 Rob Meyer
  2003-04-23 16:42 ` Kai Großjohann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rob Meyer @ 2003-04-23 14:07 UTC (permalink / raw)


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!

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

end of thread, other threads:[~2003-04-23 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-23 14:07 blinking the modeline Rob Meyer
2003-04-23 16:42 ` Kai Großjohann
2003-04-23 17:18 ` Barry Margolin
2003-04-23 17:19 ` Piet van Oostrum

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