all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to update modelines of all displayed buffers
@ 2010-04-15 19:21 Cecil Westerhof
  2010-04-16  2:17 ` Barry Margolin
  2010-04-16 22:49 ` Andreas Politz
  0 siblings, 2 replies; 5+ messages in thread
From: Cecil Westerhof @ 2010-04-15 19:21 UTC (permalink / raw)
  To: help-gnu-emacs

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.

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?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


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

* Re: How to update modelines of all displayed buffers
  2010-04-15 19:21 How to update modelines of all displayed buffers Cecil Westerhof
@ 2010-04-16  2:17 ` Barry Margolin
  2010-04-16  7:19   ` Cecil Westerhof
  2010-04-16 22:49 ` Andreas Politz
  1 sibling, 1 reply; 5+ messages in thread
From: Barry Margolin @ 2010-04-16  2:17 UTC (permalink / raw)
  To: help-gnu-emacs

In article <87y6gor07c.fsf@linux-lqcw.site>,
 Cecil Westerhof <Cecil@decebal.nl> wrote:

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

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

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


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

* Re: How to update modelines of all displayed buffers
  2010-04-16  2:17 ` Barry Margolin
@ 2010-04-16  7:19   ` Cecil Westerhof
  2010-04-16 21:58     ` José A. Romero L.
  0 siblings, 1 reply; 5+ messages in thread
From: Cecil Westerhof @ 2010-04-16  7:19 UTC (permalink / raw)
  To: help-gnu-emacs

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


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

* Re: How to update modelines of all displayed buffers
  2010-04-16  7:19   ` Cecil Westerhof
@ 2010-04-16 21:58     ` José A. Romero L.
  0 siblings, 0 replies; 5+ messages in thread
From: José A. Romero L. @ 2010-04-16 21:58 UTC (permalink / raw)
  To: help-gnu-emacs

On 16 Kwi, 09:19, Cecil Westerhof <Ce...@decebal.nl> wrote:
(...)
> > (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?
(...)

You could try something like this:

(mapc
 (lambda (b) (set-buffer b) (buffer-update-mode-line))
 (delete-dups
  (mapcar 'window-buffer
          (apply 'append
                 (mapcar 'window-list (frame-list))))))

though if you refactored your buffer-update-mode-line to accept the
buffer as parameter you could write this a bit more elegantly:

(mapc 'buffer-update-mode-line
      (delete-dups
       (mapcar 'window-buffer
               (apply 'append
                      (mapcar 'window-list (frame-list))))))

Cheers,
--
José A. Romero L.
escherdragon at gmail
"We who cut mere stones must always be envisioning cathedrals."
(Quarry worker's creed)


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

* Re: How to update modelines of all displayed buffers
  2010-04-15 19:21 How to update modelines of all displayed buffers Cecil Westerhof
  2010-04-16  2:17 ` Barry Margolin
@ 2010-04-16 22:49 ` Andreas Politz
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Politz @ 2010-04-16 22:49 UTC (permalink / raw)
  To: help-gnu-emacs

Cecil Westerhof <Cecil@decebal.nl> 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.
>
> 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?

(defun displayed-buffer-list (&optional all-frames)
  (flet ((fn (buf) (get-buffer-window buf all-frames)))
    (remove-if-not #'fn (buffer-list))))

ap


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

end of thread, other threads:[~2010-04-16 22:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-15 19:21 How to update modelines of all displayed buffers Cecil Westerhof
2010-04-16  2:17 ` Barry Margolin
2010-04-16  7:19   ` Cecil Westerhof
2010-04-16 21:58     ` José A. Romero L.
2010-04-16 22:49 ` Andreas Politz

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.