This is pretty simple, I'm trying to find (or build) a hook that fires when files are visited and selected (i.e. immediately displayed).
Background
I'm writing a UI centric entry for find-file-hook
, but it turns out that find-file-hook
is fired for all sorts of things that I don't need:
- Semantic assets which are loaded when semantic starts
- Files opened in the background for my on-the-fly diffing program
- Probably other stuff, that's all I could think of off the top of my head
Most of this is done by way of find-file-noselect
, which associates a buffer with a file, but does not switch-to-buffer
on the newly created buffer like find-file
does.
I would like my hook to execute only when the current buffer changes.
find-file-noselect
")? Do you mean displayed?find-file-noselect
finds the file but does not display it (the documentation calls it "selecting" a file?)files.el
or inwindow.el
, or something else? Consider adding a specific example so that forum participants have a better idea of what you are seeking.find-file-noselect
ensures that a buffer has the contents of a file. Buffers are visited, not files. If a buffer already has the file contents in it then that buffer is returned (the buffer contents are also checked wrt the file on disk, and you are alerted if they are out of sync). So a file being "visited and selected" doesn't mean much (to me anyway). Whenfind-file-noselect
returns a buffer that is visiting the file, I guess that is what you mean by "visited and selected", but then you add "(i.e., not byfind-file-noselect
)". So it's unclear to me what you mean.