aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-08 09:51:31 +0000
committerRichard M. Stallman1994-10-08 09:51:31 +0000
commit5d2ca7aec686ab793b309c42abc86705fda114df (patch)
treec16d9e1e3c5aa5d594b0eaaf9cc19c0a6cfcc03d /src
parent3071ee28bb31fba9257b2e85123279ff7242e43b (diff)
downloademacs-5d2ca7aec686ab793b309c42abc86705fda114df.tar.gz
emacs-5d2ca7aec686ab793b309c42abc86705fda114df.zip
(test_completion): New function, extracted from do_completion.
(do_completion): Use test_completion. (Fminibuffer_complete_and_exit): If completion is already exact, don't try to complete it.
Diffstat (limited to 'src')
-rw-r--r--src/minibuf.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index f7b3e59621f..f24a3d4e369 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1046,6 +1046,36 @@ temp_echo_area_glyphs (m)
1046 1046
1047Lisp_Object Fminibuffer_completion_help (); 1047Lisp_Object Fminibuffer_completion_help ();
1048Lisp_Object assoc_for_completion (); 1048Lisp_Object assoc_for_completion ();
1049/* A subroutine of Fintern_soft. */
1050extern Lisp_Object oblookup ();
1051
1052
1053/* Test whether TXT is an exact completion. */
1054Lisp_Object
1055test_completion (txt)
1056 Lisp_Object txt;
1057{
1058 Lisp_Object tem;
1059
1060 if (CONSP (Vminibuffer_completion_table)
1061 || NILP (Vminibuffer_completion_table))
1062 return assoc_for_completion (txt, Vminibuffer_completion_table);
1063 else if (VECTORP (Vminibuffer_completion_table))
1064 {
1065 /* Bypass intern-soft as that loses for nil */
1066 tem = oblookup (Vminibuffer_completion_table,
1067 XSTRING (txt)->data, XSTRING (txt)->size);
1068 if (SYMBOLP (tem))
1069 return Qnil;
1070 else if (!NILP (Vminibuffer_completion_predicate))
1071 return call1 (Vminibuffer_completion_predicate, tem);
1072 else
1073 return Qt;
1074 }
1075 else
1076 return call3 (Vminibuffer_completion_table, txt,
1077 Vminibuffer_completion_predicate, Qlambda);
1078}
1049 1079
1050/* returns: 1080/* returns:
1051 * 0 no possible completion 1081 * 0 no possible completion
@@ -1093,32 +1123,7 @@ do_completion ()
1093 } 1123 }
1094 1124
1095 /* It did find a match. Do we match some possibility exactly now? */ 1125 /* It did find a match. Do we match some possibility exactly now? */
1096 if (CONSP (Vminibuffer_completion_table) 1126 tem = test_completion (Fbuffer_string ());
1097 || NILP (Vminibuffer_completion_table))
1098 tem = assoc_for_completion (Fbuffer_string (),
1099 Vminibuffer_completion_table);
1100 else if (VECTORP (Vminibuffer_completion_table))
1101 {
1102 /* the primitive used by Fintern_soft */
1103 extern Lisp_Object oblookup ();
1104
1105 tem = Fbuffer_string ();
1106 /* Bypass intern-soft as that loses for nil */
1107 tem = oblookup (Vminibuffer_completion_table,
1108 XSTRING (tem)->data, XSTRING (tem)->size);
1109 if (!SYMBOLP (tem))
1110 tem = Qnil;
1111 else if (!NILP (Vminibuffer_completion_predicate))
1112 tem = call1 (Vminibuffer_completion_predicate, tem);
1113 else
1114 tem = Qt;
1115 }
1116 else
1117 tem = call3 (Vminibuffer_completion_table,
1118 Fbuffer_string (),
1119 Vminibuffer_completion_predicate,
1120 Qlambda);
1121
1122 if (NILP (tem)) 1127 if (NILP (tem))
1123 { 1128 {
1124 /* not an exact match */ 1129 /* not an exact match */
@@ -1236,9 +1241,8 @@ scroll the window of possible completions.")
1236 1241
1237DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit, 1242DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit,
1238 Sminibuffer_complete_and_exit, 0, 0, "", 1243 Sminibuffer_complete_and_exit, 0, 0, "",
1239 "Complete the minibuffer contents, and maybe exit.\n\ 1244 "If the minibuffer contents is a valid completion then exit.\n\
1240Exit if the name is valid with no completion needed.\n\ 1245Otherwise try to complete it. If completion leads to a valid completion,\n\
1241If name was completed to a valid match,\n\
1242a repetition of this command will exit.") 1246a repetition of this command will exit.")
1243 () 1247 ()
1244{ 1248{
@@ -1248,6 +1252,9 @@ a repetition of this command will exit.")
1248 if (BEGV == ZV) 1252 if (BEGV == ZV)
1249 goto exit; 1253 goto exit;
1250 1254
1255 if (!NILP (test_completion (Fbuffer_string ())))
1256 goto exit;
1257
1251 i = do_completion (); 1258 i = do_completion ();
1252 switch (i) 1259 switch (i)
1253 { 1260 {