help-gnu-emacs
[Top][All Lists]
Advanced

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

Hooks for new buffers?


From: Steven Degutis
Subject: Hooks for new buffers?
Date: Thu, 4 Apr 2013 15:12:25 -0500

I wrote auto-dim-other-buffers.el (https://github.com/sdegutis/auto-dim-other-buffers.el) a few days ago, which applies a "dimmed" face to non-current buffers.

It adds to post-command-hook and after-change-major-mode-hook, the first as a catch-all "something changed" and the second as a hacky way of saying "a new buffer just got created".

This mostly works. But sometimes new buffers are created that don't change major modes. For example, *magit-process* gets created at some point, and when I show it via $ inside magit-status, it's not dimmed. So it's not changing major modes.

When I show the buffer via $, it probably triggers the post-command-hook, but my hook tries to be efficient, by only looking at the previous current-buffer and the new current-buffer. And this isn't either of those, since it just shows up in a new window but isn't given focus. I'm sure there are other situations like this.

The easiest way to solve this is to find a hook that's called when new buffers are created, even if that's not its official purpose. Apparently after-change-major-mode-hook isn't enough, presumably because these never changed major modes. So is there such a hook?

And if not, is there at least some hook that happens whenever new windows are opened?

-Steven

reply via email to

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