[Top][All Lists]

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

problem with uniquify.el and kill-buffer-hook

From: Miles Bader
Subject: problem with uniquify.el and kill-buffer-hook
Date: 13 Dec 2002 11:10:15 +0900

Recently I've noticed that the `uniquify' package has stopped working
correctly, in particular, the feature controlled by the
`uniquify-after-kill-buffer-p' variable doesn't work; here's the doc:

   uniquify-after-kill-buffer-p's value is t

   If non-nil, rerationalize buffer names after a buffer has been killed.
   This can be dangerous if Emacs Lisp code is keeping track of buffers
   by their names (rather than keeping pointers to the buffers

I looked at the code a bit, and I think I found the problem:

This feature works by adding an appropriate local hook to
`kill-buffer-hook' in all the affected buffers.

However, this is done _before_ the buffer's mode is set (in the new
buffer that caused uniqify to be triggered); since most mode functions
call `kill-all-local-variables', this trashes the `kill-buffer-hook'.

I've found that I can fix the problem by doing:

  (put 'kill-buffer-hook 'permanent-local t)

But doing this by default may cause problems for other code (e.g., if a
particular mode adds a `kill-buffer-hook', you probably want that hook
to be deleted if the mode changes).

Since `kill-all-local-variables' first calls `change-major-mode-hook' I
guess another solution would be to make uniquify add some hair to
`change-major-mode-hook' that tries to preserve its entry in
`kill-buffer-hook' across the kill-all-local-variables', but I'm not
sure how this can be done without another hook that runs _after_
kill-all-local-variables has done its job.

Does anyone have any ideas for a solution?  The real problem here seems
to be that kill-buffer-hook can contain both mode-specific and
non-mode-specific entries; I'm not sure if any modes actually use
kill-buffer-hook though...

Also, any ideas why this just stopped working recently?  I didn't see
any _obvious_ things in the ChangeLogs, but maybe I just missed it.

Another thing (whew!), is that uniquify.el uses `defadvice' (on
`rename-buffer', and `create-file-buffer') and I wonder if it should be
changed to just have those functions invoke it directly.

Anyway sorry for the long rambling message!


Ich bin ein Virus. Mach' mit und kopiere mich in Deine .signature.

reply via email to

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