[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/minibuf.c
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/src/minibuf.c |
Date: |
Wed, 26 Jun 2002 04:42:22 -0400 |
Index: emacs/src/minibuf.c
diff -c emacs/src/minibuf.c:1.240 emacs/src/minibuf.c:1.241
*** emacs/src/minibuf.c:1.240 Sun Jun 2 21:42:52 2002
--- emacs/src/minibuf.c Wed Jun 26 04:42:22 2002
***************
*** 317,324 ****
return val;
}
!
!
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.
--- 317,323 ----
return val;
}
!
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.
***************
*** 367,373 ****
--- 366,380 ----
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);
+ }
+
/* 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
***************
*** 1626,1632 ****
Lisp_Object last;
struct gcpro gcpro1, gcpro2;
! completion = Ftry_completion (Fminibuffer_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
last = last_exact_completion;
--- 1633,1639 ----
Lisp_Object last;
struct gcpro gcpro1, gcpro2;
! completion = Ftry_completion (minibuffer_completion_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
last = last_exact_completion;
***************
*** 1648,1654 ****
return 1;
}
! string = Fminibuffer_contents ();
/* COMPLETEDP should be true if some completion was done, which
doesn't include simply changing the case of the entered string.
--- 1655,1661 ----
return 1;
}
! 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.
***************
*** 1661,1667 ****
if (!EQ (tem, Qt))
/* Rewrite the user's input. */
{
! Fdelete_minibuffer_contents (); /* Some completion happened */
Finsert (1, &completion);
if (! completedp)
--- 1668,1686 ----
if (!EQ (tem, Qt))
/* Rewrite the user's input. */
{
! 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)
***************
*** 1703,1709 ****
last_exact_completion = completion;
if (!NILP (last))
{
! tem = Fminibuffer_contents ();
if (!NILP (Fequal (tem, last)))
Fminibuffer_completion_help ();
}
--- 1722,1728 ----
last_exact_completion = completion;
if (!NILP (last))
{
! tem = minibuffer_completion_contents ();
if (!NILP (Fequal (tem, last)))
Fminibuffer_completion_help ();
}
***************
*** 1880,1891 ****
register int i, i_byte;
register unsigned char *completion_string;
struct gcpro gcpro1, gcpro2;
! int prompt_end_charpos;
/* 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 (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
if (NILP (completion))
--- 1899,1910 ----
register int i, i_byte;
register unsigned char *completion_string;
struct gcpro gcpro1, gcpro2;
! 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 (minibuffer_completion_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
if (NILP (completion))
***************
*** 1917,1923 ****
int buffer_nchars, completion_nchars;
CHECK_STRING (completion);
! tem = Fminibuffer_contents ();
GCPRO2 (completion, tem);
/* If reading a file name,
expand any $ENVVAR refs in the buffer and in TEM. */
--- 1936,1942 ----
int buffer_nchars, completion_nchars;
CHECK_STRING (completion);
! tem = minibuffer_completion_contents ();
GCPRO2 (completion, tem);
/* If reading a file name,
expand any $ENVVAR refs in the buffer and in TEM. */
***************
*** 1928,1939 ****
if (! EQ (substituted, tem))
{
tem = substituted;
! Fdelete_minibuffer_contents ();
! insert_from_string (tem, 0, 0, XSTRING (tem)->size,
! STRING_BYTES (XSTRING (tem)), 0);
}
}
! buffer_nchars = XSTRING (tem)->size; /* ie ZV - BEGV */
completion_nchars = XSTRING (completion)->size;
i = buffer_nchars - completion_nchars;
if (i > 0
--- 1947,1957 ----
if (! EQ (substituted, tem))
{
tem = substituted;
! del_range (prompt_end_charpos, PT);
! Finsert (1, &tem);
}
}
! buffer_nchars = XSTRING (tem)->size; /* # chars in what we completed. */
completion_nchars = XSTRING (completion)->size;
i = buffer_nchars - completion_nchars;
if (i > 0
***************
*** 1947,1953 ****
{
int start_pos;
! /* Set buffer to longest match of buffer tail and completion head. */
if (i <= 0) i = 1;
start_pos= i;
buffer_nchars -= i;
--- 1965,1972 ----
{
int start_pos;
! /* 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;
***************
*** 1964,1982 ****
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;
}
/* If completion finds next char not unique,
--- 1983,1998 ----
buffer_nchars--;
}
del_range (1, i + 1);
}
UNGCPRO;
}
#endif /* Rewritten code */
{
int prompt_end_bytepos;
prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos);
! i = PT - prompt_end_charpos;
! i_byte = PT_BYTE - prompt_end_bytepos;
}
/* If completion finds next char not unique,
***************
*** 1984,1990 ****
if (i == XSTRING (completion)->size)
{
GCPRO1 (completion);
! tem = Ftry_completion (concat2 (Fminibuffer_contents (), build_string
(" ")),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
UNGCPRO;
--- 2000,2007 ----
if (i == XSTRING (completion)->size)
{
GCPRO1 (completion);
! tem = Ftry_completion (concat2 (minibuffer_completion_contents (),
! build_string (" ")),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
UNGCPRO;
***************
*** 1995,2001 ****
{
GCPRO1 (completion);
tem =
! Ftry_completion (concat2 (Fminibuffer_contents (), build_string
("-")),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
UNGCPRO;
--- 2012,2019 ----
{
GCPRO1 (completion);
tem =
! Ftry_completion (concat2 (minibuffer_completion_contents (),
! build_string ("-")),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate);
UNGCPRO;
***************
*** 2027,2033 ****
/* If got no characters, print help for user. */
! if (i == ZV - prompt_end_charpos)
{
if (!NILP (Vcompletion_auto_help))
Fminibuffer_completion_help ();
--- 2045,2051 ----
/* If got no characters, print help for user. */
! if (i == PT - prompt_end_charpos)
{
if (!NILP (Vcompletion_auto_help))
Fminibuffer_completion_help ();
***************
*** 2036,2042 ****
/* Otherwise insert in minibuffer the chars we got */
! Fdelete_minibuffer_contents ();
insert_from_string (completion, 0, 0, i, i_byte, 1);
return Qt;
}
--- 2054,2069 ----
/* Otherwise insert in minibuffer the chars we got */
! 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;
}
***************
*** 2232,2238 ****
Lisp_Object completions;
message ("Making completion list...");
! completions = Fall_completions (Fminibuffer_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate,
Qt);
--- 2259,2265 ----
Lisp_Object completions;
message ("Making completion list...");
! completions = Fall_completions (minibuffer_completion_contents (),
Vminibuffer_completion_table,
Vminibuffer_completion_predicate,
Qt);