return val;
}
-
-
+\f
DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
Sminibuffer_prompt_end, 0, 0, 0,
doc: /* Return the buffer position of the end of the minibuffer prompt.
return Qnil;
}
+/* Get the text in the minibuffer before point.
+ That is what completion commands operate on. */
+minibuffer_completion_contents ()
+{
+ int prompt_end = XINT (Fminibuffer_prompt_end ());
+ return make_buffer_string (prompt_end, PT, 1);
+}
+\f
/* Read from the minibuffer using keymap MAP, initial contents INITIAL
(a string), putting point minus BACKUP_N bytes from the end of INITIAL,
prompting with PROMPT (a string), using history list HISTVAR
Lisp_Object last;
struct gcpro gcpro1, gcpro2;
- completion = Ftry_completion (Fminibuffer_contents (),
+ completion = Ftry_completion (minibuffer_completion_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
last = last_exact_completion;
return 1;
}
- string = Fminibuffer_contents ();
+ string = minibuffer_completion_contents ();
/* COMPLETEDP should be true if some completion was done, which
doesn't include simply changing the case of the entered string.
if (!EQ (tem, Qt))
/* Rewrite the user's input. */
{
- Fdelete_minibuffer_contents (); /* Some completion happened */
+ int prompt_end = XINT (Fminibuffer_prompt_end ());
+ /* Some completion happened */
+
+ if (! NILP (Vminibuffer_completing_file_name)
+ && XSTRING (completion)->data[STRING_BYTES (XSTRING (completion)) - 1] == '/'
+ && PT < ZV
+ && FETCH_CHAR (PT_BYTE) == '/')
+ {
+ del_range (prompt_end, PT + 1);
+ }
+ else
+ del_range (prompt_end, PT);
+
Finsert (1, &completion);
if (! completedp)
last_exact_completion = completion;
if (!NILP (last))
{
- tem = Fminibuffer_contents ();
+ tem = minibuffer_completion_contents ();
if (!NILP (Fequal (tem, last)))
Fminibuffer_completion_help ();
}
register int i, i_byte;
register unsigned char *completion_string;
struct gcpro gcpro1, gcpro2;
- int prompt_end_charpos;
+ int prompt_end_charpos = XINT (Fminibuffer_prompt_end ());
/* We keep calling Fbuffer_string rather than arrange for GC to
hold onto a pointer to one of the strings thus made. */
- completion = Ftry_completion (Fminibuffer_contents (),
+ completion = Ftry_completion (minibuffer_completion_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
if (NILP (completion))
int buffer_nchars, completion_nchars;
CHECK_STRING (completion);
- tem = Fminibuffer_contents ();
+ tem = minibuffer_completion_contents ();
GCPRO2 (completion, tem);
/* If reading a file name,
expand any $ENVVAR refs in the buffer and in TEM. */
if (! EQ (substituted, tem))
{
tem = substituted;
- Fdelete_minibuffer_contents ();
- insert_from_string (tem, 0, 0, XSTRING (tem)->size,
- STRING_BYTES (XSTRING (tem)), 0);
+ del_range (prompt_end_charpos, PT);
+ Finsert (1, &tem);
}
}
- buffer_nchars = XSTRING (tem)->size; /* ie ZV - BEGV */
+ buffer_nchars = XSTRING (tem)->size; /* # chars in what we completed. */
completion_nchars = XSTRING (completion)->size;
i = buffer_nchars - completion_nchars;
if (i > 0
{
int start_pos;
- /* Set buffer to longest match of buffer tail and completion head. */
+ /* Make buffer (before point) contain the longest match
+ of TEM's tail and COMPLETION's head. */
if (i <= 0) i = 1;
start_pos= i;
buffer_nchars -= i;
buffer_nchars--;
}
del_range (1, i + 1);
- SET_PT_BOTH (ZV, ZV_BYTE);
}
UNGCPRO;
}
#endif /* Rewritten code */
- prompt_end_charpos = XINT (Fminibuffer_prompt_end ());
-
{
int prompt_end_bytepos;
prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos);
- i = ZV - prompt_end_charpos;
- i_byte = ZV_BYTE - prompt_end_bytepos;
+ i = PT - prompt_end_charpos;
+ i_byte = PT_BYTE - prompt_end_bytepos;
}
/* If completion finds next char not unique,
if (i == XSTRING (completion)->size)
{
GCPRO1 (completion);
- tem = Ftry_completion (concat2 (Fminibuffer_contents (), build_string (" ")),
+ tem = Ftry_completion (concat2 (minibuffer_completion_contents (),
+ build_string (" ")),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
UNGCPRO;
{
GCPRO1 (completion);
tem =
- Ftry_completion (concat2 (Fminibuffer_contents (), build_string ("-")),
+ Ftry_completion (concat2 (minibuffer_completion_contents (),
+ build_string ("-")),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
UNGCPRO;
/* If got no characters, print help for user. */
- if (i == ZV - prompt_end_charpos)
+ if (i == PT - prompt_end_charpos)
{
if (!NILP (Vcompletion_auto_help))
Fminibuffer_completion_help ();
/* Otherwise insert in minibuffer the chars we got */
- Fdelete_minibuffer_contents ();
+ if (! NILP (Vminibuffer_completing_file_name)
+ && XSTRING (completion)->data[STRING_BYTES (XSTRING (completion)) - 1] == '/'
+ && PT < ZV
+ && FETCH_CHAR (PT_BYTE) == '/')
+ {
+ del_range (prompt_end_charpos, PT + 1);
+ }
+ else
+ del_range (prompt_end_charpos, PT);
+
insert_from_string (completion, 0, 0, i, i_byte, 1);
return Qt;
}
Lisp_Object completions;
message ("Making completion list...");
- completions = Fall_completions (Fminibuffer_contents (),
+ completions = Fall_completions (minibuffer_completion_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate,
Qt);