diff options
| author | Stefan Monnier | 2009-10-22 16:14:49 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-10-22 16:14:49 +0000 |
| commit | a452eee82d9dfff06caa64cec4480362c2b0ad03 (patch) | |
| tree | 4aaf9a3887e1932c99e9765b459d7ee067c9f02f | |
| parent | ab14d7d521ee2190d6a15be4df0c66d048b18ecd (diff) | |
| download | emacs-a452eee82d9dfff06caa64cec4480362c2b0ad03.tar.gz emacs-a452eee82d9dfff06caa64cec4480362c2b0ad03.zip | |
(completion-table-with-terminator): Allow to specify the terminator-regexp.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ba788adc109..5e77cb43175 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2009-10-22 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2009-10-22 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * minibuffer.el (completion-table-with-terminator): Allow to specify | ||
| 4 | the terminator-regexp. | ||
| 5 | |||
| 3 | * simple.el (switch-to-completions): Look for *Completions* in other | 6 | * simple.el (switch-to-completions): Look for *Completions* in other |
| 4 | frames as well. | 7 | frames as well. |
| 5 | 8 | ||
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 2024a5bd7d1..cd606eb33b4 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -200,16 +200,24 @@ This is meant to be called in a curried way by first passing TERMINATOR | |||
| 200 | and TABLE only (via `apply-partially'). | 200 | and TABLE only (via `apply-partially'). |
| 201 | TABLE is a completion table, and TERMINATOR is a string appended to TABLE's | 201 | TABLE is a completion table, and TERMINATOR is a string appended to TABLE's |
| 202 | completion if it is complete. TERMINATOR is also used to determine the | 202 | completion if it is complete. TERMINATOR is also used to determine the |
| 203 | completion suffix's boundary." | 203 | completion suffix's boundary. |
| 204 | TERMINATOR can also be a cons cell (TERMINATOR . TERMINATOR-REGEXP) | ||
| 205 | in which case TERMINATOR-REGEXP is a regular expression whose submatch | ||
| 206 | number 1 should match TERMINATOR. This is used when there is a need to | ||
| 207 | distinguish occurrences of the TERMINATOR strings which are really terminators | ||
| 208 | from others (e.g. escaped)." | ||
| 204 | (cond | 209 | (cond |
| 205 | ((eq (car-safe action) 'boundaries) | 210 | ((eq (car-safe action) 'boundaries) |
| 206 | (let* ((suffix (cdr action)) | 211 | (let* ((suffix (cdr action)) |
| 207 | (bounds (completion-boundaries string table pred suffix)) | 212 | (bounds (completion-boundaries string table pred suffix)) |
| 208 | (max (string-match (regexp-quote terminator) suffix))) | 213 | (terminator-regexp (if (consp terminator) |
| 214 | (cdr terminator) (regexp-quote terminator))) | ||
| 215 | (max (string-match terminator-regexp suffix))) | ||
| 209 | (list* 'boundaries (car bounds) | 216 | (list* 'boundaries (car bounds) |
| 210 | (min (cdr bounds) (or max (length suffix)))))) | 217 | (min (cdr bounds) (or max (length suffix)))))) |
| 211 | ((eq action nil) | 218 | ((eq action nil) |
| 212 | (let ((comp (try-completion string table pred))) | 219 | (let ((comp (try-completion string table pred))) |
| 220 | (if (consp terminator) (setq terminator (car terminator))) | ||
| 213 | (if (eq comp t) | 221 | (if (eq comp t) |
| 214 | (concat string terminator) | 222 | (concat string terminator) |
| 215 | (if (and (stringp comp) | 223 | (if (and (stringp comp) |