diff options
| author | Stefan Monnier | 2010-03-22 20:59:49 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-03-22 20:59:49 -0400 |
| commit | 002787475ff69f44a4fbd26bfe8b8dad3ea435ed (patch) | |
| tree | 10c4e85f881ac1178f784f5347bb4f9bd67c50f6 | |
| parent | df7734b220de9c61575677adbc1f431ef6703d84 (diff) | |
| download | emacs-002787475ff69f44a4fbd26bfe8b8dad3ea435ed.tar.gz emacs-002787475ff69f44a4fbd26bfe8b8dad3ea435ed.zip | |
Add a new completion style `substring'.
* minibuffer.el (completion-basic--pattern): New function.
(completion-basic-try-completion, completion-basic-all-completions): Use it.
(completion-substring--all-completions)
(completion-substring-try-completion)
(completion-substring-all-completions): New functions.
(completion-styles-alist): New style `substring'.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 54 |
3 files changed, 57 insertions, 10 deletions
| @@ -94,6 +94,8 @@ Secret Service API requires D-Bus for communication. | |||
| 94 | 94 | ||
| 95 | * Lisp changes in Emacs 24.1 | 95 | * Lisp changes in Emacs 24.1 |
| 96 | 96 | ||
| 97 | ** New completion style `substring'. | ||
| 98 | |||
| 97 | ** Image API | 99 | ** Image API |
| 98 | 100 | ||
| 99 | *** When the image type is one of listed in `image-animated-types' | 101 | *** When the image type is one of listed in `image-animated-types' |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index afce3835ed2..cf6b4d3496f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2010-03-23 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | Add a new completion style `substring'. | ||
| 4 | * minibuffer.el (completion-basic--pattern): New function. | ||
| 5 | (completion-basic-try-completion, completion-basic-all-completions): | ||
| 6 | Use it. | ||
| 7 | (completion-substring--all-completions) | ||
| 8 | (completion-substring-try-completion) | ||
| 9 | (completion-substring-all-completions): New functions. | ||
| 10 | (completion-styles-alist): New style `substring'. | ||
| 11 | |||
| 1 | 2010-03-22 Stefan Monnier <monnier@iro.umontreal.ca> | 12 | 2010-03-22 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 13 | ||
| 3 | Get rid of .elc files after removal of the corresponding .el. | 14 | Get rid of .elc files after removal of the corresponding .el. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 54d155cd510..94effe57994 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -393,6 +393,9 @@ the second failed attempt to complete." | |||
| 393 | "Completion of multiple words, each one taken as a prefix. | 393 | "Completion of multiple words, each one taken as a prefix. |
| 394 | E.g. M-x l-c-h can complete to list-command-history | 394 | E.g. M-x l-c-h can complete to list-command-history |
| 395 | and C-x C-f /u/m/s to /usr/monnier/src.") | 395 | and C-x C-f /u/m/s to /usr/monnier/src.") |
| 396 | (substring | ||
| 397 | completion-substring-try-completion completion-substring-all-completions | ||
| 398 | "Completion of the string taken as a substring.") | ||
| 396 | (initials | 399 | (initials |
| 397 | completion-initials-try-completion completion-initials-all-completions | 400 | completion-initials-try-completion completion-initials-all-completions |
| 398 | "Completion of acronyms and initialisms. | 401 | "Completion of acronyms and initialisms. |
| @@ -1658,6 +1661,12 @@ Return the new suffix." | |||
| 1658 | ;; Nothing to merge. | 1661 | ;; Nothing to merge. |
| 1659 | suffix)) | 1662 | suffix)) |
| 1660 | 1663 | ||
| 1664 | (defun completion-basic--pattern (beforepoint afterpoint bounds) | ||
| 1665 | (delete | ||
| 1666 | "" (list (substring beforepoint (car bounds)) | ||
| 1667 | 'point | ||
| 1668 | (substring afterpoint 0 (cdr bounds))))) | ||
| 1669 | |||
| 1661 | (defun completion-basic-try-completion (string table pred point) | 1670 | (defun completion-basic-try-completion (string table pred point) |
| 1662 | (let* ((beforepoint (substring string 0 point)) | 1671 | (let* ((beforepoint (substring string 0 point)) |
| 1663 | (afterpoint (substring string point)) | 1672 | (afterpoint (substring string point)) |
| @@ -1674,10 +1683,8 @@ Return the new suffix." | |||
| 1674 | (length completion)))) | 1683 | (length completion)))) |
| 1675 | (let* ((suffix (substring afterpoint (cdr bounds))) | 1684 | (let* ((suffix (substring afterpoint (cdr bounds))) |
| 1676 | (prefix (substring beforepoint 0 (car bounds))) | 1685 | (prefix (substring beforepoint 0 (car bounds))) |
| 1677 | (pattern (delete | 1686 | (pattern (completion-basic--pattern |
| 1678 | "" (list (substring beforepoint (car bounds)) | 1687 | beforepoint afterpoint bounds)) |
| 1679 | 'point | ||
| 1680 | (substring afterpoint 0 (cdr bounds))))) | ||
| 1681 | (all (completion-pcm--all-completions prefix pattern table pred))) | 1688 | (all (completion-pcm--all-completions prefix pattern table pred))) |
| 1682 | (if minibuffer-completing-file-name | 1689 | (if minibuffer-completing-file-name |
| 1683 | (setq all (completion-pcm--filename-try-filter all))) | 1690 | (setq all (completion-pcm--filename-try-filter all))) |
| @@ -1687,12 +1694,8 @@ Return the new suffix." | |||
| 1687 | (let* ((beforepoint (substring string 0 point)) | 1694 | (let* ((beforepoint (substring string 0 point)) |
| 1688 | (afterpoint (substring string point)) | 1695 | (afterpoint (substring string point)) |
| 1689 | (bounds (completion-boundaries beforepoint table pred afterpoint)) | 1696 | (bounds (completion-boundaries beforepoint table pred afterpoint)) |
| 1690 | (suffix (substring afterpoint (cdr bounds))) | ||
| 1691 | (prefix (substring beforepoint 0 (car bounds))) | 1697 | (prefix (substring beforepoint 0 (car bounds))) |
| 1692 | (pattern (delete | 1698 | (pattern (completion-basic--pattern beforepoint afterpoint bounds)) |
| 1693 | "" (list (substring beforepoint (car bounds)) | ||
| 1694 | 'point | ||
| 1695 | (substring afterpoint 0 (cdr bounds))))) | ||
| 1696 | (all (completion-pcm--all-completions prefix pattern table pred))) | 1699 | (all (completion-pcm--all-completions prefix pattern table pred))) |
| 1697 | (completion-hilit-commonality all point (car bounds)))) | 1700 | (completion-hilit-commonality all point (car bounds)))) |
| 1698 | 1701 | ||
| @@ -2069,7 +2072,38 @@ filter out additional entries (because TABLE migth not obey PRED)." | |||
| 2069 | 'completion-pcm--filename-try-filter)) | 2072 | 'completion-pcm--filename-try-filter)) |
| 2070 | (completion-pcm--merge-try pattern all prefix suffix))) | 2073 | (completion-pcm--merge-try pattern all prefix suffix))) |
| 2071 | 2074 | ||
| 2072 | ;;; Initials completion | 2075 | ;;; Substring completion |
| 2076 | ;; Mostly derived from the code of `basic' completion. | ||
| 2077 | |||
| 2078 | (defun completion-substring--all-completions (string table pred point) | ||
| 2079 | (let* ((beforepoint (substring string 0 point)) | ||
| 2080 | (afterpoint (substring string point)) | ||
| 2081 | (bounds (completion-boundaries beforepoint table pred afterpoint)) | ||
| 2082 | (suffix (substring afterpoint (cdr bounds))) | ||
| 2083 | (prefix (substring beforepoint 0 (car bounds))) | ||
| 2084 | (basic-pattern (completion-basic--pattern | ||
| 2085 | beforepoint afterpoint bounds)) | ||
| 2086 | (pattern (if (not (stringp (car basic-pattern))) | ||
| 2087 | basic-pattern | ||
| 2088 | (cons 'any basic-pattern))) | ||
| 2089 | (all (completion-pcm--all-completions prefix pattern table pred))) | ||
| 2090 | (list all pattern prefix suffix (car bounds)))) | ||
| 2091 | |||
| 2092 | (defun completion-substring-try-completion (string table pred point) | ||
| 2093 | (destructuring-bind (all pattern prefix suffix carbounds) | ||
| 2094 | (completion-substring--all-completions string table pred point) | ||
| 2095 | (if minibuffer-completing-file-name | ||
| 2096 | (setq all (completion-pcm--filename-try-filter all))) | ||
| 2097 | (completion-pcm--merge-try pattern all prefix suffix))) | ||
| 2098 | |||
| 2099 | (defun completion-substring-all-completions (string table pred point) | ||
| 2100 | (destructuring-bind (all pattern prefix suffix carbounds) | ||
| 2101 | (completion-substring--all-completions string table pred point) | ||
| 2102 | (when all | ||
| 2103 | (nconc (completion-pcm--hilit-commonality pattern all) | ||
| 2104 | (length prefix))))) | ||
| 2105 | |||
| 2106 | ;; Initials completion | ||
| 2073 | ;; Complete /ums to /usr/monnier/src or lch to list-command-history. | 2107 | ;; Complete /ums to /usr/monnier/src or lch to list-command-history. |
| 2074 | 2108 | ||
| 2075 | (defun completion-initials-expand (str table pred) | 2109 | (defun completion-initials-expand (str table pred) |