[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to update modelines of all displayed buffers
From: |
Cecil Westerhof |
Subject: |
Re: How to update modelines of all displayed buffers |
Date: |
Tue, 04 May 2010 15:44:43 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Barry Margolin <barmar@alum.mit.edu> writes:
>> I have defined the following function:
>> (defun buffer-update-mode-line ()
>> (setq buffer-mode-line (buffer-mode-line-extra))
>> (force-mode-line-update t))
>>
>> The function buffer-mode-line-extra gives the extra data I want to
>> display in the modeline.
>
> What's the variable buffer-mode-line? I can't find it in the Emacs Lisp
> documentation, is it something you added?
Yes, my bad:
(unless (memq 'buffer-mode-line global-mode-string)
(setq global-mode-string
(append global-mode-string
'("" buffer-mode-line))))
>> It is called every minute with:
>> (run-with-timer 60 60 'buffer-update-mode-line)
>>
>> With this only the modeline of the current buffer is updated. In
>> principal (force-mode-line-update t) makes all modelines updated, but
>> that will only work if for every (visible) buffer buffer-mode-line is
>> updated with the function buffer-mode-line-extra. Is there a way to get
>> this done?
>
> If buffer-mode-line is a buffer-local variable, you need to loop through
> all buffers, changing to each one and running your function.
>
> (defun update-mode-line-all-buffers ()
> (save-current-buffer
> (dolist (b (buffer-list))
> (set-buffer b)
> (buffer-update-mode-line))))
This does all buffers. Is it possible to do it only for displayed
buffers?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof