aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-05-05 22:59:07 -0400
committerStefan Monnier2010-05-05 22:59:07 -0400
commit1493963bb19856c8fffedc1e3091bf1fa61bdf64 (patch)
tree02f2dcce0cf6c2e728e8fff2f602b76731c9796c
parent0c495c215a149245fd00cf26f375b8cfa3977ef6 (diff)
downloademacs-1493963bb19856c8fffedc1e3091bf1fa61bdf64.tar.gz
emacs-1493963bb19856c8fffedc1e3091bf1fa61bdf64.zip
Extract common suffix for * in partial-completion.
* minibuffer.el (completion--sreverse, completion--common-suffix): New functions. (completion-pcm--merge-completions): Extract common suffix when safe.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/minibuffer.el23
2 files changed, 26 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 88c41ea84c2..97a0f8c5b41 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12010-05-06 Stefan Monnier <monnier@iro.umontreal.ca> 12010-05-06 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * minibuffer.el (completion--sreverse, completion--common-suffix):
4 New functions.
5 (completion-pcm--merge-completions): Extract common suffix when safe.
6
3 * emacs-lisp/easy-mmode.el (define-minor-mode): 7 * emacs-lisp/easy-mmode.el (define-minor-mode):
4 Make :variable more flexible. 8 Make :variable more flexible.
5 * files.el (auto-save-mode): Use it to define using define-minor-mode. 9 * files.el (auto-save-mode): Use it to define using define-minor-mode.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index d8f1f0a8e9d..31bdb6993fa 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1983,6 +1983,17 @@ filter out additional entries (because TABLE migth not obey PRED)."
1983 (nconc (completion-pcm--hilit-commonality pattern all) 1983 (nconc (completion-pcm--hilit-commonality pattern all)
1984 (length prefix))))) 1984 (length prefix)))))
1985 1985
1986(defun completion--sreverse (str)
1987 "Like `reverse' but for a string STR rather than a list."
1988 (apply 'string (nreverse (mapcar 'identity str))))
1989
1990(defun completion--common-suffix (strs)
1991 "Return the common suffix of the strings STRS."
1992 (completion--sreverse
1993 (try-completion
1994 ""
1995 (mapcar 'completion--sreverse comps))))
1996
1986(defun completion-pcm--merge-completions (strs pattern) 1997(defun completion-pcm--merge-completions (strs pattern)
1987 "Extract the commonality in STRS, with the help of PATTERN." 1998 "Extract the commonality in STRS, with the help of PATTERN."
1988 ;; When completing while ignoring case, we want to try and avoid 1999 ;; When completing while ignoring case, we want to try and avoid
@@ -2044,7 +2055,17 @@ filter out additional entries (because TABLE migth not obey PRED)."
2044 ;; `any' into a `star' because the surrounding context has 2055 ;; `any' into a `star' because the surrounding context has
2045 ;; changed such that string->pattern wouldn't add an `any' 2056 ;; changed such that string->pattern wouldn't add an `any'
2046 ;; here any more. 2057 ;; here any more.
2047 (unless unique (push elem res)) 2058 (unless unique
2059 (push elem res)
2060 (when (memq elem '(star point))
2061 ;; Extract common suffix additionally to common prefix.
2062 ;; Only do it for `point' and `star' since for
2063 ;; `any' it could lead to a merged completion that
2064 ;; doesn't itself match the candidates.
2065 (let ((suffix (completion--common-suffix comps)))
2066 (assert (stringp suffix))
2067 (unless (equal suffix "")
2068 (push suffix res)))))
2048 (setq fixed ""))))) 2069 (setq fixed "")))))
2049 ;; We return it in reverse order. 2070 ;; We return it in reverse order.
2050 res))))) 2071 res)))))