On Mon, 1 Oct 2001, Volker Franz uttered the following:
this might be a small and simple problem --- but (to be honest) it
took me almost a year to figure it out:
Well done; I haven't managed to figure it out at all.
If you use uniquify, you can allow it to rename the buffer names
after
a buffer has been killed:
(setq uniquify-after-kill-buffer-p t)
For example, if you had the buffers: <foo|bar1> and <foo|bar2>, and
now you killed <foo|bar2>, uniquify will automatically rename
<foo|bar1> to <foo>.
However, if you do this, info will be broken. This is because AFTER A
WHILE the *info* buffer is renamed to the name of the currently
visited info-file. A new call of F1-i then messes up everything, the
history is broken, links are broken, etc.
The problem is that uniquify renames ALL buffers after any buffer has
been killed, including the *info* buffer (it usually renames it to the
name of the info file).
Good god, is *that* it? No wonder I never managed to debug it :(
The solution
------------
... is simple. One can exclude the info buffer from being renamed by
setting:
(setq uniquify-ignore-buffers-re "^\\*info\\*$")
I found this problem hard to track because it shows up only after a
Likewise. I'm amazed you managed it, actually.
while (when I killed some buffer) --- I always suspected my info-dir
settings to be somehow erroneous. Therefore, I would like to suggest
to make this setting the default for uniquify-ignore-buffers-re
(instead of nil):
======================================================================
--- uniquify.orig Mon Oct 1 22:51:41 2001
+++ uniquify.el Mon Oct 1 22:52:16 2001
@@ -127,7 +127,7 @@
:type 'boolean
:group 'uniquify)
-(defcustom uniquify-ignore-buffers-re nil
+(defcustom uniquify-ignore-buffers-re "^\\*info\\*$"
"*Regular expression matching buffer names that should not be uniquified.
For instance, set this to \"^draft-[0-9]+$\" to avoid having uniquify rename
draft buffers even if `uniquify-after-kill-buffer-p' is non-nil and the
======================================================================
This is still not ideal, because the real criterion is `bucffers whose
mode is Info-mode'; this will still break people who rename their Info
buffers themselves.
In the interests of insane generality, and to make it easier to add new
exclusion classes to uniquify, might I suggest something like the
following (disclaimer: not heavily tested but it seems to stop the
problem here)...
(btw, is there a better customization type for hooks than `lisp'? I
tried to write one and gave up, but then I'm a customize newbie.)
2001-10-05 Nix <nix(a)esperi.demon.co.uk>
* uniquify.el (uniquify-ignore-buffers-query-functions): New hook,
called to determine buffers not to uniquify.
(uniquify-rationalize-file-buffer-names): Use it...
(uniquify-ignore-buffers-re): ... reimplement in terms of it.
New function.
(uniquify-ignore-buffers-mode-re): New variable and function.
--- edit-utils/uniquify.el~ Fri Oct 5 21:00:42 2001
+++ edit-utils/uniquify.el Fri Oct 5 22:10:06 2001
@@ -130,6 +130,20 @@
:type '(choice (const :tag "Uniquify all buffers" nil) regexp)
:group 'uniquify)
+(defcustom uniquify-ignore-buffers-mode-re "^Info-mode$"
+ "*Regexp matching names of major modes of buffers that should not be uniquified.
+For instance, set this to \"^\\\\(Info\\\\)\\\\|\\\\(message\\\\)-mode$\" to
avoid
+having uniquify rename Info and mail message buffers."
+ :type '(choice (const :tag "Uniquify all buffers" nil) regexp)
+ :group 'uniquify)
+
+(defcustom uniquify-ignore-buffers-query-functions '(uniquify-ignore-buffers-re
+ uniquify-ignore-buffers-mode-re)
+ "*Functions to call to determine if a buffer name should not be uniquified.
+The functions are called with one argument, the buffer. If any function returns
+t, the buffer name is not uniquified."
+ :group 'uniquify)
+
(defcustom uniquify-min-dir-content 0
"*Minimum number of directory name components included in buffer name."
:type 'integer
@@ -202,10 +216,9 @@
(uniquify-buffer-file-name buffer)))
(rawname (and bfn (uniquify-file-name-nondirectory bfn)))
(deserving (and rawname
- (not (and uniquify-ignore-buffers-re
- (string-match
- uniquify-ignore-buffers-re
- (buffer-name buffer))))
+ (not (run-hook-with-args-until-success
+ 'uniquify-ignore-buffers-query-functions
+ buffer))
(or (not newbuffile)
(equal rawname
(uniquify-file-name-nondirectory
@@ -440,6 +453,24 @@
(remove-hook 'post-command-hook
'delayed-uniquify-rationalize-file-buffer-names))
+(defun uniquify-ignore-buffers-re (buffer)
+ "Returns t if the BUFFER's name matches `uniquify-ignore-buffers-re'.
+Meant to be called from the `uniquify-ignore-buffers-query-functions'."
+ (and uniquify-ignore-buffers-re
+ (string-match
+ uniquify-ignore-buffers-re
+ (buffer-name buffer))))
+
+(defun uniquify-ignore-buffers-mode-re (buffer)
+ "Returns t if the BUFFER's major mode matches
`uniquify-ignore-buffers-mode-re'.
+Meant to be called from the `uniquify-ignore-buffers-query-functions'."
+ (and uniquify-ignore-buffers-mode-re
+ (string-match
+ uniquify-ignore-buffers-mode-re
+ (symbol-name (with-current-buffer buffer
+ major-mode)))))
+
+
(add-hook 'kill-buffer-hook 'delay-uniquify-rationalize-file-buffer-names)
;;; uniquify.el ends here
--
`Upsetting this BOFH was a BAD MOVE.' --- Chris Newport