aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-05-09 18:39:36 -0400
committerStefan Monnier2010-05-09 18:39:36 -0400
commit79ccd68f683c1e46bc5dcc12f5b232a75a42ea88 (patch)
treed79e6b09f6e2da53e5cd1be55321077916fdd225
parent0d5852cfaa28f0805b23395a3fdd8eb16363474e (diff)
downloademacs-79ccd68f683c1e46bc5dcc12f5b232a75a42ea88.tar.gz
emacs-79ccd68f683c1e46bc5dcc12f5b232a75a42ea88.zip
* minibuffer.el (completion-pcm-complete-word-inserts-delimiters):
New custom variable. (completion-pcm--string->pattern): Use it. (completion-pcm--pattern->regex, completion-pcm--pattern->string): Make it handle any symbol as `any'. (completion-pcm--merge-completions): Extract common suffix for the new `prefix' symbol as well. (completion-substring--all-completions): Use the new `prefix' symbol.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/minibuffer.el40
3 files changed, 38 insertions, 18 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 578aac46e05..0b522c5fd62 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -123,8 +123,9 @@ regardless of the value of `delete-by-moving-to-trash'.
123The reason is that this interferes with cua-mode. 123The reason is that this interferes with cua-mode.
124 124
125** partial-completion-mode is now obsolete. 125** partial-completion-mode is now obsolete.
126You can get the same behavior with 126You can get a comparable behavior with:
127(setq completion-styles '(partial-completion initials)). 127(setq completion-styles '(partial-completion initials))
128(setq completion-pcm-complete-word-inserts-delimiters t)
128 129
129** mpc.el: Can use pseudo tags of the form tag1|tag2 as a union of two tags. 130** mpc.el: Can use pseudo tags of the form tag1|tag2 as a union of two tags.
130** Customize 131** Customize
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5e2f5baaeb3..c5a8e8fe3b9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12010-05-09 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * minibuffer.el (completion-pcm-complete-word-inserts-delimiters):
4 New custom variable.
5 (completion-pcm--string->pattern): Use it.
6 (completion-pcm--pattern->regex, completion-pcm--pattern->string):
7 Make it handle any symbol as `any'.
8 (completion-pcm--merge-completions): Extract common suffix for the new
9 `prefix' symbol as well.
10 (completion-substring--all-completions): Use the new `prefix' symbol.
11
12010-05-09 Michael Albinus <michael.albinus@gmx.de> 122010-05-09 Michael Albinus <michael.albinus@gmx.de>
2 13
3 * net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if 14 * net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 3ff89ad206b..869ce937b66 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1769,6 +1769,14 @@ expression (not containing character ranges like `a-z')."
1769 :group 'minibuffer 1769 :group 'minibuffer
1770 :type 'string) 1770 :type 'string)
1771 1771
1772(defcustom completion-pcm-complete-word-inserts-delimiters nil
1773 "Treat the SPC or - inserted by `minibuffer-complete-word' as delimiters.
1774Those chars are treated as delimiters iff this variable is non-nil.
1775I.e. if non-nil, M-x SPC will just insert a \"-\" in the minibuffer, whereas
1776if nil, it will list all possible commands in *Completions* because none of
1777the commands start with a \"-\" or a SPC."
1778 :type 'boolean)
1779
1772(defun completion-pcm--pattern-trivial-p (pattern) 1780(defun completion-pcm--pattern-trivial-p (pattern)
1773 (and (stringp (car pattern)) 1781 (and (stringp (car pattern))
1774 ;; It can be followed by `point' and "" and still be trivial. 1782 ;; It can be followed by `point' and "" and still be trivial.
@@ -1781,7 +1789,7 @@ expression (not containing character ranges like `a-z')."
1781(defun completion-pcm--string->pattern (string &optional point) 1789(defun completion-pcm--string->pattern (string &optional point)
1782 "Split STRING into a pattern. 1790 "Split STRING into a pattern.
1783A pattern is a list where each element is either a string 1791A pattern is a list where each element is either a string
1784or a symbol chosen among `any', `star', `point'." 1792or a symbol chosen among `any', `star', `point', `prefix'."
1785 (if (and point (< point (length string))) 1793 (if (and point (< point (length string)))
1786 (let ((prefix (substring string 0 point)) 1794 (let ((prefix (substring string 0 point))
1787 (suffix (substring string point))) 1795 (suffix (substring string point)))
@@ -1794,11 +1802,12 @@ or a symbol chosen among `any', `star', `point'."
1794 1802
1795 (while (and (setq p (string-match completion-pcm--delim-wild-regex 1803 (while (and (setq p (string-match completion-pcm--delim-wild-regex
1796 string p)) 1804 string p))
1797 ;; If the char was added by minibuffer-complete-word, then 1805 (or completion-pcm-complete-word-inserts-delimiters
1798 ;; don't treat it as a delimiter, otherwise "M-x SPC" 1806 ;; If the char was added by minibuffer-complete-word,
1799 ;; ends up inserting a "-" rather than listing 1807 ;; then don't treat it as a delimiter, otherwise
1800 ;; all completions. 1808 ;; "M-x SPC" ends up inserting a "-" rather than listing
1801 (not (get-text-property p 'completion-try-word string))) 1809 ;; all completions.
1810 (not (get-text-property p 'completion-try-word string))))
1802 ;; Usually, completion-pcm--delim-wild-regex matches a delimiter, 1811 ;; Usually, completion-pcm--delim-wild-regex matches a delimiter,
1803 ;; meaning that something can be added *before* it, but it can also 1812 ;; meaning that something can be added *before* it, but it can also
1804 ;; match a prefix and postfix, in which case something can be added 1813 ;; match a prefix and postfix, in which case something can be added
@@ -1824,11 +1833,10 @@ or a symbol chosen among `any', `star', `point'."
1824 (concat "\\`" 1833 (concat "\\`"
1825 (mapconcat 1834 (mapconcat
1826 (lambda (x) 1835 (lambda (x)
1827 (case x 1836 (cond
1828 ((star any point) 1837 ((stringp x) (regexp-quote x))
1829 (if (if (consp group) (memq x group) group) 1838 ((if (consp group) (memq x group) group)
1830 "\\(.*?\\)" ".*?")) 1839 "\\(.*?\\)" ".*?")))
1831 (t (regexp-quote x))))
1832 pattern 1840 pattern
1833 "")))) 1841 ""))))
1834 ;; Avoid pathological backtracking. 1842 ;; Avoid pathological backtracking.
@@ -2057,9 +2065,9 @@ filter out additional entries (because TABLE migth not obey PRED)."
2057 ;; here any more. 2065 ;; here any more.
2058 (unless unique 2066 (unless unique
2059 (push elem res) 2067 (push elem res)
2060 (when (memq elem '(star point)) 2068 (when (memq elem '(star point prefix))
2061 ;; Extract common suffix additionally to common prefix. 2069 ;; Extract common suffix additionally to common prefix.
2062 ;; Only do it for `point' and `star' since for 2070 ;; Only do it for `point', `star', and `prefix' since for
2063 ;; `any' it could lead to a merged completion that 2071 ;; `any' it could lead to a merged completion that
2064 ;; doesn't itself match the candidates. 2072 ;; doesn't itself match the candidates.
2065 (let ((suffix (completion--common-suffix comps))) 2073 (let ((suffix (completion--common-suffix comps)))
@@ -2074,8 +2082,7 @@ filter out additional entries (because TABLE migth not obey PRED)."
2074 (mapconcat (lambda (x) (cond 2082 (mapconcat (lambda (x) (cond
2075 ((stringp x) x) 2083 ((stringp x) x)
2076 ((eq x 'star) "*") 2084 ((eq x 'star) "*")
2077 ((eq x 'any) "") 2085 (t ""))) ;any, point, prefix.
2078 ((eq x 'point) "")))
2079 pattern 2086 pattern
2080 "")) 2087 ""))
2081 2088
@@ -2117,6 +2124,7 @@ filter out additional entries (because TABLE migth not obey PRED)."
2117 (pointpat (or (memq 'point mergedpat) 2124 (pointpat (or (memq 'point mergedpat)
2118 (memq 'any mergedpat) 2125 (memq 'any mergedpat)
2119 (memq 'star mergedpat) 2126 (memq 'star mergedpat)
2127 ;; Not `prefix'.
2120 mergedpat)) 2128 mergedpat))
2121 ;; New pos from the start. 2129 ;; New pos from the start.
2122 (newpos (length (completion-pcm--pattern->string pointpat))) 2130 (newpos (length (completion-pcm--pattern->string pointpat)))
@@ -2147,7 +2155,7 @@ filter out additional entries (because TABLE migth not obey PRED)."
2147 beforepoint afterpoint bounds)) 2155 beforepoint afterpoint bounds))
2148 (pattern (if (not (stringp (car basic-pattern))) 2156 (pattern (if (not (stringp (car basic-pattern)))
2149 basic-pattern 2157 basic-pattern
2150 (cons 'any basic-pattern))) 2158 (cons 'prefix basic-pattern)))
2151 (all (completion-pcm--all-completions prefix pattern table pred))) 2159 (all (completion-pcm--all-completions prefix pattern table pred)))
2152 (list all pattern prefix suffix (car bounds)))) 2160 (list all pattern prefix suffix (car bounds))))
2153 2161