New file.
[bpt/emacs.git] / lisp / iswitchb.el
index d705faf..2339972 100644 (file)
@@ -1,18 +1,17 @@
 ;;; iswitchb.el --- switch between buffers using substrings
 
-;; Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-;;           Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Stephen Eglen <stephen@gnu.org>
 ;; Maintainer: Stephen Eglen <stephen@gnu.org>
 ;; Keywords: completion convenience
-;; location: http://www.anc.ed.ac.uk/~stephen/emacs/
 
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -22,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -293,6 +292,7 @@ with a space, for which the regexp is `^ '.  See the source file for
 example functions that filter buffernames."
   :type '(repeat (choice regexp function))
   :group 'iswitchb)
+(put 'iswitchb-buffer-ignore 'risky-local-variable t)
 
 (defcustom iswitchb-max-to-show nil
   "*If non-nil, limit the number of names shown in the minibuffer.
@@ -396,7 +396,7 @@ See documentation of `walk-windows' for useful values.")
 (defcustom iswitchb-minibuffer-setup-hook nil
   "Iswitchb-specific customization of minibuffer setup.
 
-This hook is run during minibuffer setup iff `iswitchb' will be active.
+This hook is run during minibuffer setup if `iswitchb' is active.
 For instance:
 \(add-hook 'iswitchb-minibuffer-setup-hook
          '\(lambda () (set (make-local-variable 'max-mini-window-height) 3)))
@@ -495,14 +495,13 @@ interfere with other minibuffer usage.")
 
 (defvar iswitchb-global-map
   (let ((map (make-sparse-keymap)))
-    (substitute-key-definition 'switch-to-buffer ; normally C-x b
-                              'iswitchb-buffer map global-map)
-    (substitute-key-definition 'switch-to-buffer-other-window ; C-x 4 b
-                              'iswitchb-buffer-other-window map global-map)
-    (substitute-key-definition 'switch-to-buffer-other-frame ; C-x 5 b
-                              'iswitchb-buffer-other-frame map global-map)
-    (substitute-key-definition 'display-buffer ; C-x 4 C-o
-                              'iswitchb-display-buffer map global-map)
+    (dolist (b '((switch-to-buffer . iswitchb-buffer)
+                 (switch-to-buffer-other-window . iswitchb-buffer-other-window)
+                 (switch-to-buffer-other-frame . iswitchb-buffer-other-frame)
+                 (display-buffer . iswitchb-display-buffer)))
+      (if (fboundp 'command-remapping)
+          (define-key map (vector 'remap (car b)) (cdr b))
+        (substitute-key-definition (car b) (cdr b) map global-map)))
     map)
   "Global keymap for `iswitchb-mode'.")
 
@@ -558,7 +557,7 @@ variable `iswitchb-mode'."
     (define-key map "\C-j" 'iswitchb-select-buffer-text)
     (define-key map "\C-t" 'iswitchb-toggle-regexp)
     (define-key map "\C-x\C-f" 'iswitchb-find-file)
-    ;;(define-key map "\C-a" 'iswitchb-toggle-ignore)
+    (define-key map "\C-n" 'iswitchb-toggle-ignore)
     (define-key map "\C-c" 'iswitchb-toggle-case)
     (define-key map "\C-k" 'iswitchb-kill-buffer)
     (define-key map "\C-m" 'iswitchb-exit-minibuffer)
@@ -942,7 +941,7 @@ BUFFER-LIST can be list of buffers or list of strings."
             (progn
               (setq ignorep t)
               (setq re-list nil))))
-       ((fboundp nextstr)
+       ((functionp nextstr)
         (if (funcall nextstr bufname)
             (progn
               (setq ignorep t)
@@ -1122,7 +1121,7 @@ Return the modified list with the last element prepended to it."
              (set-buffer-major-mode newbufcreated))
          (iswitchb-visit-buffer newbufcreated))
       ;; else wont create new buffer
-      (message (format "no buffer matching `%s'" buf)))))
+      (message "no buffer matching `%s'" buf))))
 
 (defun iswitchb-window-buffer-p  (buffer)
   "Return window pointer if BUFFER is visible in another frame.
@@ -1441,7 +1440,7 @@ This is an example function which can be hooked on to
     (iswitchb-to-end summaries)))
 
 (defun iswitchb-case ()
-  "Return non-nil iff we should ignore case when matching.
+  "Return non-nil if we should ignore case when matching.
 See the variable `iswitchb-case' for details."
   (if iswitchb-case
       (if (featurep 'xemacs)
@@ -1451,7 +1450,7 @@ See the variable `iswitchb-case' for details."
 ;;;###autoload
 (define-minor-mode iswitchb-mode
   "Toggle Iswitchb global minor mode.
-With arg, turn Iswitchb mode on if and only iff ARG is positive.
+With arg, turn Iswitchb mode on if ARG is positive, otherwise turn it off.
 This mode enables switching between buffers using substrings.  See
 `iswitchb' for details."
   nil nil iswitchb-global-map :global t :group 'iswitchb