129 |
;; See the User Variables section below for easy ways to change the |
;; See the User Variables section below for easy ways to change the |
130 |
;; functionality of the program. These are accessible using the |
;; functionality of the program. These are accessible using the |
131 |
;; custom package. |
;; custom package. |
132 |
;; To modify the keybindings, use the hook provided. For example: |
;; To modify the keybindings, use something like: |
|
;;(add-hook 'iswitchb-define-mode-map-hook |
|
|
;; 'iswitchb-my-keys) |
|
133 |
;; |
;; |
134 |
|
;;(add-hook 'iswitchb-mode-hook 'iswitchb-my-keys) |
135 |
;;(defun iswitchb-my-keys () |
;;(defun iswitchb-my-keys () |
136 |
;; "Add my keybindings for iswitchb." |
;; "Add my keybindings for iswitchb." |
137 |
;; (define-key iswitchb-mode-map " " 'iswitchb-next-match) |
;; (define-key iswitchb-mode-map " " 'iswitchb-next-match)) |
|
;; ) |
|
138 |
;; |
;; |
139 |
;; Seeing all the matching buffers |
;; Seeing all the matching buffers |
140 |
;; |
;; |
235 |
:link '(url-link "http://www.anc.ed.ac.uk/~stephen/emacs/") |
:link '(url-link "http://www.anc.ed.ac.uk/~stephen/emacs/") |
236 |
:link '(emacs-library-link :tag "Lisp File" "iswitchb.el")) |
:link '(emacs-library-link :tag "Lisp File" "iswitchb.el")) |
237 |
|
|
|
;;;###autoload |
|
|
(defcustom iswitchb-mode nil |
|
|
"Toggle Iswitchb mode. |
|
|
Setting this variable directly does not take effect; |
|
|
use either \\[customize] or the function `iswitchb-mode'." |
|
|
:set (lambda (symbol value) |
|
|
(iswitchb-mode (or value 0))) |
|
|
:initialize 'custom-initialize-default |
|
|
:group 'iswitchb |
|
|
:require 'iswitchb |
|
|
:version "21.1" |
|
|
:type 'boolean) |
|
|
|
|
|
(defcustom iswitchb-mode-hook nil |
|
|
"Hook run at the end of function `iswitchb-mode'." |
|
|
:group 'iswitchb |
|
|
:type 'hook) |
|
|
|
|
238 |
(defcustom iswitchb-case case-fold-search |
(defcustom iswitchb-case case-fold-search |
239 |
"*Non-nil if searching of buffer names should ignore case. |
"*Non-nil if searching of buffer names should ignore case. |
240 |
If this is non-nil but the user input has any upper case letters, matching |
If this is non-nil but the user input has any upper case letters, matching |
307 |
:type 'boolean |
:type 'boolean |
308 |
:group 'iswitchb) |
:group 'iswitchb) |
309 |
|
|
|
(defcustom iswitchb-define-mode-map-hook nil |
|
|
"Hook to define keys in `iswitchb-mode-map' for extra keybindings." |
|
|
:type 'hook |
|
|
:group 'iswitchb) |
|
|
|
|
310 |
(defcustom iswitchb-use-fonts t |
(defcustom iswitchb-use-fonts t |
311 |
"*Non-nil means use font-lock fonts for showing first match." |
"*Non-nil means use font-lock fonts for showing first match." |
312 |
:type 'boolean |
:type 'boolean |
503 |
;;\\[iswitchb-toggle-ignore] Toggle ignoring certain buffers (see \ |
;;\\[iswitchb-toggle-ignore] Toggle ignoring certain buffers (see \ |
504 |
;;`iswitchb-buffer-ignore') |
;;`iswitchb-buffer-ignore') |
505 |
|
|
506 |
(let |
(let* ((prompt "iswitch ") |
507 |
(prompt buf) |
(buf (iswitchb-read-buffer prompt))) |
|
|
|
|
(setq prompt (format "iswitch ")) |
|
|
|
|
|
(setq buf (iswitchb-read-buffer prompt)) |
|
508 |
|
|
509 |
;;(message "chosen text %s" iswitchb-final-text) |
;;(message "chosen text %s" iswitchb-final-text) |
510 |
;; Choose the buffer name: either the text typed in, or the head |
;; Choose the buffer name: either the text typed in, or the head |
567 |
nil ;require-match [handled elsewhere] |
nil ;require-match [handled elsewhere] |
568 |
nil ;initial-contents |
nil ;initial-contents |
569 |
'iswitchb-history))) |
'iswitchb-history))) |
570 |
|
(if (get-buffer iswitchb-final-text) |
571 |
|
;; This happens for example if the buffer was chosen with the mouse. |
572 |
|
(setq iswitchb-matches (list iswitchb-final-text))) |
573 |
|
|
574 |
;; Handling the require-match must be done in a better way. |
;; Handling the require-match must be done in a better way. |
575 |
(if (and require-match (not (iswitchb-existing-buffer-p))) |
(if (and require-match (not (iswitchb-existing-buffer-p))) |
576 |
(error "Must specify valid buffer")) |
(error "Must specify valid buffer")) |
890 |
(cons (car las) lis)))) |
(cons (car las) lis)))) |
891 |
|
|
892 |
(defun iswitchb-completion-help () |
(defun iswitchb-completion-help () |
893 |
"Show possible completions in a *Buffer Completions* buffer." |
"Show possible completions in a *Completions* buffer." |
894 |
;; we could allow this buffer to be used to select match, but I think |
;; we could allow this buffer to be used to select match, but I think |
895 |
;; choose-completion-string will need redefining, so it just inserts |
;; choose-completion-string will need redefining, so it just inserts |
896 |
;; choice with out any previous input. |
;; choice with out any previous input. |
897 |
(interactive) |
(interactive) |
898 |
(setq iswitchb-rescan nil) |
(setq iswitchb-rescan nil) |
899 |
(let ((completion-setup-hook nil) ;disable fancy highlight/selection. |
(let ((buf (current-buffer)) |
900 |
(buf (current-buffer)) |
(temp-buf "*Completions*") |
901 |
(temp-buf "*Buffer Completions*") |
(win)) |
|
(win) |
|
|
(again (eq last-command this-command))) |
|
902 |
|
|
903 |
(if again |
(if (eq last-command this-command) |
904 |
;; scroll buffer |
;; scroll buffer |
905 |
(progn |
(progn |
906 |
(set-buffer temp-buf) |
(set-buffer temp-buf) |
1239 |
(defun iswitchb-minibuffer-setup () |
(defun iswitchb-minibuffer-setup () |
1240 |
"Set up minibuffer for `iswitchb-buffer'. |
"Set up minibuffer for `iswitchb-buffer'. |
1241 |
Copied from `icomplete-minibuffer-setup-hook'." |
Copied from `icomplete-minibuffer-setup-hook'." |
1242 |
(if (iswitchb-entryfn-p) |
(when (iswitchb-entryfn-p) |
1243 |
(progn |
(set (make-local-variable 'iswitchb-use-mycompletion) t) |
1244 |
|
(add-hook 'pre-command-hook 'iswitchb-pre-command nil t) |
1245 |
(make-local-variable 'iswitchb-use-mycompletion) |
(add-hook 'post-command-hook 'iswitchb-post-command nil t) |
1246 |
(setq iswitchb-use-mycompletion t) |
(run-hooks 'iswitchb-minibuffer-setup-hook))) |
|
(make-local-hook 'pre-command-hook) |
|
|
(add-hook 'pre-command-hook |
|
|
'iswitchb-pre-command |
|
|
nil t) |
|
|
(make-local-hook 'post-command-hook) |
|
|
(add-hook 'post-command-hook |
|
|
'iswitchb-post-command |
|
|
nil t) |
|
|
|
|
|
(run-hooks 'iswitchb-minibuffer-setup-hook)))) |
|
1247 |
|
|
1248 |
(defun iswitchb-pre-command () |
(defun iswitchb-pre-command () |
1249 |
"Run before command in `iswitchb-buffer'." |
"Run before command in `iswitchb-buffer'." |
1296 |
(isearch-no-upper-case-p iswitchb-text t)))) |
(isearch-no-upper-case-p iswitchb-text t)))) |
1297 |
|
|
1298 |
;;;###autoload |
;;;###autoload |
1299 |
(defun iswitchb-mode (&optional arg) |
(define-minor-mode iswitchb-mode |
1300 |
"Toggle Iswitchb global minor mode. |
"Toggle Iswitchb global minor mode. |
1301 |
With arg, turn Iswitchb mode on if and only iff ARG is positive. |
With arg, turn Iswitchb mode on if and only iff ARG is positive. |
1302 |
This mode enables switching between buffers using substrings. See |
This mode enables switching between buffers using substrings. See |
1303 |
`iswitchb' for details." |
`iswitchb' for details." |
1304 |
(interactive "P") |
nil nil iswitchb-global-map :global t :group 'iswitchb |
|
(setq iswitchb-mode |
|
|
(if arg |
|
|
(> (prefix-numeric-value arg) 0) |
|
|
(not iswitchb-mode))) |
|
1305 |
(if iswitchb-mode |
(if iswitchb-mode |
1306 |
(add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup) |
(add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup) |
1307 |
(remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)) |
(remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup))) |
|
(run-hooks 'iswitchb-mode-hook) |
|
|
(if (interactive-p) |
|
|
(message "Iswitchb mode %sabled" |
|
|
(if iswitchb-mode "en" "dis")))) |
|
|
|
|
|
(unless (assq 'iswitchb-mode minor-mode-map-alist) |
|
|
(push (cons 'iswitchb-mode iswitchb-global-map) |
|
|
minor-mode-map-alist)) |
|
1308 |
|
|
1309 |
(provide 'iswitchb) |
(provide 'iswitchb) |
1310 |
|
|