diff options
| author | Karl Heuer | 1997-12-19 14:58:42 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-12-19 14:58:42 +0000 |
| commit | ccd2f9976a0dcdc12fb60f4dc8868ff53790b46f (patch) | |
| tree | 3aff91313aa43303adac0a50954c8e1d37a3a83e | |
| parent | dcaa5925632d41f285b1638179e30cedd5bfef9f (diff) | |
| download | emacs-ccd2f9976a0dcdc12fb60f4dc8868ff53790b46f.tar.gz emacs-ccd2f9976a0dcdc12fb60f4dc8868ff53790b46f.zip | |
(iswitchb-completion-help): Multiple TAB presses
scroll the completion window.
(iswitchb-read-buffer): New function to act as drop-in replacement
for read-buffer.
| -rw-r--r-- | lisp/iswitchb.el | 275 |
1 files changed, 157 insertions, 118 deletions
diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el index 862d5ef3045..fb57ff69bad 100644 --- a/lisp/iswitchb.el +++ b/lisp/iswitchb.el | |||
| @@ -88,12 +88,13 @@ | |||
| 88 | ;; Of course, where this function comes in really useful is when you | 88 | ;; Of course, where this function comes in really useful is when you |
| 89 | ;; can specify the buffer using only a few keystrokes. In the above | 89 | ;; can specify the buffer using only a few keystrokes. In the above |
| 90 | ;; example, the quickest way to get to the "123456" buffer would be | 90 | ;; example, the quickest way to get to the "123456" buffer would be |
| 91 | ;; just to type 4 and then RET (assuming there isnt any newer buffer | 91 | ;; just to type 4 and then RET (assuming there isn't any newer buffer |
| 92 | ;; with 4 in its name). | 92 | ;; with 4 in its name). |
| 93 | 93 | ||
| 94 | ;; To see a full list of all matching buffers in a separate buffer, | 94 | ;; To see a full list of all matching buffers in a separate buffer, |
| 95 | ;; hit ? or press TAB when there are no further completions to the | 95 | ;; hit ? or press TAB when there are no further completions to the |
| 96 | ;; substring. | 96 | ;; substring. Repeated TAB presses will scroll you through this |
| 97 | ;; separate buffer. | ||
| 97 | 98 | ||
| 98 | ;; The buffer at the head of the list can be killed by pressing C-k. | 99 | ;; The buffer at the head of the list can be killed by pressing C-k. |
| 99 | ;; If the buffer needs saving, you will be queried before the buffer | 100 | ;; If the buffer needs saving, you will be queried before the buffer |
| @@ -116,7 +117,7 @@ | |||
| 116 | ;; 'iswitchb-my-keys) | 117 | ;; 'iswitchb-my-keys) |
| 117 | ;; | 118 | ;; |
| 118 | ;;(defun iswitchb-my-keys () | 119 | ;;(defun iswitchb-my-keys () |
| 119 | ;; "Add my keybings for iswitchb." | 120 | ;; "Add my keybindings for iswitchb." |
| 120 | ;; (define-key iswitchb-mode-map " " 'iswitchb-next-match) | 121 | ;; (define-key iswitchb-mode-map " " 'iswitchb-next-match) |
| 121 | ;; ) | 122 | ;; ) |
| 122 | ;; | 123 | ;; |
| @@ -153,30 +154,15 @@ | |||
| 153 | ;; this is too harsh, let me know. Colouring of the matching buffer | 154 | ;; this is too harsh, let me know. Colouring of the matching buffer |
| 154 | ;; name was suggested by Carsten Dominik (dominik@strw.leidenuniv.nl) | 155 | ;; name was suggested by Carsten Dominik (dominik@strw.leidenuniv.nl) |
| 155 | 156 | ||
| 156 | ;;; Comparison with iswitch-buffer | ||
| 157 | |||
| 158 | ;; This package is a rewrite of iswitch-buffer, using the minibuffer | ||
| 159 | ;; rather than the echo area. The advantages of using the minibuffer | ||
| 160 | ;; are several: | ||
| 161 | ;; o minibuffer has more powerful editing facilities | ||
| 162 | ;; o doesnt interfere with other packages that use the echo area | ||
| 163 | ;; o *Messages* buffer doesnt get filled up with all of the messages that | ||
| 164 | ;; go to the modeline | ||
| 165 | ;; o cursor is in the minibuffer, which somehow looks right. | ||
| 166 | ;; o minibuffer can be resized dynamically to show all the possible matching | ||
| 167 | ;; buffers rather than just the first line's worth (using rsz-mini). | ||
| 168 | ;; | ||
| 169 | ;; Disadvantages: | ||
| 170 | ;; o cant change the prompt to indicate status of searching (eg whether | ||
| 171 | ;; regexp searching is currently on). | ||
| 172 | 157 | ||
| 158 | ;; Replacement for read-buffer. | ||
| 173 | 159 | ||
| 174 | ;;; TODO | 160 | ;; iswitchb-read-buffer has been written to be a drop in replacement |
| 175 | ;; Could this selection also be used for other buffer selection | 161 | ;; for the normal buffer selection routine `read-buffer'. To use |
| 176 | ;; routines, such as append-to-buffer and kill-buffer? | 162 | ;; iswitch for all buffer selections, add: |
| 163 | ;; (setq read-buffer-function 'iswitchb-read-buffer) | ||
| 177 | 164 | ||
| 178 | ;; Pressing Tab key twice (without completion) does not scroll the | 165 | ;;; TODO |
| 179 | ;; list of buffers. | ||
| 180 | 166 | ||
| 181 | ;;; Acknowledgements | 167 | ;;; Acknowledgements |
| 182 | 168 | ||
| @@ -367,7 +353,7 @@ interfere with other minibuffer usage.") | |||
| 367 | "Stores the users string as it is typed in.") | 353 | "Stores the users string as it is typed in.") |
| 368 | 354 | ||
| 369 | (defvar iswitchb-matches nil | 355 | (defvar iswitchb-matches nil |
| 370 | "List of buffers currenly matching `iswitchb-text'.") | 356 | "List of buffers currently matching `iswitchb-text'.") |
| 371 | 357 | ||
| 372 | (defvar iswitchb-mode-map nil | 358 | (defvar iswitchb-mode-map nil |
| 373 | "Keymap for `iswitchb-buffer'.") | 359 | "Keymap for `iswitchb-buffer'.") |
| @@ -395,7 +381,7 @@ selected.") | |||
| 395 | "Set up the keymap for `iswitchb-buffer'." | 381 | "Set up the keymap for `iswitchb-buffer'." |
| 396 | (interactive) | 382 | (interactive) |
| 397 | (let (map) | 383 | (let (map) |
| 398 | ;; generated every time so that it can inheret new functions. | 384 | ;; generated every time so that it can inherit new functions. |
| 399 | ;;(or iswitchb-mode-map | 385 | ;;(or iswitchb-mode-map |
| 400 | 386 | ||
| 401 | (setq map (copy-keymap minibuffer-local-map)) | 387 | (setq map (copy-keymap minibuffer-local-map)) |
| @@ -409,6 +395,7 @@ selected.") | |||
| 409 | ;;(define-key map "\C-a" 'iswitchb-toggle-ignore) | 395 | ;;(define-key map "\C-a" 'iswitchb-toggle-ignore) |
| 410 | (define-key map "\C-c" 'iswitchb-toggle-case) | 396 | (define-key map "\C-c" 'iswitchb-toggle-case) |
| 411 | (define-key map "\C-k" 'iswitchb-kill-buffer) | 397 | (define-key map "\C-k" 'iswitchb-kill-buffer) |
| 398 | (define-key map "\C-m" 'iswitchb-exit-minibuffer) | ||
| 412 | (setq iswitchb-mode-map map) | 399 | (setq iswitchb-mode-map map) |
| 413 | (run-hooks 'iswitchb-define-mode-map-hook) | 400 | (run-hooks 'iswitchb-define-mode-map-hook) |
| 414 | )) | 401 | )) |
| @@ -436,7 +423,7 @@ If no buffer is found, prompt for a new one. | |||
| 436 | matches all buffers. If there is only one match, select that buffer. | 423 | matches all buffers. If there is only one match, select that buffer. |
| 437 | If there is no common suffix, show a list of all matching buffers | 424 | If there is no common suffix, show a list of all matching buffers |
| 438 | in a separate window. | 425 | in a separate window. |
| 439 | \\[iswitchb-toggle-regexp] Toggle rexep searching. | 426 | \\[iswitchb-toggle-regexp] Toggle regexp searching. |
| 440 | \\[iswitchb-toggle-case] Toggle case-sensitive searching of buffer names. | 427 | \\[iswitchb-toggle-case] Toggle case-sensitive searching of buffer names. |
| 441 | \\[iswitchb-completion-help] Show list of matching buffers in separate window. | 428 | \\[iswitchb-completion-help] Show list of matching buffers in separate window. |
| 442 | \\[iswitchb-find-file] Exit iswitchb and drop into find-file. | 429 | \\[iswitchb-find-file] Exit iswitchb and drop into find-file. |
| @@ -445,68 +432,93 @@ in a separate window. | |||
| 445 | ;;`iswitchb-buffer-ignore') | 432 | ;;`iswitchb-buffer-ignore') |
| 446 | 433 | ||
| 447 | (let | 434 | (let |
| 435 | (prompt buf) | ||
| 436 | |||
| 437 | (setq prompt (format "iswitch ")) | ||
| 438 | |||
| 439 | (setq buf (iswitchb-read-buffer prompt)) | ||
| 440 | |||
| 441 | |||
| 442 | ;;(message "chosen text %s" iswitchb-final-text) | ||
| 443 | ;; Choose the buffer name: either the text typed in, or the head | ||
| 444 | ;; of the list of matches | ||
| 445 | |||
| 446 | (cond ( (eq iswitchb-exit 'findfile) | ||
| 447 | (call-interactively 'find-file)) | ||
| 448 | |||
| 449 | (t | ||
| 450 | ;; View the buffer | ||
| 451 | (message "go to buf %s" buf) | ||
| 452 | ;; Check buf is non-nil. | ||
| 453 | (if buf | ||
| 454 | (if (get-buffer buf) | ||
| 455 | ;; buffer exists, so view it and then exit | ||
| 456 | (iswitchb-visit-buffer buf) | ||
| 457 | ;; else buffer doesn't exist | ||
| 458 | (iswitchb-possible-new-buffer buf))) | ||
| 459 | )) | ||
| 460 | |||
| 461 | )) | ||
| 462 | |||
| 463 | |||
| 464 | |||
| 465 | (defun iswitchb-read-buffer (prompt &optional default require-match) | ||
| 466 | "Replacement for the built-in `read-buffer'. | ||
| 467 | Return the name of a buffer selected. | ||
| 468 | PROMPT is the prompt to give to the user. DEFAULT if given is the default | ||
| 469 | buffer to be selected, which will go to the front of the list. | ||
| 470 | If REQUIRE-MATCH is non-nil, an existing-buffer must be selected." | ||
| 471 | (let | ||
| 448 | ( | 472 | ( |
| 449 | prompt | ||
| 450 | buf-sel | 473 | buf-sel |
| 451 | iswitchb-final-text | 474 | iswitchb-final-text |
| 452 | (minibuffer-confirm-incomplete nil) ;XEmacs todo: prevent `;confirm' | ||
| 453 | (icomplete-mode nil) ;; prevent icomplete starting up | 475 | (icomplete-mode nil) ;; prevent icomplete starting up |
| 454 | ;; can only use fonts if they have been bound. | 476 | ;; can only use fonts if they have been bound. |
| 455 | (iswitchb-use-fonts (and iswitchb-use-fonts | 477 | (iswitchb-use-fonts (and iswitchb-use-fonts |
| 456 | (boundp 'font-lock-comment-face) | 478 | (boundp 'font-lock-comment-face) |
| 457 | (boundp 'font-lock-function-name-face))) | 479 | (boundp 'font-lock-function-name-face)))) |
| 458 | ) | 480 | |
| 459 | |||
| 460 | (iswitchb-define-mode-map) | 481 | (iswitchb-define-mode-map) |
| 461 | (setq iswitchb-exit nil) | 482 | (setq iswitchb-exit nil) |
| 462 | (setq iswitchb-rescan t) | 483 | (setq iswitchb-rescan t) |
| 463 | (setq iswitchb-text "") | 484 | (setq iswitchb-text "") |
| 485 | (iswitchb-make-buflist default) | ||
| 464 | (iswitchb-set-matches) | 486 | (iswitchb-set-matches) |
| 465 | (setq prompt (format "iswitch ")) | ||
| 466 | (iswitchb-make-buflist) | ||
| 467 | (let | 487 | (let |
| 468 | ((minibuffer-local-completion-map iswitchb-mode-map)) | 488 | ((minibuffer-local-completion-map iswitchb-mode-map) |
| 489 | (iswitchb-prepost-hooks t) | ||
| 490 | (iswitchb-require-match require-match) | ||
| 491 | ) | ||
| 469 | ;; prompt the user for the buffer name | 492 | ;; prompt the user for the buffer name |
| 470 | (setq iswitchb-final-text (completing-read prompt | 493 | (setq iswitchb-final-text (completing-read |
| 471 | ;;nil | 494 | prompt ;the prompt |
| 472 | '(("dummy".1)) | 495 | '(("dummy".1)) ;table |
| 473 | ;;("2".2) ("3".3)) | 496 | nil ;predicate |
| 474 | nil nil | 497 | nil ;require-match [handled elsewhere] |
| 475 | nil;init string | 498 | nil ;initial-contents |
| 476 | 'iswitchb-history))) | 499 | 'iswitchb-history))) |
| 477 | 500 | ;; Handling the require-match must be done in a better way. | |
| 478 | ;;(message "chosen text %s" iswitchb-final-text) | 501 | (if (and require-match (not (iswitchb-existing-buffer-p))) |
| 479 | ;; Choose the buffer name: either the text typed in, or the head | 502 | (error "must specify valid buffer")) |
| 480 | ;; of the list of matches | 503 | |
| 504 | (if (or | ||
| 505 | (eq iswitchb-exit 'takeprompt) | ||
| 506 | (null iswitchb-matches)) | ||
| 507 | (setq buf-sel iswitchb-final-text) | ||
| 508 | ;; else take head of list | ||
| 509 | (setq buf-sel (car iswitchb-matches))) | ||
| 510 | |||
| 511 | ;; Or possibly choose the default buffer | ||
| 512 | (if (equal iswitchb-final-text "") | ||
| 513 | (setq buf-sel | ||
| 514 | (car iswitchb-matches))) | ||
| 481 | 515 | ||
| 482 | (cond ( (eq iswitchb-exit 'findfile) | 516 | buf-sel)) |
| 483 | (call-interactively 'find-file)) | ||
| 484 | 517 | ||
| 485 | (t | ||
| 486 | (if (or | ||
| 487 | (eq iswitchb-exit 'takeprompt) | ||
| 488 | (null iswitchb-matches)) | ||
| 489 | (setq buf-sel iswitchb-final-text) | ||
| 490 | ;; else take head of list | ||
| 491 | (setq buf-sel (car iswitchb-matches))) | ||
| 492 | |||
| 493 | ;; Or possibly choose the default buffer | ||
| 494 | (if (equal iswitchb-final-text "") | ||
| 495 | (setq buf-sel (car iswitchb-matches))) | ||
| 496 | |||
| 497 | ;; View the buffer | ||
| 498 | (message "go to buf %s" buf-sel) | ||
| 499 | ;; Check buf-sel is non-nil. | ||
| 500 | (if buf-sel | ||
| 501 | (if (get-buffer buf-sel) | ||
| 502 | ;; buffer exists, so view it and then exit | ||
| 503 | (iswitchb-visit-buffer buf-sel) | ||
| 504 | ;; else buffer doesnt exist | ||
| 505 | (iswitchb-possible-new-buffer buf-sel))) | ||
| 506 | )) | ||
| 507 | |||
| 508 | )) | ||
| 509 | 518 | ||
| 519 | (defun iswitchb-existing-buffer-p () | ||
| 520 | "Return non-nil if there is a matching buffer." | ||
| 521 | (not (null iswitchb-matches))) | ||
| 510 | 522 | ||
| 511 | ;;; COMPLETION CODE | 523 | ;;; COMPLETION CODE |
| 512 | 524 | ||
| @@ -534,7 +546,7 @@ The result is stored in `iswitchb-common-match-string'." | |||
| 534 | (iswitchb-completion-help) | 546 | (iswitchb-completion-help) |
| 535 | ) | 547 | ) |
| 536 | 548 | ||
| 537 | ((eq 1 (length iswitchb-matches)) | 549 | ((= 1 (length iswitchb-matches)) |
| 538 | ;; only one choice, so select it. | 550 | ;; only one choice, so select it. |
| 539 | (exit-minibuffer)) | 551 | (exit-minibuffer)) |
| 540 | 552 | ||
| @@ -545,7 +557,7 @@ The result is stored in `iswitchb-common-match-string'." | |||
| 545 | iswitchb-matches iswitchb-text)) | 557 | iswitchb-matches iswitchb-text)) |
| 546 | (if (and (not (memq res '(t nil))) | 558 | (if (and (not (memq res '(t nil))) |
| 547 | (not (equal res iswitchb-text))) | 559 | (not (equal res iswitchb-text))) |
| 548 | ;; found something to complete, so put it in the minibuff. | 560 | ;; found something to complete, so put it in the minibuffer. |
| 549 | (progn | 561 | (progn |
| 550 | (setq iswitchb-rescan nil) | 562 | (setq iswitchb-rescan nil) |
| 551 | (delete-region (point-min) (point)) | 563 | (delete-region (point-min) (point)) |
| @@ -592,6 +604,13 @@ The result is stored in `iswitchb-common-match-string'." | |||
| 592 | (setq iswitchb-rescan t) | 604 | (setq iswitchb-rescan t) |
| 593 | ) | 605 | ) |
| 594 | 606 | ||
| 607 | (defun iswitchb-exit-minibuffer () | ||
| 608 | "Exit minibuffer, but make sure we have a match if one is needed." | ||
| 609 | (interactive) | ||
| 610 | (if (or (not iswitchb-require-match) | ||
| 611 | (iswitchb-existing-buffer-p)) | ||
| 612 | (throw 'exit nil) | ||
| 613 | )) | ||
| 595 | 614 | ||
| 596 | (defun iswitchb-select-buffer-text () | 615 | (defun iswitchb-select-buffer-text () |
| 597 | "Select the buffer named by the prompt. | 616 | "Select the buffer named by the prompt. |
| @@ -648,12 +667,13 @@ If no buffer exactly matching the prompt exists, maybe create a new one." | |||
| 648 | ;;; CREATE LIST OF ALL CURRENT BUFFERS | 667 | ;;; CREATE LIST OF ALL CURRENT BUFFERS |
| 649 | 668 | ||
| 650 | 669 | ||
| 651 | (defun iswitchb-make-buflist () | 670 | (defun iswitchb-make-buflist (default) |
| 652 | "Set `iswitchb-buflist' to the current list of buffers. | 671 | "Set `iswitchb-buflist' to the current list of buffers. |
| 653 | Currently visible buffers are put at the end of the list. | 672 | Currently visible buffers are put at the end of the list. |
| 654 | The hook `iswitchb-make-buflist-hook' is run after the list has been | 673 | The hook `iswitchb-make-buflist-hook' is run after the list has been |
| 655 | created to allow the user to further modify the order of the buffer names | 674 | created to allow the user to further modify the order of the buffer names |
| 656 | in this list." | 675 | in this list. If DEFAULT is non-nil, and corresponds to an existing buffer, |
| 676 | it is put to the start of the list." | ||
| 657 | (setq iswitchb-buflist | 677 | (setq iswitchb-buflist |
| 658 | (let* ((iswitchb-current-buffers (iswitchb-get-buffers-in-frames)) | 678 | (let* ((iswitchb-current-buffers (iswitchb-get-buffers-in-frames)) |
| 659 | (buflist | 679 | (buflist |
| @@ -669,7 +689,14 @@ in this list." | |||
| 669 | (buffer-list))))) | 689 | (buffer-list))))) |
| 670 | (nconc buflist iswitchb-current-buffers) | 690 | (nconc buflist iswitchb-current-buffers) |
| 671 | (run-hooks 'iswitchb-make-buflist-hook) | 691 | (run-hooks 'iswitchb-make-buflist-hook) |
| 672 | buflist))) | 692 | ;; Should this be after the hooks, or should the hooks be the |
| 693 | ;; final thing to be run? | ||
| 694 | (if default | ||
| 695 | (progn | ||
| 696 | (setq buflist (delete default buflist)) | ||
| 697 | (setq buflist (cons default buflist)) | ||
| 698 | )) | ||
| 699 | buflist))) | ||
| 673 | 700 | ||
| 674 | (defun iswitchb-to-end (lst) | 701 | (defun iswitchb-to-end (lst) |
| 675 | "Move the elements from LST to the end of BUFLIST." | 702 | "Move the elements from LST to the end of BUFLIST." |
| @@ -809,7 +836,7 @@ If `iswitchb-change-word-sub' cannot be found in WORD, return nil." | |||
| 809 | subs | 836 | subs |
| 810 | (regexp-quote subs))) | 837 | (regexp-quote subs))) |
| 811 | (setq res (mapcar 'iswitchb-word-matching-substring lis)) | 838 | (setq res (mapcar 'iswitchb-word-matching-substring lis)) |
| 812 | (setq res (delq nil res)) ;; remove any nil elements (shouldnt happen) | 839 | (setq res (delq nil res)) ;; remove any nil elements (shouldn't happen) |
| 813 | (setq alist (mapcar 'iswitchb-makealist res)) ;; could use an OBARRAY | 840 | (setq alist (mapcar 'iswitchb-makealist res)) ;; could use an OBARRAY |
| 814 | 841 | ||
| 815 | ;; try-completion returns t if there is an exact match. | 842 | ;; try-completion returns t if there is an exact match. |
| @@ -847,30 +874,47 @@ Return the modified list with the last element prepended to it." | |||
| 847 | (interactive) | 874 | (interactive) |
| 848 | (setq iswitchb-rescan nil) | 875 | (setq iswitchb-rescan nil) |
| 849 | (let ((completion-setup-hook nil) ;disable fancy highlight/selection. | 876 | (let ((completion-setup-hook nil) ;disable fancy highlight/selection. |
| 850 | ) | 877 | (buf (current-buffer)) |
| 851 | (with-output-to-temp-buffer "*Buffer Completions*" | 878 | (temp-buf "*Buffer Completions*") |
| 852 | (if iswitchb-xemacs | 879 | (win) |
| 853 | 880 | (again (eq last-command this-command))) | |
| 854 | ;; XEmacs extents are put on by default, doesn't seem to be | 881 | |
| 855 | ;; any way of switching them off. | 882 | (if again |
| 856 | (display-completion-list (if iswitchb-matches | 883 | ;; scroll buffer |
| 857 | iswitchb-matches | 884 | (progn |
| 858 | iswitchb-buflist) | 885 | (set-buffer temp-buf) |
| 859 | :help-string "iswitchb " | 886 | (setq win (get-buffer-window temp-buf)) |
| 887 | (if (pos-visible-in-window-p (point-max) win) | ||
| 888 | (set-window-start win (point-min)) | ||
| 889 | (scroll-other-window)) | ||
| 890 | (set-buffer buf) | ||
| 891 | ) | ||
| 892 | |||
| 893 | |||
| 894 | (with-output-to-temp-buffer temp-buf | ||
| 895 | (if iswitchb-xemacs | ||
| 896 | |||
| 897 | ;; XEmacs extents are put on by default, doesn't seem to be | ||
| 898 | ;; any way of switching them off. | ||
| 899 | (display-completion-list (if iswitchb-matches | ||
| 900 | iswitchb-matches | ||
| 901 | iswitchb-buflist) | ||
| 902 | :help-string "iswitchb " | ||
| 860 | :activate-callback | 903 | :activate-callback |
| 861 | '(lambda (x y z) | 904 | '(lambda (x y z) |
| 862 | (message "doesnt work yet, sorry!"))) | 905 | (message "doesn't work yet, sorry!"))) |
| 863 | ;; else running Emacs | 906 | ;; else running Emacs |
| 864 | (display-completion-list (if iswitchb-matches | 907 | (display-completion-list (if iswitchb-matches |
| 865 | iswitchb-matches | 908 | iswitchb-matches |
| 866 | iswitchb-buflist)) | 909 | iswitchb-buflist)) |
| 867 | )))) | 910 | ))))) |
| 911 | |||
| 868 | 912 | ||
| 869 | 913 | ||
| 870 | ;;; KILL CURRENT BUFFER | 914 | ;;; KILL CURRENT BUFFER |
| 871 | 915 | ||
| 872 | (defun iswitchb-kill-buffer () | 916 | (defun iswitchb-kill-buffer () |
| 873 | "Kill the buffer at the head of `iswtichb-matches'." | 917 | "Kill the buffer at the head of `iswitchb-matches'." |
| 874 | (interactive) | 918 | (interactive) |
| 875 | (let ( (enable-recursive-minibuffers t) | 919 | (let ( (enable-recursive-minibuffers t) |
| 876 | buf) | 920 | buf) |
| @@ -965,8 +1009,8 @@ If BUFFER is visible in the current frame, return nil." | |||
| 965 | ;;If the buffer is visible in current frame, return nil | 1009 | ;;If the buffer is visible in current frame, return nil |
| 966 | (if (memq buffer blist) | 1010 | (if (memq buffer blist) |
| 967 | nil | 1011 | nil |
| 968 | ;; maybe in other frame... | 1012 | ;; maybe in other frame or icon |
| 969 | (get-buffer-window buffer 'visible) | 1013 | (get-buffer-window buffer 0) ; better than 'visible |
| 970 | ))) | 1014 | ))) |
| 971 | 1015 | ||
| 972 | ;;;###autoload | 1016 | ;;;###autoload |
| @@ -991,7 +1035,7 @@ in another frame. | |||
| 991 | For details of keybindings, do `\\[describe-function] iswitchb'." | 1035 | For details of keybindings, do `\\[describe-function] iswitchb'." |
| 992 | (interactive) | 1036 | (interactive) |
| 993 | (setq iswitchb-method iswitchb-default-method) | 1037 | (setq iswitchb-method iswitchb-default-method) |
| 994 | (iswitchb-entry)) | 1038 | (iswitchb)) |
| 995 | 1039 | ||
| 996 | 1040 | ||
| 997 | ;;;###autoload | 1041 | ;;;###autoload |
| @@ -1001,7 +1045,7 @@ The buffer name is selected interactively by typing a substring. | |||
| 1001 | For details of keybindings, do `\\[describe-function] iswitchb'." | 1045 | For details of keybindings, do `\\[describe-function] iswitchb'." |
| 1002 | (interactive) | 1046 | (interactive) |
| 1003 | (setq iswitchb-method 'otherwindow) | 1047 | (setq iswitchb-method 'otherwindow) |
| 1004 | (iswitchb-entry)) | 1048 | (iswitchb)) |
| 1005 | 1049 | ||
| 1006 | 1050 | ||
| 1007 | 1051 | ||
| @@ -1012,7 +1056,7 @@ The buffer name is selected interactively by typing a substring. | |||
| 1012 | For details of keybindings, do `\\[describe-function] iswitchb'." | 1056 | For details of keybindings, do `\\[describe-function] iswitchb'." |
| 1013 | (interactive) | 1057 | (interactive) |
| 1014 | (setq iswitchb-method 'display) | 1058 | (setq iswitchb-method 'display) |
| 1015 | (iswitchb-entry)) | 1059 | (iswitchb)) |
| 1016 | 1060 | ||
| 1017 | 1061 | ||
| 1018 | 1062 | ||
| @@ -1023,22 +1067,12 @@ The buffer name is selected interactively by typing a substring. | |||
| 1023 | For details of keybindings, do `\\[describe-function] iswitchb'." | 1067 | For details of keybindings, do `\\[describe-function] iswitchb'." |
| 1024 | (interactive) | 1068 | (interactive) |
| 1025 | (setq iswitchb-method 'otherframe) | 1069 | (setq iswitchb-method 'otherframe) |
| 1026 | (iswitchb-entry)) | ||
| 1027 | |||
| 1028 | |||
| 1029 | |||
| 1030 | (defun iswitchb-entry () | ||
| 1031 | "Simply fall into `iswitchb' -- the main function." | ||
| 1032 | (iswitchb)) | 1070 | (iswitchb)) |
| 1033 | 1071 | ||
| 1034 | |||
| 1035 | |||
| 1036 | |||
| 1037 | |||
| 1038 | ;;; XEmacs hack for showing default buffer | 1072 | ;;; XEmacs hack for showing default buffer |
| 1039 | 1073 | ||
| 1040 | ;; The first time we enter the minibuffer, Emacs puts up the default | 1074 | ;; The first time we enter the minibuffer, Emacs puts up the default |
| 1041 | ;; buffer to switch to, but XEmacs doesnt -- presumably there is a | 1075 | ;; buffer to switch to, but XEmacs doesn't -- presumably there is a |
| 1042 | ;; subtle difference in the two versions of post-command-hook. The | 1076 | ;; subtle difference in the two versions of post-command-hook. The |
| 1043 | ;; default is shown for both whenever we delete all of our text | 1077 | ;; default is shown for both whenever we delete all of our text |
| 1044 | ;; though, indicating its just a problem the first time we enter the | 1078 | ;; though, indicating its just a problem the first time we enter the |
| @@ -1061,7 +1095,7 @@ This is a hack for XEmacs, and should really be handled by `iswitchb-exhibit'." | |||
| 1061 | 1095 | ||
| 1062 | 1096 | ||
| 1063 | ;;; XEmacs / backspace key | 1097 | ;;; XEmacs / backspace key |
| 1064 | ;; For some reason, if the backspace key is pressed in xemacs, the | 1098 | ;; For some reason, if the backspace key is pressed in XEmacs, the |
| 1065 | ;; line gets confused, so I've added a simple key definition to make | 1099 | ;; line gets confused, so I've added a simple key definition to make |
| 1066 | ;; backspace act like the normal delete key. | 1100 | ;; backspace act like the normal delete key. |
| 1067 | 1101 | ||
| @@ -1135,7 +1169,7 @@ Modified from `icomplete-completions'." | |||
| 1135 | (setq first (car comps)) | 1169 | (setq first (car comps)) |
| 1136 | (setq first (format "%s" first)) | 1170 | (setq first (format "%s" first)) |
| 1137 | (put-text-property 0 (length first) 'face | 1171 | (put-text-property 0 (length first) 'face |
| 1138 | (if (eq (length comps) 1) | 1172 | (if (= (length comps) 1) |
| 1139 | 'font-lock-comment-face | 1173 | 'font-lock-comment-face |
| 1140 | 'font-lock-function-name-face) | 1174 | 'font-lock-function-name-face) |
| 1141 | first) | 1175 | first) |
| @@ -1262,12 +1296,17 @@ Copied from `icomplete-tidy'." | |||
| 1262 | 1296 | ||
| 1263 | (defun iswitchb-entryfn-p () | 1297 | (defun iswitchb-entryfn-p () |
| 1264 | "Return non-nil if `this-command' shows we are using `iswitchb-buffer'." | 1298 | "Return non-nil if `this-command' shows we are using `iswitchb-buffer'." |
| 1265 | (and (symbolp this-command) ; ignore lambda functions | 1299 | (or (boundp 'iswitchb-prepost-hooks) |
| 1266 | (memq this-command | 1300 | ;; I think the of this may be redundant, since the prepost hooks |
| 1267 | '(iswitchb-buffer | 1301 | ;; will always be set in the iswitchb defuns. |
| 1268 | iswitchb-buffer-other-frame | 1302 | ;;(and (symbolp this-command) ; ignore lambda functions |
| 1269 | iswitchb-display-buffer | 1303 | ;;(memq this-command |
| 1270 | iswitchb-buffer-other-window)))) | 1304 | ;; '(iswitchb-buffer |
| 1305 | ;; iswitchb-buffer-other-frame | ||
| 1306 | ;; iswitchb-display-buffer | ||
| 1307 | ;; iswitchb-buffer-other-window)))) | ||
| 1308 | )) | ||
| 1309 | |||
| 1271 | 1310 | ||
| 1272 | 1311 | ||
| 1273 | 1312 | ||