]> code.delx.au - gnu-emacs/blobdiff - lisp/iswitchb.el
(cvs-fileinfo-from-entries): Deal with Solaris'
[gnu-emacs] / lisp / iswitchb.el
index e3bb8ad76b370dcac98eff714f9e7f037b4c4ec2..d24f737851b02750c0497b07e5ffcc854ce38c60 100644 (file)
@@ -49,9 +49,9 @@
 
 ;;; Example
 
-;;If I have two buffers called "123456" and "123", with "123456" the
-;;most recent, when I use iswitchb, I first of all get presented with
-;;the list of all the buffers
+;; If I have two buffers called "123456" and "123", with "123456" the
+;; most recent, when I use iswitchb, I first of all get presented with
+;; the list of all the buffers
 ;;
 ;;       iswitch  {123456,123}
 ;;
 ;; wanted the second in the list, I could press C-s to move it to the
 ;; top of the list and then RET to select it.
 ;;
-;;However, If I type 4, I only have one match left:
+;; However, if I type 4, I only have one match left:
 ;;       iswitch 234[123456] [Matched]
 ;;
-;;Since there is only one matching buffer left, it is given in [] and we
-;;see the text [Matched] afterwards.  I can now press TAB or RET to go
-;;to that buffer.
+;; Since there is only one matching buffer left, it is given in [] and we
+;; see the text [Matched] afterwards.  I can now press TAB or RET to go
+;; to that buffer.
 ;;
 ;; If however, I now type "a":
 ;;       iswitch 234a [No match]
 ;; If you find that the file you are after is not in a buffer, you can
 ;; press C-x C-f to immediately drop into find-file.
 
-;;
-;;  See the doc string of iswitchb for full keybindings and features.
-;;  (describe-function 'iswitchb)
+;; See the doc string of iswitchb for full keybindings and features.
+;; (describe-function 'iswitchb)
 
 ;; Case matching: The case of strings when matching can be ignored or
 ;; used depending on the value of iswitchb-case (default is the same
 ;; for the normal buffer selection routine `read-buffer'.  To use
 ;; iswitch for all buffer selections in Emacs, add:
 ;; (setq read-buffer-function 'iswitchb-read-buffer)
-;; (This variable should be present in Emacs 20.3+)
+;; (This variable was introduced in Emacs 20.3.)
 ;; XEmacs users can get the same behaviour by doing:
 ;; (defalias 'read-buffer 'iswitchb-read-buffer)
 ;; since `read-buffer' is defined in lisp.
 
+;; Using iswitchb for other completion tasks.
+
+;; Kin Cho (kin@neoscale.com) sent the following suggestion to use
+;; iswitchb for other completion tasks.  
+;;
+;; (defun my-icompleting-read (prompt choices)
+;;   "Use iswitch as a completing-read replacement to choose from
+;; choices.  PROMPT is a string to prompt with.  CHOICES is a list of
+;; strings to choose from."
+;;   (let ((iswitchb-make-buflist-hook
+;;          (lambda ()
+;;            (setq iswitchb-temp-buflist choices))))
+;;     (iswitchb-read-buffer prompt)))
+;;
+;; example:
+;; (my-icompleting-read "Which fruit? " '
+;;                  ("apple" "pineapple" "pear" "bananas" "oranges") )
+
+;; Kin Cho also suggested the following defun.  Once you have a subset of
+;; matching buffers matching your current prompt, you can then press
+;; e.g. C-o to restrict matching to those buffers and clearing the prompt:
+;; (defun iswitchb-exclude-nonmatching()
+;;    "Make iswitchb work on only the currently matching names."
+;;    (interactive)
+;;    (setq iswitchb-buflist iswitchb-matches)
+;;    (setq iswitchb-rescan t)
+;;    (delete-minibuffer-contents))
+;;
+;; (add-hook 'iswitchb-define-mode-map-hook
+;;       '(lambda () (define-key 
+;;                     iswitchb-mode-map "\C-o" 
+;;                     'iswitchb-exclude-nonmatching)))
+
+;; Other lisp packages extend iswitchb behaviour to other tasks.  See
+;; ido.el (by Kim Storm) and mcomplete.el (Yuji Minejima).
+
+;; Window managers: Switching frames/focus follows mouse; Sawfish.
+
+;; If you switch to a buffer that is visible in another frame,
+;; iswitchb can switch focus to that frame.  If your window manager
+;; uses "click to focus" policy for window selection, you should also
+;; set focus-follows-mouse to nil.
+
+;; iswitch functionality has also been implemented for switching
+;; between windows in the Sawfish window manager.
+
 ;; Regexp matching
 
 ;; There is limited provision for regexp matching within iswitchb,
@@ -967,13 +1012,12 @@ Return the modified list with the last element prepended to it."
             (or (eq iswitchb-method 'always-frame)
                 (y-or-n-p "Jump to frame? ")))
        (setq newframe (window-frame win))
-       (raise-frame newframe)
-       (select-frame newframe)
-       (select-window win)
-       (if (not iswitchb-xemacs)
-           ;; reposition mouse to make frame active.  not needed in XEmacs
-           ;; This line came from the other-frame defun in Emacs.
-           (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
+        (if (not iswitchb-xemacs)
+            (select-frame-set-input-focus newframe)
+          (raise-frame newframe)
+          (select-frame newframe)
+          )
+       (select-window win))
        (t
        ;;  No buffer in other frames...
        (switch-to-buffer buffer)
@@ -989,7 +1033,7 @@ Return the modified list with the last element prepended to it."
       (progn
        (switch-to-buffer-other-frame buffer)
        (if (not iswitchb-xemacs)
-           (set-mouse-position (selected-frame) (1- (frame-width)) 0))
+            (select-frame-set-input-focus (selected-frame)))
        )))))
 
 (defun iswitchb-possible-new-buffer (buf)
@@ -1143,11 +1187,11 @@ Copied from `icomplete-exhibit' with two changes:
          (iswitchb-set-common-completion)
 
          ;; Insert the match-status information:
-         (insert-string (iswitchb-completions 
-                         contents
-                         minibuffer-completion-table
-                         minibuffer-completion-predicate
-                         (not minibuffer-completion-confirm)))))))
+         (insert (iswitchb-completions 
+                  contents
+                  minibuffer-completion-table
+                  minibuffer-completion-predicate
+                  (not minibuffer-completion-confirm)))))))
 
 (defun iswitchb-completions (name candidates predicate require-match)
   "Return the string that is displayed after the user's text.
@@ -1216,7 +1260,8 @@ Modified from `icomplete-completions'."
 
              ;; put in common completion item -- what you get by
              ;; pressing tab
-             (if (> (length iswitchb-common-match-string) (length name))
+             (if (and (stringp iswitchb-common-match-string)
+                      (> (length iswitchb-common-match-string) (length name)))
                  (concat open-bracket-determined
                          (substring iswitchb-common-match-string
                                     (length name))