annotate lisp/emacs-lisp/crm.el @ 107505:cea18e9685bf

from trunk
author Kenichi Handa <handa@m17n.org>
date Tue, 16 Mar 2010 10:04:20 +0900
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; crm.el --- read multiple strings with completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64751
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105601
diff changeset
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Sen Nagata <sen@eccosys.com>
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Keywords: completion, minibuffer, multiple elements
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94131
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94131
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94131
diff changeset
14 ;; (at your option) any later version.
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94131
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; This code defines a function, `completing-read-multiple', which
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;; provides the ability to read multiple strings in the minibuffer,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; with completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; By using this functionality, a user may specify multiple strings at
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; a single prompt, optionally using completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; Multiple strings are specified by separating each of the strings
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; with a prespecified separator character. For example, if the
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; separator character is a comma, the strings 'alice', 'bob', and
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; 'eve' would be specified as 'alice,bob,eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; The default value for the separator character is the value of
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; `crm-default-separator' (comma). The separator character may be
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; changed by modifying the value of `crm-separator'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
42 ;; Contiguous strings of non-separator-characters are referred to as
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; 'elements'. In the aforementioned example, the elements are:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; 'alice', 'bob', and 'eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; Completion is available on a per-element basis. For example, if
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; the contents of the minibuffer are 'alice,bob,eve' and point is
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; between 'l' and 'i', pressing TAB operates on the element 'alice'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; For the moment, I have decided to not bind any special behavior to
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; the separator key. In the future, the separator key might be used
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; to provide completion in certain circumstances. One of the reasons
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; why this functionality is not yet provided is that it is unclear to
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; the author what the precise circumstances are, under which
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; separator-invoked completion should be provided.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; Design note: `completing-read-multiple' is modeled after
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; `completing-read'. They should be similar -- it was intentional.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; Some of this code started out as translation from C code in
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
61 ;; src/minibuf.c to Emacs Lisp code. After this code was rewritten in Elisp
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
62 ;; and made to operate on any field, this file was completely rewritten to
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
63 ;; just reuse that code.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
64
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
65 ;; Thanks to Sen Nagata <sen@eccosys.com> for the original version of the
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
66 ;; code, and sorry for throwing it all out. --Stef
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; Thanks to Richard Stallman for all of his help (many of the good
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; ideas in here are from him), Gerd Moellmann for his attention,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; Stefan Monnier for responding with a code sample and comments very
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;; early on, and Kai Grossjohann & Soren Dayton for valuable feedback.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;;; Questions and Thoughts:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;; -should `completing-read-multiple' allow a trailing separator in
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; a return value when REQUIRE-MATCH is t? if not, should beep when a user
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; tries to exit the minibuffer via RET?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
79 ;; -tip: use M-f and M-b for ease of navigation among elements.
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
81 ;; - the difference between minibuffer-completion-table and
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
82 ;; crm-completion-table is just crm--collection-fn. In most cases it
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
83 ;; shouldn't make any difference. But if a non-CRM completion function
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
84 ;; happens to be used, it will use minibuffer-completion-table and
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
85 ;; crm--collection-fn will try to make it do "more or less the right
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
86 ;; thing" by making it complete on the last element, which is about as
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
87 ;; good as we can hope for right now.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
88 ;; I'm not sure if it's important or not. Maybe we could just throw away
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
89 ;; crm-completion-table and crm--collection-fn, but there doesn't seem to
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
90 ;; be a pressing need for it, and since Sen did bother to write it, we may
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
91 ;; as well keep it, in case it helps.
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;;; History:
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
94 ;;
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;; 2000-04-10:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 ;;
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 ;; first revamped version
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;;; Code:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (defconst crm-default-separator ","
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 "Default separator for `completing-read-multiple'.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (defvar crm-separator crm-default-separator
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 "Separator used for separating strings in `completing-read-multiple'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 It should be a single character string that doesn't appear in the list of
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 completion candidates. Modify this value to make `completing-read-multiple'
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 use a separator other than `crm-default-separator'.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
109 (defvar crm-local-completion-map
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
110 (let ((map (make-sparse-keymap)))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
111 (set-keymap-parent map minibuffer-local-completion-map)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
112 (define-key map [remap minibuffer-complete] #'crm-complete)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
113 (define-key map [remap minibuffer-complete-word] #'crm-complete-word)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
114 (define-key map [remap minibuffer-completion-help] #'crm-completion-help)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
115 map)
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 "Local keymap for minibuffer multiple input with completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 Analog of `minibuffer-local-completion-map'.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
119 (defvar crm-local-must-match-map
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
120 (let ((map (make-sparse-keymap)))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
121 ;; We'd want to have multiple inheritance here.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
122 (set-keymap-parent map minibuffer-local-must-match-map)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
123 (define-key map [remap minibuffer-complete] #'crm-complete)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
124 (define-key map [remap minibuffer-complete-word] #'crm-complete-word)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
125 (define-key map [remap minibuffer-completion-help] #'crm-completion-help)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
126 (define-key map [remap minibuffer-complete-and-exit]
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
127 #'crm-complete-and-exit)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
128 map)
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 "Local keymap for minibuffer multiple input with exact match completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 Analog of `minibuffer-local-must-match-map' for crm.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131
28741
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
132 (defvar crm-completion-table nil
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
133 "An alist whose elements' cars are strings, or an obarray.
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
134 This is a table used for completion by `completing-read-multiple' and its
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
135 supporting functions.")
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
136
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ;; this function evolved from a posting by Stefan Monnier
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
138 (defun crm--collection-fn (string predicate flag)
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 "Function used by `completing-read-multiple' to compute completion values.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 The value of STRING is the string to be completed.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 The value of PREDICATE is a function to filter possible matches, or
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 nil if none.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 The value of FLAG is used to specify the type of completion operation.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 A value of nil specifies `try-completion'. A value of t specifies
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 `all-completions'. A value of lambda specifes a test for an exact match.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 For more information on STRING, PREDICATE, and FLAG, see the Elisp
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 Reference sections on 'Programmed Completion' and 'Basic Completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 Functions'."
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
152 (let ((beg 0))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
153 (while (string-match crm-separator string beg)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
154 (setq beg (match-end 0)))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
155 (completion-table-with-context (substring string 0 beg)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
156 crm-completion-table
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
157 (substring string beg)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
158 predicate
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
159 flag)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
161 (defun crm--select-current-element ()
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
162 "Parse the minibuffer to find the current element.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
163 Place an overlay on the element, with a `field' property, and return it."
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
164 (let* ((bob (minibuffer-prompt-end))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
165 (start (save-excursion
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
166 (if (re-search-backward crm-separator bob t)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
167 (match-end 0)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
168 bob)))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
169 (end (save-excursion
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
170 (if (re-search-forward crm-separator nil t)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
171 (match-beginning 0)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
172 (point-max))))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
173 (ol (make-overlay start end nil nil t)))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
174 (overlay-put ol 'field (make-symbol "crm"))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
175 ol))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
177 (defun crm-completion-help ()
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 "Display a list of possible completions of the current minibuffer element."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (interactive)
94131
c39283931fa5 (crm-completion-help, crm-complete, crm-complete-word, crm-complete-and-exit):
Juanma Barranquero <lekktu@gmail.com>
parents: 94090
diff changeset
180 (let ((ol (crm--select-current-element)))
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
181 (unwind-protect
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
182 (minibuffer-completion-help)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
183 (delete-overlay ol)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
186 (defun crm-complete ()
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 "Complete the current element.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 If no characters can be completed, display a list of possible completions.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 Return t if the current element is now a valid match; otherwise return nil."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (interactive)
94131
c39283931fa5 (crm-completion-help, crm-complete, crm-complete-word, crm-complete-and-exit):
Juanma Barranquero <lekktu@gmail.com>
parents: 94090
diff changeset
192 (let ((ol (crm--select-current-element)))
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
193 (unwind-protect
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
194 (minibuffer-complete)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
195 (delete-overlay ol))))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
197 (defun crm-complete-word ()
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
198 "Complete the current element at most a single word.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
199 Like `minibuffer-complete-word' but for `completing-read-multiple'."
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
200 (interactive)
94131
c39283931fa5 (crm-completion-help, crm-complete, crm-complete-word, crm-complete-and-exit):
Juanma Barranquero <lekktu@gmail.com>
parents: 94090
diff changeset
201 (let ((ol (crm--select-current-element)))
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
202 (unwind-protect
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
203 (minibuffer-complete-word)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
204 (delete-overlay ol))))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
206 (defun crm-complete-and-exit ()
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 "If all of the minibuffer elements are valid completions then exit.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 All elements in the minibuffer must match. If there is a mismatch, move point
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 to the location of mismatch and do not exit.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
211 This function is modeled after `minibuffer-complete-and-exit'."
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (interactive)
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
213 (let ((doexit t))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
214 (goto-char (minibuffer-prompt-end))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
215 (while
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
216 (and doexit
94131
c39283931fa5 (crm-completion-help, crm-complete, crm-complete-word, crm-complete-and-exit):
Juanma Barranquero <lekktu@gmail.com>
parents: 94090
diff changeset
217 (let ((ol (crm--select-current-element)))
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
218 (goto-char (overlay-end ol))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
219 (unwind-protect
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
220 (catch 'exit
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
221 (minibuffer-complete-and-exit)
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
222 ;; This did not throw `exit', so there was a problem.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
223 (setq doexit nil))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
224 (goto-char (overlay-end ol))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
225 (delete-overlay ol))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
226 (not (eobp))))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
227 ;; Skip to the next element.
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
228 (forward-char 1))
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
229 (if doexit (exit-minibuffer))))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230
105601
68686d39c93a Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 102596
diff changeset
231 (defun crm--choose-completion-string (choice buffer base-position
68686d39c93a Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 102596
diff changeset
232 &rest ignored)
102596
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
233 "Completion string chooser for `completing-read-multiple'.
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
234 This is called from `choose-completion-string-functions'.
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
235 It replaces the string that is currently being completed, without
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
236 exiting the minibuffer."
105601
68686d39c93a Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 102596
diff changeset
237 (let ((completion-no-auto-exit t)
68686d39c93a Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 102596
diff changeset
238 (choose-completion-string-functions nil))
68686d39c93a Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 102596
diff changeset
239 (choose-completion-string choice buffer base-position)
68686d39c93a Replace completion-base-size by completion-base-position to fix bugs
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 102596
diff changeset
240 t))
102596
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
241
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 ;; superemulates behavior of completing_read in src/minibuf.c
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 ;;;###autoload
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (defun completing-read-multiple
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (prompt table &optional predicate require-match initial-input
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 hist def inherit-input-method)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 "Read multiple strings in the minibuffer, with completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 By using this functionality, a user may specify multiple strings at a
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 single prompt, optionally using completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 Multiple strings are specified by separating each of the strings with
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 a prespecified separator character. For example, if the separator
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 character is a comma, the strings 'alice', 'bob', and 'eve' would be
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 specified as 'alice,bob,eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 The default value for the separator character is the value of
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 `crm-default-separator' (comma). The separator character may be
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 changed by modifying the value of `crm-separator'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
260 Contiguous strings of non-separator-characters are referred to as
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 'elements'. In the aforementioned example, the elements are: 'alice',
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 'bob', and 'eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 Completion is available on a per-element basis. For example, if the
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 contents of the minibuffer are 'alice,bob,eve' and point is between
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 'l' and 'i', pressing TAB operates on the element 'alice'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 The return value of this function is a list of the read strings.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 See the documentation for `completing-read' for details on the arguments:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF, and
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 INHERIT-INPUT-METHOD."
102596
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
273 (unwind-protect
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
274 (progn
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
275 (add-hook 'choose-completion-string-functions
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
276 'crm--choose-completion-string)
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
277 (let* ((minibuffer-completion-table #'crm--collection-fn)
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
278 (minibuffer-completion-predicate predicate)
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
279 ;; see completing_read in src/minibuf.c
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
280 (minibuffer-completion-confirm
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
281 (unless (eq require-match t) require-match))
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
282 (crm-completion-table table)
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
283 (map (if require-match
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
284 crm-local-must-match-map
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
285 crm-local-completion-map))
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
286 ;; If the user enters empty input, read-from-minibuffer returns
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
287 ;; the empty string, not DEF.
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
288 (input (read-from-minibuffer
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
289 prompt initial-input map
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
290 nil hist def inherit-input-method)))
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
291 (and def (string-equal input "") (setq input def))
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
292 (split-string input crm-separator)))
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
293 (remove-hook 'choose-completion-string-functions
580bf204da67 (crm--choose-completion-string): New function.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
294 'crm--choose-completion-string)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295
94090
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
296 (define-obsolete-function-alias 'crm-minibuffer-complete 'crm-complete "23.1")
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
297 (define-obsolete-function-alias
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
298 'crm-minibuffer-completion-help 'crm-completion-help "23.1")
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
299 (define-obsolete-function-alias
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
300 'crm-minibuffer-complete-and-exit 'crm-complete-and-exit "23.1")
6027fc6333c9 Complete rewrite.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93975
diff changeset
301
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 ;; testing and debugging
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
303 ;; (defun crm-init-test-environ ()
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
304 ;; "Set up some variables for testing."
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
305 ;; (interactive)
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
306 ;; (setq my-prompt "Prompt: ")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
307 ;; (setq my-table
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
308 ;; '(("hi") ("there") ("man") ("may") ("mouth") ("ma")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
309 ;; ("a") ("ab") ("abc") ("abd") ("abf") ("zab") ("acb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
310 ;; ("da") ("dab") ("dabc") ("dabd") ("dabf") ("dzab") ("dacb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
311 ;; ("fda") ("fdab") ("fdabc") ("fdabd") ("fdabf") ("fdzab") ("fdacb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
312 ;; ("gda") ("gdab") ("gdabc") ("gdabd") ("gdabf") ("gdzab") ("gdacb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
313 ;; ))
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
314 ;; (setq my-separator ","))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 ;(completing-read-multiple my-prompt my-table)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 ;(completing-read-multiple my-prompt my-table nil t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 ;(completing-read-multiple my-prompt my-table nil "match")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 ;(completing-read my-prompt my-table nil t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 ;(completing-read my-prompt my-table nil "match")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (provide 'crm)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79704
diff changeset
324 ;; arch-tag: db1911d9-86c6-4a42-b32a-4910701b15a6
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 ;;; crm.el ends here