[Top][All Lists]

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

RE: automatic dired update

From: Drew Adams
Subject: RE: automatic dired update
Date: Sun, 4 Jan 2009 17:56:33 -0800

> Does anyone know how to make dired auto-refresh?
> For example, i have a dired buffer of dir xyz buried somewhere.
> Then, i renamed some files in OS's Desktop.
> Then, when i switch to dir xyz in emacs, i wish to see the updated
> list without me having to type g to refresh.
> originally i thought just some hook... something like
> (add-hook 'dired-load-hook 'revert-buffer)
> but when actually trying to do it, apparently not that simple.
> I thought it must be some function or variable that tells me when
> buffer display is switched or updated... can't locate it.

Good question. To use a hook to call `dired-revert', you need to find a hook
that represents the "change" in interaction state that you make when you
"switch" to the dired buffer. I'm not sure what hook that might be.

Seems like you want something that kicks in whenever a particular window gets
the focus, but I don't know of such a hook. `window-configuratino-change-hook'
is probably not what you want, but maybe take a look.

I think `change-major-mode-hook' won't do it, because that's only when the
current buffer's mode changes.

You could use a timer or, say, `display-time-hook' to do it periodically, but
that's a sledge hammer.

`first-change-hook' would presumably kick in for any change you made in Dired -
you might look at that.

`menu-bar-update-hook' kicks in whenever the menu-bar is updated - which is
quite often - another sledge hammer.

If you always switch buffers/windows with the mouse, maybe
`mouse-leave-buffer-hook' would help.

You could perhaps advise the commands you typically use to switch to the Dired
buffer/window (`switch-to-buffer' or whatever), so they check for `dired-mode'
and DTRT, but again, that's a bit of a sledge hammer.

I'm probably not thinking clearly right now, but I don't see anything obvious as
an elegant solution; sorry. But it's a good question. Maybe someone else has a
good answer.

reply via email to

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