/[emacs]/emacs/lisp/iswitchb.el
ViewVC logotype

Diff of /emacs/lisp/iswitchb.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.38 by pj, Sat Apr 13 12:59:56 2002 UTC revision 1.38.2.1 by miles, Fri Apr 4 06:20:08 2003 UTC
# Line 183  Line 183 
183  ;; Using iswitchb for other completion tasks.  ;; Using iswitchb for other completion tasks.
184    
185  ;; Kin Cho (kin@neoscale.com) sent the following suggestion to use  ;; Kin Cho (kin@neoscale.com) sent the following suggestion to use
186  ;; iswitchb for other completion tasks.    ;; iswitchb for other completion tasks.
187  ;;  ;;
188  ;; (defun my-icompleting-read (prompt choices)  ;; (defun my-icompleting-read (prompt choices)
189  ;;   "Use iswitch as a completing-read replacement to choose from  ;;   "Use iswitch as a completing-read replacement to choose from
# Line 209  Line 209 
209  ;;    (delete-minibuffer-contents))  ;;    (delete-minibuffer-contents))
210  ;;  ;;
211  ;; (add-hook 'iswitchb-define-mode-map-hook  ;; (add-hook 'iswitchb-define-mode-map-hook
212  ;;        '(lambda () (define-key  ;;        '(lambda () (define-key
213  ;;                      iswitchb-mode-map "\C-o"  ;;                      iswitchb-mode-map "\C-o"
214  ;;                      'iswitchb-exclude-nonmatching)))  ;;                      'iswitchb-exclude-nonmatching)))
215    
216  ;; Other lisp packages extend iswitchb behaviour to other tasks.  See  ;; Other lisp packages extend iswitchb behaviour to other tasks.  See
# Line 518  variable `iswitchb-mode'." Line 518  variable `iswitchb-mode'."
518      (define-key map "\C-m" 'iswitchb-exit-minibuffer)      (define-key map "\C-m" 'iswitchb-exit-minibuffer)
519      (setq iswitchb-mode-map map)      (setq iswitchb-mode-map map)
520      (run-hooks 'iswitchb-define-mode-map-hook)))      (run-hooks 'iswitchb-define-mode-map-hook)))
521      
522  ;;; MAIN FUNCTION  ;;; MAIN FUNCTION
523  (defun iswitchb ()  (defun iswitchb ()
524    "Switch to buffer matching a substring.    "Switch to buffer matching a substring.
# Line 547  in a separate window. Line 547  in a separate window.
547  \\[iswitchb-kill-buffer] Kill buffer at head of buffer list."  \\[iswitchb-kill-buffer] Kill buffer at head of buffer list."
548    ;;\\[iswitchb-toggle-ignore] Toggle ignoring certain buffers (see \    ;;\\[iswitchb-toggle-ignore] Toggle ignoring certain buffers (see \
549    ;;`iswitchb-buffer-ignore')    ;;`iswitchb-buffer-ignore')
550            
551    (let* ((prompt "iswitch ")    (let* ((prompt "iswitch ")
552           (buf (iswitchb-read-buffer prompt)))           (buf (iswitchb-read-buffer prompt)))
553    
# Line 626  If REQUIRE-MATCH is non-nil, an existing Line 626  If REQUIRE-MATCH is non-nil, an existing
626          (setq buf-sel iswitchb-final-text)          (setq buf-sel iswitchb-final-text)
627        ;; else take head of list        ;; else take head of list
628        (setq buf-sel (car iswitchb-matches)))        (setq buf-sel (car iswitchb-matches)))
629        
630      ;; Or possibly choose the default buffer      ;; Or possibly choose the default buffer
631      (if  (equal iswitchb-final-text "")      (if  (equal iswitchb-final-text "")
632          (setq buf-sel          (setq buf-sel
# Line 661  The result is stored in `iswitchb-common Line 661  The result is stored in `iswitchb-common
661    (let (res)    (let (res)
662      (cond ((not  iswitchb-matches)      (cond ((not  iswitchb-matches)
663             (run-hooks 'iswitchb-cannot-complete-hook))             (run-hooks 'iswitchb-cannot-complete-hook))
664              
665            ((= 1 (length iswitchb-matches))            ((= 1 (length iswitchb-matches))
666             ;; only one choice, so select it.             ;; only one choice, so select it.
667             (exit-minibuffer))             (exit-minibuffer))
668              
669            (t            (t
670             ;; else there could be some completions             ;; else there could be some completions
671             (setq res iswitchb-common-match-string)             (setq res iswitchb-common-match-string)
# Line 847  BUFFER-LIST can be list of buffers or li Line 847  BUFFER-LIST can be list of buffers or li
847           ret)           ret)
848      (mapcar      (mapcar
849       (lambda (x)       (lambda (x)
850          
851         (if do-string         (if do-string
852             (setq name x)               ;We already have the name             (setq name x)               ;We already have the name
853           (setq name (buffer-name x)))           (setq name (buffer-name x)))
854          
855         (cond         (cond
856          ((and (or (and string-format (string-match regexp name))          ((and (or (and string-format (string-match regexp name))
857                    (and (null string-format)                    (and (null string-format)
858                         (string-match (regexp-quote regexp) name)))                         (string-match (regexp-quote regexp) name)))
859                  
860                (not (iswitchb-ignore-buffername-p name)))                (not (iswitchb-ignore-buffername-p name)))
861           (setq ret (cons name ret))           (setq ret (cons name ret))
862            )))            )))
# Line 954  Return the modified list with the last e Line 954  Return the modified list with the last e
954                (set-window-start win (point-min))                (set-window-start win (point-min))
955              (scroll-other-window))              (scroll-other-window))
956            (set-buffer buf))            (set-buffer buf))
957          
958        (with-output-to-temp-buffer temp-buf        (with-output-to-temp-buffer temp-buf
959          (if iswitchb-xemacs          (if iswitchb-xemacs
960                
961              ;; XEmacs extents are put on by default, doesn't seem to be              ;; XEmacs extents are put on by default, doesn't seem to be
962              ;; any way of switching them off.              ;; any way of switching them off.
963              (display-completion-list (if iswitchb-matches              (display-completion-list (if iswitchb-matches
# Line 1043  Return the modified list with the last e Line 1043  Return the modified list with the last e
1043      (if (and iswitchb-newbuffer      (if (and iswitchb-newbuffer
1044               (or               (or
1045                (not iswitchb-prompt-newbuffer)                (not iswitchb-prompt-newbuffer)
1046                  
1047                (and iswitchb-prompt-newbuffer                (and iswitchb-prompt-newbuffer
1048                     (y-or-n-p                     (y-or-n-p
1049                      (format                      (format
# Line 1187  Copied from `icomplete-exhibit' with two Line 1187  Copied from `icomplete-exhibit' with two
1187            (iswitchb-set-common-completion)            (iswitchb-set-common-completion)
1188    
1189            ;; Insert the match-status information:            ;; Insert the match-status information:
1190            (insert (iswitchb-completions            (insert (iswitchb-completions
1191                     contents                     contents
1192                     minibuffer-completion-table                     minibuffer-completion-table
1193                     minibuffer-completion-predicate                     minibuffer-completion-predicate
# Line 1196  Copied from `icomplete-exhibit' with two Line 1196  Copied from `icomplete-exhibit' with two
1196  (defun iswitchb-completions (name candidates predicate require-match)  (defun iswitchb-completions (name candidates predicate require-match)
1197    "Return the string that is displayed after the user's text.    "Return the string that is displayed after the user's text.
1198  Modified from `icomplete-completions'."  Modified from `icomplete-completions'."
1199      
1200    (let ((comps iswitchb-matches)    (let ((comps iswitchb-matches)
1201                                          ; "-determined" - only one candidate                                          ; "-determined" - only one candidate
1202          (open-bracket-determined (if require-match "(" "["))          (open-bracket-determined (if require-match "(" "["))
# Line 1260  Modified from `icomplete-completions'." Line 1260  Modified from `icomplete-completions'."
1260    
1261                ;; put in common completion item -- what you get by                ;; put in common completion item -- what you get by
1262                ;; pressing tab                ;; pressing tab
1263                (if (> (length iswitchb-common-match-string) (length name))                (if (and (stringp iswitchb-common-match-string)
1264                           (> (length iswitchb-common-match-string) (length name)))
1265                    (concat open-bracket-determined                    (concat open-bracket-determined
1266                            (substring iswitchb-common-match-string                            (substring iswitchb-common-match-string
1267                                       (length name))                                       (length name))
# Line 1272  Modified from `icomplete-completions'." Line 1273  Modified from `icomplete-completions'."
1273                     (concat open-bracket-determined                     (concat open-bracket-determined
1274                             (substring most (length name))                             (substring most (length name))
1275                             close-bracket-determined))                             close-bracket-determined))
1276                  
1277                ;; list all alternatives                ;; list all alternatives
1278                open-bracket-prospects                open-bracket-prospects
1279                (if most-is-exact                (if most-is-exact
# Line 1303  Copied from `icomplete-tidy'." Line 1304  Copied from `icomplete-tidy'."
1304    
1305    (if (and (boundp 'iswitchb-eoinput)    (if (and (boundp 'iswitchb-eoinput)
1306             iswitchb-eoinput)             iswitchb-eoinput)
1307          
1308        (if (> iswitchb-eoinput (point-max))        (if (> iswitchb-eoinput (point-max))
1309            ;; Oops, got rug pulled out from under us - reinit:            ;; Oops, got rug pulled out from under us - reinit:
1310            (setq iswitchb-eoinput (point-max))            (setq iswitchb-eoinput (point-max))
1311          (let ((buffer-undo-list buffer-undo-list )) ; prevent entry          (let ((buffer-undo-list buffer-undo-list )) ; prevent entry
1312            (delete-region iswitchb-eoinput (point-max))))            (delete-region iswitchb-eoinput (point-max))))
1313        
1314      ;; Reestablish the local variable 'cause minibuffer-setup is weird:      ;; Reestablish the local variable 'cause minibuffer-setup is weird:
1315      (make-local-variable 'iswitchb-eoinput)      (make-local-variable 'iswitchb-eoinput)
1316      (setq iswitchb-eoinput 1)))      (setq iswitchb-eoinput 1)))

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.38.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26