• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3931 (tree)
Time2018-12-01 22:28:54
Authormagicant

Log Message

Add le-predict-empty option

Some users find it confusing for the command line prediction feature to
suggest a command before any character is inserted on the command line.
This commit adds the le-predict-empty option. Suggestion for an empty
line is now performed only when the new option is enabled.

This patch was contributed by Adrian Perez:
https://github.com/magicant/yash/pull/7

--

Squashed commit of the following:

commit 318989c365a1ec383a81d561b810e5e4dd0aaa21
Author: Adrian Perez de Castro <aperez@igalia.com>
Date: Sat Dec 1 01:32:07 2018 +0100

tests: Modify test expectations to cover "lepredictempty"
This adds the "lepredictempty" option in the results for
some of the tests.

commit a1201a7a75aaf580541cf6cda4366df43388f66b
Author: Adrian Perez de Castro <aperez@igalia.com>
Date: Sat Dec 1 01:23:27 2018 +0100

Document option "lepredictempty"

commit ca468e370044e7ecc37cad0dc4e170d98c07f30a
Author: Adrian Perez de Castro <aperez@igalia.com>
Date: Sat Dec 1 01:16:17 2018 +0100

completion/set: Add "lepredictempty" to the list of options

commit 58bad870071da341f20ac44a33919adca0892d2b
Author: Adrian Perez de Castro <aperez@igalia.com>
Date: Sat Dec 1 01:12:27 2018 +0100

Add option "lepredictempty" to enable auto-suggestions on empty lines
Enabling the "lepredictempty" option will also provide
auto-suggestions on empty input lines when "lepredict" is
enabled.

commit 6119b73ace7c65bb7f214df8e270cff2094b9a63
Author: Adrian Perez de Castro <aperez@igalia.com>
Date: Fri Nov 30 09:28:15 2018 +0100

Only add prediction to input line when there is some input

Change Summary

Incremental Difference

--- yash/trunk/doc/_set.txt (revision 3930)
+++ yash/trunk/doc/_set.txt (revision 3931)
@@ -150,6 +150,7 @@
150150 [[so-leconvmeta]]le-conv-meta::
151151 [[so-lenoconvmeta]]le-no-conv-meta::
152152 [[so-lepredict]]le-predict::
153+[[so-lepredictempty]]le-predictemty::
153154 [[so-lepromptsp]]le-prompt-sp::
154155 [[so-levisiblebell]]le-visible-bell::
155156 See link:lineedit.html#options[shell options on line-editing].
--- yash/trunk/doc/lineedit.txt (revision 3930)
+++ yash/trunk/doc/lineedit.txt (revision 3931)
@@ -68,6 +68,10 @@
6868 link:_set.html#so-lepredict[le-predict]::
6969 activates <<prediction,command line prediction>>.
7070
71+link:_set.html#so-lepredictempty[le-predictempty]::
72+When enabled, and <<prediction,command line prediction>> is active,
73+suggestions are also provided for empty input lines.
74+
7175 link:_set.html#so-lepromptsp[le-prompt-sp]::
7276 When enabled, the shell prints a special character sequence before printing
7377 each prompt so that every prompt is printed at the beginning of a line.
--- yash/trunk/lineedit/editing.c (revision 3930)
+++ yash/trunk/lineedit/editing.c (revision 3931)
@@ -2559,8 +2559,12 @@
25592559 {
25602560 clear_prediction();
25612561
2562+ if (!shopt_le_predictempty && active_length() == 0)
2563+ return;
2564+
25622565 if (le_main_index < active_length())
25632566 return;
2567+
25642568 le_main_length = le_main_buffer.length;
25652569
25662570 wchar_t *suffix = trie_probable_key(
--- yash/trunk/option.c (revision 3930)
+++ yash/trunk/option.c (revision 3931)
@@ -190,6 +190,8 @@
190190 /* If set, auto-suggest the most probable command line as the user enters a
191191 * command line. */
192192 bool shopt_le_predict = false;
193+/* If set, auto-suggest also provides suggestions for empty input lines. */
194+bool shopt_le_predictempty = false;
193195 /* If set, debugging information is printed during command completion. */
194196 bool shopt_le_compdebug = false;
195197 #endif
@@ -234,6 +236,7 @@
234236 { 0, 0, L"leconvmeta", &shopt_le_yesconvmeta, true, },
235237 { 0, 0, L"lenoconvmeta", &shopt_le_noconvmeta, true, },
236238 { 0, 0, L"lepredict", &shopt_le_predict, true, },
239+ { 0, 0, L"lepredictempty", &shopt_le_predictempty,true, },
237240 { 0, 0, L"lepromptsp", &shopt_le_promptsp, true, },
238241 { 0, 0, L"levisiblebell", &shopt_le_visiblebell, true, },
239242 #endif
--- yash/trunk/option.h (revision 3930)
+++ yash/trunk/option.h (revision 3931)
@@ -57,7 +57,7 @@
5757 extern enum shopt_lineedit_T shopt_lineedit;
5858 extern enum shopt_yesnoauto_T shopt_le_convmeta;
5959 extern _Bool shopt_le_visiblebell, shopt_le_promptsp, shopt_le_alwaysrp,
60- shopt_le_predict, shopt_le_compdebug;
60+ shopt_le_predict, shopt_le_predictempty, shopt_le_compdebug;
6161 #endif
6262
6363 /* Whether or not this shell process is doing job control right now. */
Show on old repository browser