From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.devel Subject: problem with uniquify.el and kill-buffer-hook Date: 13 Dec 2002 11:10:15 +0900 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: Reply-To: Miles Bader NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1039745693 11847 80.91.224.249 (13 Dec 2002 02:14:53 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 13 Dec 2002 02:14:53 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18MfLn-00034m-00 for ; Fri, 13 Dec 2002 03:14:51 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18MfXb-0007d1-00 for ; Fri, 13 Dec 2002 03:27:03 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18MfLm-00065k-00 for emacs-devel@quimby.gnus.org; Thu, 12 Dec 2002 21:14:50 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18MfLP-00064V-00 for emacs-devel@gnu.org; Thu, 12 Dec 2002 21:14:27 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18MfLN-00062v-00 for emacs-devel@gnu.org; Thu, 12 Dec 2002 21:14:26 -0500 Original-Received: from tyo202.gate.nec.co.jp ([202.32.8.202]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18MfI6-0004lP-00; Thu, 12 Dec 2002 21:11:03 -0500 Original-Received: from mailgate4.nec.co.jp ([10.7.69.193])gBD2AuU00780; Fri, 13 Dec 2002 11:10:56 +0900 (JST) Original-Received: from mailsv4.nec.co.jp (mailgate51.nec.co.jp [10.7.69.190]) by mailgate4.nec.co.jp (8.11.6/3.7W-MAILGATE-NEC) with ESMTP id gBD2AGn19878; Fri, 13 Dec 2002 11:10:55 +0900 (JST) Original-Received: from mcsss2.ucom.lsi.nec.co.jp ([10.30.114.133]) by mailsv4.nec.co.jp (8.11.6/3.7W-MAILSV4-NEC) with ESMTP id gBD2AFq17563; Fri, 13 Dec 2002 11:10:15 +0900 (JST) Original-Received: from mcspd15.ucom.lsi.nec.co.jp (mcspd15 [10.30.114.174]) id gBD2AFB09942; Fri, 13 Dec 2002 11:10:15 +0900 (JST) Original-Received: by mcspd15.ucom.lsi.nec.co.jp (Postfix, from userid 31295) id 2D9023701; Fri, 13 Dec 2002 11:10:15 +0900 (JST) Original-To: emacs-devel@gnu.org System-Type: i686-pc-linux-gnu Blat: Foop Original-Lines: 54 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10104 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10104 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 themselves). 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! Thanks, -Miles -- Ich bin ein Virus. Mach' mit und kopiere mich in Deine .signature.