all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

* Re: blinking the modeline
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Kai Großjohann @ 2003-04-23 16:42 UTC (permalink / raw)


roblist@bigdis.com (Rob Meyer) writes:

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

How about M-x display-time RET?  That updates the display every
minute, and gives you useful information, to boot!
-- 
file-error; Data: (Opening input file no such file or directory ~/.signature)

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

* Re: blinking the modeline
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Barry Margolin @ 2003-04-23 17:18 UTC (permalink / raw)


In article <c6d3cf9e.0304230607.25d0fa7d@posting.google.com>,
Rob Meyer <roblist@bigdis.com> wrote:
>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....

Why don't you just turn on the time display on the mode line, with
(display-time)?  It will update every minute.

-- 
Barry Margolin, barry.margolin@level3.com
Genuity Managed Services, a Level(3) Company, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

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

* Re: blinking the modeline
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Piet van Oostrum @ 2003-04-23 17:19 UTC (permalink / raw)


>>>>> roblist@bigdis.com (Rob Meyer) (RM) wrote:

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

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

Use sit-for rather than sleep-for (sleep-for doesn't redisplay). You could
also display-time which updates the time in the modeline every minute.
However, when there is a lot of crap in the modeline the time will be
pushed out of it. 
-- 
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum@hccnet.nl

^ 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.