summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-03 22:37:21 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-03 22:37:21 -0700
commit66320508c3c964ea33584c5c4b1b84850ae469bf (patch)
tree609da94c8b1c5a34c3eea52c1953ec00960a665b
parent7996c1fa2d68251430a5007e97ef4e8f39429a26 (diff)
downloadtxr-66320508c3c964ea33584c5c4b1b84850ae469bf.tar.gz
txr-66320508c3c964ea33584c5c4b1b84850ae469bf.tar.bz2
txr-66320508c3c964ea33584c5c4b1b84850ae469bf.zip
Interactive listener: substring completion.
* parser.c (find_matching_syms): Take advantage of the linenoise Ctrl-X Tab feature by providing substring matches. * txr.1: Documented Ctrl-X Tab.
-rw-r--r--parser.c5
-rw-r--r--txr.132
2 files changed, 33 insertions, 4 deletions
diff --git a/parser.c b/parser.c
index 3ff1451a..ccff6a3f 100644
--- a/parser.c
+++ b/parser.c
@@ -424,8 +424,11 @@ static void find_matching_syms(lino_completions_t *cpl,
for (syms = package_symbols(package); syms; syms = cdr(syms)) {
val sym = car(syms);
val name = symbol_name(sym);
+ val found = if3(cpl->substring,
+ search_str(name, prefix, zero, nil),
+ match_str(name, prefix, zero));
- if (match_str(name, prefix, zero)) {
+ if (found) {
val comple;
switch (par) {
diff --git a/txr.1 b/txr.1
index bac9f926..1dc7ea9c 100644
--- a/txr.1
+++ b/txr.1
@@ -34342,10 +34342,11 @@ lines relative to the currently recalled history line.
.NP* Symbolic Completion
If the Tab key is pressed while editing a line, it is interpreted as a
-request for completion.
+request for completion. There is a second completion command: the
+sequence Ctrl-X Tab.
-When completion is invoked with the Tab key, the listener looks at a few of the
-trailing characters to the left of the cursor position to determine the
+When completion is invoked with Tab or Ctrl-X Tab, the listener looks at a few
+of the trailing characters to the left of the cursor position to determine the
applicable list of completions. Completions are determined from among the \*(TL symbols which have
global variable, function, macro and symbolic macro bindings. Symbols which
have operator binding are also taken into consideration. If a
@@ -34353,6 +34354,29 @@ package-qualified symbol is completed, then completion is restricted to that
package. Keyword symbol completion is restricted to the contents of the keyword
package.
+The difference between Tab and Ctrl-X Tab is that Tab completion looks only for
+prefix matches among the eligible identifiers. Thus it is a pure completion in
+the sense that it suggests additional material that may follow what has been
+typed. If the buffer contains
+.code (list
+it will only suggest completions which can be endings for
+.code list
+such as
+.codn list* ,
+.codn listp ,
+and
+.codn list-str .
+It will not suggest identifiers which rewrite the
+.code list
+prefix. By contrast, the Ctrl-X Tab completion suggests not only pure
+completions but also alternatives to the partial identifier, by looking for
+substring matches. For instance
+.code copy-list
+is a possible completion for
+.codn list ,
+as is
+.codn proper-listp .
+
If no completions are found, then the BEL character is sent to the terminal
to generate a beep or a visual alert indication. The listener returns to
editing mode.
@@ -34360,6 +34384,8 @@ editing mode.
If completions are found, listener enters into completion selection mode.
The first available completion is placed into the line as if it had been typed
in. The other completions may be viewed one by one using the Tab key.
+(Note that the Ctrl-X is not used, only Tab, even if completion mode had been
+entered via Ctrl-X Tab).
When the completions are exhausted, the original uncompleted line is shown
again, and Tab can continue to be used to cycle through the completions again.
In completion mode, the Ctrl-C character acts as a command to cancel completion mode