Commits

Anonymous committed 3ca050f

2001-12-26 Nix <nix@esperi.demon.co.uk>
Volker Franz <volker.franz@tuebingen.mpg.de>

* 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.

Comments (0)

Files changed (2)

+2001-12-26  Nix  <nix@esperi.demon.co.uk>
+            Volker Franz  <volker.franz@tuebingen.mpg.de>
+
+	* 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.
+
 2001-12-13  Steve Youngs  <youngs@xemacs.org>
 
 	* Makefile (REQUIRES): Add fsf-compat for info-look's require
   :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."
+  :type '(repeat (function :format "%v"))
+  :group 'uniquify)
+
 (defcustom uniquify-min-dir-content 0
   "*Minimum number of directory name components included in buffer name."
   :type 'integer
 		      (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
   (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