annotate lisp/emacs-lisp/crm.el @ 82361:be079227e4e1

(cvs-parse-table): Handle additional instance of optional quotes around files in NEED-UPDATE . REMOVED case.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 13 Aug 2007 10:41:40 +0000
parents 935157c0b596
children 78ee6fae0e41 f55f9811f5d7
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,
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74466
diff changeset
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 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
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
78217
935157c0b596 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; any later version.
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
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63985
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63985
diff changeset
24 ;; Boston, MA 02110-1301, USA.
28710
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 ;;; Commentary:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; This code defines a function, `completing-read-multiple', which
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; provides the ability to read multiple strings in the minibuffer,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; with completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; By using this functionality, a user may specify multiple strings at
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; a single prompt, optionally using completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; Multiple strings are specified by separating each of the strings
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; with a prespecified separator character. For example, if the
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; separator character is a comma, the strings 'alice', 'bob', and
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; 'eve' would be specified as 'alice,bob,eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; The default value for the separator character is the value of
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; `crm-default-separator' (comma). The separator character may be
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; changed by modifying the value of `crm-separator'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
44 ;; Contiguous strings of non-separator-characters are referred to as
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; 'elements'. In the aforementioned example, the elements are:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; 'alice', 'bob', and 'eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; Completion is available on a per-element basis. For example, if
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;; the contents of the minibuffer are 'alice,bob,eve' and point is
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; between 'l' and 'i', pressing TAB operates on the element 'alice'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; 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
53 ;; the separator key. In the future, the separator key might be used
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; to provide completion in certain circumstances. One of the reasons
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; 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
56 ;; the author what the precise circumstances are, under which
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; separator-invoked completion should be provided.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; Design note: `completing-read-multiple' is modeled after
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; `completing-read'. They should be similar -- it was intentional.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;; Some of this code started out as translation from C code in
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;; src/minibuf.c to Emacs Lisp code.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; 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
66 ;; ideas in here are from him), Gerd Moellmann for his attention,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; Stefan Monnier for responding with a code sample and comments very
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; early on, and Kai Grossjohann & Soren Dayton for valuable feedback.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;;; Questions and Thoughts:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;; -the author has gone through a number of test-and-fix cycles w/
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; this code, so it should be usable. please let me know if you find
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; any problems.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; -should `completing-read-multiple' allow a trailing separator in
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; 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
78 ;; tries to exit the minibuffer via RET?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; -TODO: possibly make return values from `crm-do-completion' into constants
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; -TODO: find out whether there is an appropriate way to distinguish between
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; functions intended for internal use and those that aren't.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; -tip: use M-f and M-b for ease of navigation among elements.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;;; History:
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
88 ;;
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; 2000-04-10:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;;
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 ;; first revamped version
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 ;;; Code:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 (defconst crm-default-separator ","
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 "Default separator for `completing-read-multiple'.")
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 (defvar crm-separator crm-default-separator
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 "Separator used for separating strings in `completing-read-multiple'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 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
100 completion candidates. Modify this value to make `completing-read-multiple'
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 use a separator other than `crm-default-separator'.")
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 ;; actual filling in of these maps occurs below via `crm-init-keymaps'
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (defvar crm-local-completion-map nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 "Local keymap for minibuffer multiple input with completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 Analog of `minibuffer-local-completion-map'.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (defvar crm-local-must-match-map nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 "Local keymap for minibuffer multiple input with exact match completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 Analog of `minibuffer-local-must-match-map' for crm.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
28741
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
112 (defvar crm-completion-table nil
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
113 "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
114 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
115 supporting functions.")
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
116
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 ;; this is supposed to be analogous to last_exact_completion in src/minibuf.c
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (defvar crm-last-exact-completion nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 "Completion string if last attempt reported \"Complete, but not unique\".")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (defvar crm-left-of-element nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 "String to the left of the current element.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (defvar crm-current-element nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 "The current element.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (defvar crm-right-of-element nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 "String to the right of the current element.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (defvar crm-beginning-of-element nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 "Buffer position representing the beginning of the current element.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (defvar crm-end-of-element nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 "Buffer position representing the end of the current element.")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 ;; emulates temp_echo_area_glyphs from src/minibuf.c
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (defun crm-temp-echo-area-glyphs (message-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 "Temporarily display MESSAGE-STRING in echo area.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 After user-input or 2 seconds, erase the displayed string."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (save-excursion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (goto-char (point-max))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (insert message-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (sit-for 2)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (backward-char (length message-string))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (delete-char (length message-string))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 ;; this function evolved from a posting by Stefan Monnier
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (defun crm-collection-fn (string predicate flag)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 "Function used by `completing-read-multiple' to compute completion values.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 The value of STRING is the string to be completed.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 The value of PREDICATE is a function to filter possible matches, or
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 nil if none.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 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
156 A value of nil specifies `try-completion'. A value of t specifies
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 `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
158
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 For more information on STRING, PREDICATE, and FLAG, see the Elisp
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 Reference sections on 'Programmed Completion' and 'Basic Completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 Functions'."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 (let ((lead ""))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (when (string-match (concat ".*" crm-separator) string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (setq lead (substring string 0 (match-end 0)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (setq string (substring string (match-end 0))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (if (eq flag 'lambda)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 ;; return t for exact match, nil otherwise
28741
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
168 (let ((result (try-completion string crm-completion-table predicate)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (if (stringp result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (if result
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 t
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 nil))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (if flag
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 ;; called via (all-completions string 'crm-completion-fn predicate)?
28741
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
176 (all-completions string crm-completion-table predicate)
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ;; called via (try-completion string 'crm-completion-fn predicate)?
28741
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
178 (let ((result (try-completion string crm-completion-table predicate)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (if (stringp result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (concat lead result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 result)))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (defun crm-find-current-element ()
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 "Parse the minibuffer to find the current element.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 If no element can be found, return nil.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 If an element is found, bind:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 -the variable `crm-current-element' to the current element,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 -the variables `crm-left-of-element' and `crm-right-of-element' to
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 the strings to the left and right of the current element,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 respectively, and
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 -the variables `crm-beginning-of-element' and `crm-end-of-element' to
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 the buffer positions of the beginning and end of the current element
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 respectively,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 and return t."
63894
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
200 (let* ((prompt-end (minibuffer-prompt-end))
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
201 (minibuffer-string (buffer-substring prompt-end (point-max)))
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
202 (end-index (or (string-match "," minibuffer-string (- (point) prompt-end))
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
203 (- (point-max) prompt-end)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 (target-string (substring minibuffer-string 0 end-index))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (index (or (string-match
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (concat crm-separator "\\([^" crm-separator "]*\\)$")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 target-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (string-match
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (concat "^\\([^" crm-separator "]*\\)$")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 target-string))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (if (not (numberp index))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 ;; no candidate found
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 (progn
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
215 ;;
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (setq crm-beginning-of-element (match-beginning 1))
63985
0dc94b891de0 (crm-find-current-element)
Juri Linkov <juri@jurta.org>
parents: 63894
diff changeset
217 (setq crm-end-of-element (+ end-index prompt-end))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 ;; string to the left of the current element
63894
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
219 (setq crm-left-of-element
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
220 (substring target-string 0 (match-beginning 1)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 ;; the current element
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (setq crm-current-element (match-string 1 target-string))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 ;; string to the right of the current element
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (setq crm-right-of-element (substring minibuffer-string end-index))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 t))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (defun crm-test-completion (candidate)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 "Return t if CANDIDATE is an exact match for a valid completion."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (let ((completions
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 ;; TODO: verify whether the arguments are appropriate
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
231 (all-completions
28741
efa45c683e9a (crm-completion-table): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28710
diff changeset
232 candidate crm-completion-table minibuffer-completion-predicate)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (if (member candidate completions)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 t
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 nil)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (defun crm-minibuffer-completion-help ()
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 "Display a list of possible completions of the current minibuffer element."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (interactive)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 (message "Making completion list...")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (if (not (crm-find-current-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 (let ((completions (all-completions crm-current-element
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 minibuffer-completion-table
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 minibuffer-completion-predicate)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (message nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 (if (null completions)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (crm-temp-echo-area-glyphs " [No completions]")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (with-output-to-temp-buffer "*Completions*"
67624
e17240315b4a (crm-minibuffer-completion-help):
Juri Linkov <juri@jurta.org>
parents: 64751
diff changeset
250 (display-completion-list
e17240315b4a (crm-minibuffer-completion-help):
Juri Linkov <juri@jurta.org>
parents: 64751
diff changeset
251 (sort completions 'string-lessp)
e17240315b4a (crm-minibuffer-completion-help):
Juri Linkov <juri@jurta.org>
parents: 64751
diff changeset
252 crm-current-element)))))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (defun crm-do-completion ()
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 "This is the internal completion engine.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 This function updates the text in the minibuffer
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 to complete the current string, and returns a number between 0 and 6.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 The meanings of the return values are:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 0 - the string has no possible completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 1 - the string is already a valid and unique match
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 2 - not used
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 3 - the string is already a valid match (but longer matches exist too)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 4 - the string was completed to a valid match
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 5 - some completion has been done, but the result is not a match
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 6 - no completion was done, and the string is not an exact match"
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (if (not (crm-find-current-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (let (last completion completedp)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (setq completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (try-completion crm-current-element
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 minibuffer-completion-table
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 minibuffer-completion-predicate))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (setq last crm-last-exact-completion)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (setq crm-last-exact-completion nil)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
278
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (catch 'crm-exit
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
280
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 (if (null completion) ; no possible completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (crm-temp-echo-area-glyphs " [No match]")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (throw 'crm-exit 0)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
285
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (if (eq completion t) ; was already an exact and unique completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (throw 'crm-exit 1))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
288
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (setq completedp
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (null (string-equal completion crm-current-element)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
291
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (if completedp
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (progn
63894
e2eed2c9a354 (crm-do-completion): Handle minibuffer prompt.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
294 (delete-region (minibuffer-prompt-end) (point-max))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (insert crm-left-of-element completion)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 ;; (if crm-complete-up-to-point
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 ;; (insert crm-separator))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (insert crm-right-of-element)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (backward-char (length crm-right-of-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 ;; TODO: is this correct?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (setq crm-current-element completion)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
302
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (if (null (crm-test-completion crm-current-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (if completedp ; some completion happened
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (throw 'crm-exit 5)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (if completion-auto-help
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (crm-minibuffer-completion-help)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (crm-temp-echo-area-glyphs " [Next char not unique]")))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (throw 'crm-exit 6))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (if completedp
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (throw 'crm-exit 4)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
313
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (setq crm-last-exact-completion completion)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (if (not (null last))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (if (not (null (equal crm-current-element last)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (crm-minibuffer-completion-help))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
319
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 ;; returning -- was already an exact completion
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (throw 'crm-exit 3)))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (defun crm-minibuffer-complete ()
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 "Complete the current element.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 If no characters can be completed, display a list of possible completions.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 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
328 (interactive)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 ;; take care of scrolling if necessary -- completely cribbed from minibuf.c
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (if (not (eq last-command this-command))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 ;; ok?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (setq minibuffer-scroll-window nil))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (let ((window minibuffer-scroll-window))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (if (and (not (null window))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 ;; ok?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (not (null (window-buffer window))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (let (tem)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (set-buffer (window-buffer window))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 ;; ok?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (setq tem (pos-visible-in-window-p (point-max) window))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (if (not (null tem))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 ;; ok?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (set-window-start window (point-min) nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (scroll-other-window nil))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 ;; reaching here means exiting the function w/ return value of nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (let* (
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 ;(crm-end-of-element nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (result (crm-do-completion)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (cond
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 ((eq 0 result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 ((eq 1 result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 ;; adapted from Emacs 21
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (if (not (eq (point) crm-end-of-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (goto-char (+ 1 crm-end-of-element)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (crm-temp-echo-area-glyphs " [Sole completion]")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 ((eq 3 result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 ;; adapted from Emacs 21
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (if (not (eq (point) crm-end-of-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (goto-char (+ 1 crm-end-of-element)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (crm-temp-echo-area-glyphs " [Complete, but not unique]")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 t))))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 ;; i love traffic lights...but only when they're green
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (defun crm-find-longest-completable-substring (string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 "Determine the longest completable (left-anchored) substring of STRING.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 The description \"left-anchored\" means the positions of the characters
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 in the substring must be the same as those of the corresponding characters
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 in STRING. Anchoring is what `^' does in a regular expression.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 The table and predicate used for completion are
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 `minibuffer-completion-table' and `minibuffer-completion-predicate',
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 respectively.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 A non-nil return value means that there is some substring which is
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 completable. A return value of t means that STRING itself is
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 completable. If a string value is returned it is the longest
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 completable proper substring of STRING. If nil is returned, STRING
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 does not have any non-empty completable substrings.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 Remember: \"left-anchored\" substring"
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (let* ((length-of-string (length string))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (index length-of-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (done (if (> length-of-string 0)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 t))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (first t) ; ugh, special handling for first time through...
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 goal-string
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 ;; loop through left-anchored substrings in order of descending length,
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 ;; find the first substring that is completable
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (while (not done)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (setq result (try-completion (substring string 0 index)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 minibuffer-completion-table
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 minibuffer-completion-predicate))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (if result
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ;; found completable substring
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (setq done t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (if (and (eq result t) first)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 ;; exactly matching string first time through
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (setq goal-string t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 ;; fully-completed proper substring
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (setq goal-string (substring string 0 index)))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (setq index (1- index))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (if first
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (setq first nil))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (if (<= index 0)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 (setq done t)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 ;; possible values include: t, nil, some string
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 goal-string))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 ;; TODO: decide whether trailing separator is allowed. current
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 ;; implementation appears to allow it
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (defun crm-strings-completed-p (separated-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 "Verify that strings in SEPARATED-STRING are completed strings.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 A return value of t means that all strings were verified. A number is
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 returned if verification was unsuccessful. This number represents the
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 position in SEPARATED-STRING up to where completion was successful."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (let ((strings (split-string separated-string crm-separator))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 ;; buffers start at 1, not 0
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (current-position 1)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 current-string
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 result
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 done)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (while (and strings (not done))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (setq current-string (car strings)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 result (try-completion current-string
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 minibuffer-completion-table
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 minibuffer-completion-predicate))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (if (eq result t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (setq strings (cdr strings)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 current-position (+ current-position
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (length current-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 ;; automatically adding 1 for separator
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 ;; character
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 1))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 ;; still one more case of a match
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (if (stringp result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (let ((string-list
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (all-completions result
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 minibuffer-completion-table
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 minibuffer-completion-predicate)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (if (member result string-list)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 ;; ho ho, code duplication...
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (setq strings (cdr strings)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 current-position (+ current-position
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (length current-string)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 1))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (setq done t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 ;; current-string is a partially-completed string
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (setq current-position (+ current-position
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (length current-string))))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 ;; current-string cannot be completed
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (let ((completable-substring
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (crm-find-longest-completable-substring current-string)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (setq done t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (setq current-position (+ current-position
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (length completable-substring)))))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 ;; return our result
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (if (null strings)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 t
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 current-position)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 ;; try to complete candidate, then check all separated strings. move
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 ;; point to problem position if checking fails for some string. if
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 ;; checking succeeds for all strings, exit.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (defun crm-minibuffer-complete-and-exit ()
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 "If all of the minibuffer elements are valid completions then exit.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 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
475 to the location of mismatch and do not exit.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 This function is modeled after `minibuffer_complete_and_exit' in src/minibuf.c"
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (interactive)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
479
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (if (not (crm-find-current-element))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (let (result)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
483
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (setq result
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (catch 'crm-exit
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
486
63985
0dc94b891de0 (crm-find-current-element)
Juri Linkov <juri@jurta.org>
parents: 63894
diff changeset
487 (if (eq (minibuffer-prompt-end) (point-max))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (throw 'crm-exit t))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
489
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 ;; TODO: this test is suspect?
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (if (not (null (crm-test-completion crm-current-element)))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (throw 'crm-exit "check"))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
493
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 ;; TODO: determine how to detect errors
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (let ((result (crm-do-completion)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
496
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (cond
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 ((or (eq 1 result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (eq 3 result))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (throw 'crm-exit "check"))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 ((eq 4 result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (if (not (null minibuffer-completion-confirm))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (crm-temp-echo-area-glyphs " [Confirm]")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (throw 'crm-exit "check")))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (nil)))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
508
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (if (null result)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 nil
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (if (equal result "check")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (let ((check-strings
63985
0dc94b891de0 (crm-find-current-element)
Juri Linkov <juri@jurta.org>
parents: 63894
diff changeset
513 (crm-strings-completed-p
0dc94b891de0 (crm-find-current-element)
Juri Linkov <juri@jurta.org>
parents: 63894
diff changeset
514 (buffer-substring (minibuffer-prompt-end) (point-max)))))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 ;; check all of minibuffer
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (if (eq check-strings t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (throw 'exit nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (if (numberp check-strings)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (progn
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (goto-char check-strings)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (crm-temp-echo-area-glyphs " [An element did not match]"))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (message "Unexpected error"))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (if (eq result t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (throw 'exit nil)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (message "Unexpected error")))))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (defun crm-init-keymaps ()
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 "Initialize the keymaps used by `completing-read-multiple'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 Two keymaps are used depending on the value of the REQUIRE-MATCH
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 argument of the function `completing-read-multiple'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 If REQUIRE-MATCH is nil, the keymap `crm-local-completion-map' is used.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 This keymap inherits from the keymap named `minibuffer-local-completion-map'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 The only difference is that TAB is bound to `crm-minibuffer-complete' in
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 the inheriting keymap.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
537 If REQUIRE-MATCH is non-nil, the keymap `crm-local-must-match-map' is used.
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 This keymap inherits from the keymap named `minibuffer-local-must-match-map'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 The inheriting keymap binds RET to `crm-minibuffer-complete-and-exit'
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 and TAB to `crm-minibuffer-complete'."
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (unless crm-local-completion-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (setq crm-local-completion-map (make-sparse-keymap))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (set-keymap-parent crm-local-completion-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 minibuffer-local-completion-map)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 ;; key definitions
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (define-key crm-local-completion-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (kbd "TAB")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (function crm-minibuffer-complete)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41694
diff changeset
549
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (unless crm-local-must-match-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (setq crm-local-must-match-map (make-sparse-keymap))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (set-keymap-parent crm-local-must-match-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 minibuffer-local-must-match-map)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 ;; key definitions
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (define-key crm-local-must-match-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (kbd "RET")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (function crm-minibuffer-complete-and-exit))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (define-key crm-local-must-match-map
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (kbd "TAB")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (function crm-minibuffer-complete))))
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (crm-init-keymaps)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 ;; superemulates behavior of completing_read in src/minibuf.c
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 ;;;###autoload
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 (defun completing-read-multiple
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (prompt table &optional predicate require-match initial-input
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 hist def inherit-input-method)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 "Read multiple strings in the minibuffer, with completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 By using this functionality, a user may specify multiple strings at a
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 single prompt, optionally using completion.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 Multiple strings are specified by separating each of the strings with
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 a prespecified separator character. For example, if the separator
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 character is a comma, the strings 'alice', 'bob', and 'eve' would be
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 specified as 'alice,bob,eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 The default value for the separator character is the value of
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 `crm-default-separator' (comma). The separator character may be
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 changed by modifying the value of `crm-separator'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
582 Contiguous strings of non-separator-characters are referred to as
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 'elements'. In the aforementioned example, the elements are: 'alice',
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 'bob', and 'eve'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 Completion is available on a per-element basis. For example, if the
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 contents of the minibuffer are 'alice,bob,eve' and point is between
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 'l' and 'i', pressing TAB operates on the element 'alice'.
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 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
591
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 See the documentation for `completing-read' for details on the arguments:
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF, and
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 INHERIT-INPUT-METHOD."
70555
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
595 (let* ((minibuffer-completion-table (function crm-collection-fn))
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
596 (minibuffer-completion-predicate predicate)
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
597 ;; see completing_read in src/minibuf.c
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
598 (minibuffer-completion-confirm
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
599 (unless (eq require-match t) require-match))
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
600 (crm-completion-table table)
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
601 crm-last-exact-completion
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
602 crm-current-element
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
603 crm-left-of-element
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
604 crm-right-of-element
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
605 crm-beginning-of-element
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
606 crm-end-of-element
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
607 (map (if require-match
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
608 crm-local-must-match-map
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
609 crm-local-completion-map))
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
610 ;; If the user enters empty input, read-from-minibuffer returns
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
611 ;; the empty string, not DEF.
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
612 (input (read-from-minibuffer
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
613 prompt initial-input map
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
614 nil hist def inherit-input-method)))
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
615 (and def (string-equal input "") (setq input def))
4ff0c9f3ea31 * emacs-lisp/crm.el (completing-read-multiple): Properly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
616 (split-string input crm-separator)))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 ;; testing and debugging
41694
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
619 ;; (defun crm-init-test-environ ()
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
620 ;; "Set up some variables for testing."
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
621 ;; (interactive)
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
622 ;; (setq my-prompt "Prompt: ")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
623 ;; (setq my-table
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
624 ;; '(("hi") ("there") ("man") ("may") ("mouth") ("ma")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
625 ;; ("a") ("ab") ("abc") ("abd") ("abf") ("zab") ("acb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
626 ;; ("da") ("dab") ("dabc") ("dabd") ("dabf") ("dzab") ("dacb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
627 ;; ("fda") ("fdab") ("fdabc") ("fdabd") ("fdabf") ("fdzab") ("fdacb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
628 ;; ("gda") ("gdab") ("gdabc") ("gdabd") ("gdabf") ("gdzab") ("gdacb")
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
629 ;; ))
835717f56bf2 (completing-read-multiple): Better preserve
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28741
diff changeset
630 ;; (setq my-separator ","))
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 ;(completing-read-multiple my-prompt my-table)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 ;(completing-read-multiple my-prompt my-table nil t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 ;(completing-read-multiple my-prompt my-table nil "match")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 ;(completing-read my-prompt my-table nil t)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 ;(completing-read my-prompt my-table nil "match")
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (provide 'crm)
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
640 ;;; arch-tag: db1911d9-86c6-4a42-b32a-4910701b15a6
28710
6efaa4627dee *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 ;;; crm.el ends here