diff options
| author | Gerd Moellmann | 2000-04-17 12:31:49 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-04-17 12:31:49 +0000 |
| commit | 8097dd15c28e9978b5cb666a66b3101ee1ebbe62 (patch) | |
| tree | 9300a7a1486986b035bc81e0848685ccea0b9262 | |
| parent | e3721db120f8d2317efea6c7ccda2ca8db211c3e (diff) | |
| download | emacs-8097dd15c28e9978b5cb666a66b3101ee1ebbe62.tar.gz emacs-8097dd15c28e9978b5cb666a66b3101ee1ebbe62.zip | |
(iswitchb-case): New function. If the user input
contains any upper-case characters, the search is made
case-sensitive.
| -rw-r--r-- | lisp/iswitchb.el | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el index 0b5ad730fea..0f57b789038 100644 --- a/lisp/iswitchb.el +++ b/lisp/iswitchb.el | |||
| @@ -46,7 +46,7 @@ | |||
| 46 | ;; common to all of the matching buffers as you type. | 46 | ;; common to all of the matching buffers as you type. |
| 47 | 47 | ||
| 48 | ;; This code is similar to a couple of other packages. Michael R Cook | 48 | ;; This code is similar to a couple of other packages. Michael R Cook |
| 49 | ;; <mcook@cognex.com> wrote a similar buffer switching package, but | 49 | ;; <cook@sightpath.com> wrote a similar buffer switching package, but |
| 50 | ;; does exact matching rather than substring matching on buffer names. | 50 | ;; does exact matching rather than substring matching on buffer names. |
| 51 | ;; I also modified a couple of functions from icomplete.el to provide | 51 | ;; I also modified a couple of functions from icomplete.el to provide |
| 52 | ;; the completion feedback in the minibuffer. | 52 | ;; the completion feedback in the minibuffer. |
| @@ -111,6 +111,23 @@ | |||
| 111 | ;; See the doc string of iswitchb for full keybindings and features. | 111 | ;; See the doc string of iswitchb for full keybindings and features. |
| 112 | ;; (describe-function 'iswitchb) | 112 | ;; (describe-function 'iswitchb) |
| 113 | 113 | ||
| 114 | ;; Case matching: The case of strings when matching can be ignored or | ||
| 115 | ;; used depending on the value of iswitchb-case (default is the same | ||
| 116 | ;; as case-fold-search, normally t). Imagine you have the following | ||
| 117 | ;; buffers: | ||
| 118 | ;; | ||
| 119 | ;; INBOX *info* *scratch* | ||
| 120 | ;; | ||
| 121 | ;; Then these will be the matching buffers, depending on how you type | ||
| 122 | ;; the two letters `in' and the value of iswitchb-case: | ||
| 123 | ;; | ||
| 124 | ;; iswitchb-case user input | matching buffers | ||
| 125 | ;; ---------------------------------------------- | ||
| 126 | ;; nil in | *info* | ||
| 127 | ;; t in | INBOX, *info* | ||
| 128 | ;; t IN | INBOX | ||
| 129 | ;; t In | [No match] | ||
| 130 | |||
| 114 | ;;; Customisation | 131 | ;;; Customisation |
| 115 | 132 | ||
| 116 | ;; See the User Variables section below for easy ways to change the | 133 | ;; See the User Variables section below for easy ways to change the |
| @@ -224,7 +241,9 @@ | |||
| 224 | :link '(emacs-library-link :tag "Lisp File" "iswitchb.el")) | 241 | :link '(emacs-library-link :tag "Lisp File" "iswitchb.el")) |
| 225 | 242 | ||
| 226 | (defcustom iswitchb-case case-fold-search | 243 | (defcustom iswitchb-case case-fold-search |
| 227 | "*Non-nil if searching of buffer names should ignore case." | 244 | "*Non-nil if searching of buffer names should ignore case. |
| 245 | If this is non-nil but the user input has any upper case letters, matching | ||
| 246 | is temporarily case sensitive." | ||
| 228 | :type 'boolean | 247 | :type 'boolean |
| 229 | :group 'iswitchb) | 248 | :group 'iswitchb) |
| 230 | 249 | ||
| @@ -741,7 +760,7 @@ current frame, rather than all frames, regardless of value of | |||
| 741 | "Return buffers matching REGEXP. | 760 | "Return buffers matching REGEXP. |
| 742 | If STRING-FORMAT is nil, consider REGEXP as just a string. | 761 | If STRING-FORMAT is nil, consider REGEXP as just a string. |
| 743 | BUFFER-LIST can be list of buffers or list of strings." | 762 | BUFFER-LIST can be list of buffers or list of strings." |
| 744 | (let* ((case-fold-search iswitchb-case) | 763 | (let* ((case-fold-search (iswitchb-case)) |
| 745 | ;; need reverse since we are building up list backwards | 764 | ;; need reverse since we are building up list backwards |
| 746 | (list (reverse buffer-list)) | 765 | (list (reverse buffer-list)) |
| 747 | (do-string (stringp (car list))) | 766 | (do-string (stringp (car list))) |
| @@ -793,7 +812,7 @@ BUFFER-LIST can be list of buffers or list of strings." | |||
| 793 | (defun iswitchb-word-matching-substring (word) | 812 | (defun iswitchb-word-matching-substring (word) |
| 794 | "Return part of WORD before 1st match to `iswitchb-change-word-sub'. | 813 | "Return part of WORD before 1st match to `iswitchb-change-word-sub'. |
| 795 | If `iswitchb-change-word-sub' cannot be found in WORD, return nil." | 814 | If `iswitchb-change-word-sub' cannot be found in WORD, return nil." |
| 796 | (let ((case-fold-search iswitchb-case)) | 815 | (let ((case-fold-search (iswitchb-case))) |
| 797 | (let ((m (string-match iswitchb-change-word-sub word))) | 816 | (let ((m (string-match iswitchb-change-word-sub word))) |
| 798 | (if m | 817 | (if m |
| 799 | (substring word m) | 818 | (substring word m) |
| @@ -814,7 +833,7 @@ If `iswitchb-change-word-sub' cannot be found in WORD, return nil." | |||
| 814 | (setq alist (mapcar 'iswitchb-makealist res)) ;; could use an OBARRAY | 833 | (setq alist (mapcar 'iswitchb-makealist res)) ;; could use an OBARRAY |
| 815 | 834 | ||
| 816 | ;; try-completion returns t if there is an exact match. | 835 | ;; try-completion returns t if there is an exact match. |
| 817 | (let ((completion-ignore-case iswitchb-case)) | 836 | (let ((completion-ignore-case (iswitchb-case))) |
| 818 | 837 | ||
| 819 | (try-completion subs alist)))) | 838 | (try-completion subs alist)))) |
| 820 | 839 | ||
| @@ -1256,6 +1275,14 @@ This is an example function which can be hooked on to | |||
| 1256 | iswitchb-temp-buflist)))) | 1275 | iswitchb-temp-buflist)))) |
| 1257 | (iswitchb-to-end summaries))) | 1276 | (iswitchb-to-end summaries))) |
| 1258 | 1277 | ||
| 1278 | (defun iswitchb-case () | ||
| 1279 | "Return non-nil iff we should ignore case when matching. | ||
| 1280 | See the variable `iswitchb-case' for details." | ||
| 1281 | (if iswitchb-case | ||
| 1282 | (if iswitchb-xemacs | ||
| 1283 | (isearch-no-upper-case-p iswitchb-text) | ||
| 1284 | (isearch-no-upper-case-p iswitchb-text t)))) | ||
| 1285 | |||
| 1259 | (provide 'iswitchb) | 1286 | (provide 'iswitchb) |
| 1260 | 1287 | ||
| 1261 | ;;; iswitchb.el ends here | 1288 | ;;; iswitchb.el ends here |