annotate src/minibuf.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 576fb035e263
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Minibuffer input and completion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992-1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Mule 2.0, FSF 19.28. Mule-ized except as noted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 Substantially different from FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* #### dmoore - All sorts of things in here can call lisp, like message.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 Track all this stuff. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "commands.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "console-stream.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "events.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "redisplay.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 /* Depth in minibuffer invocations. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 int minibuf_level;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 Lisp_Object Qcompletion_ignore_case;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 /* Nonzero means completion ignores case. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 int completion_ignore_case;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 /* List of regexps that should restrict possible completions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 Lisp_Object Vcompletion_regexp_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 /* The echo area buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Lisp_Object Vecho_area_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 /* Prompt to display in front of the minibuffer contents */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 Lisp_Object Vminibuf_prompt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 /* Added on 97/3/14 by Jareth Hein (jhod@po.iijnet.or.jp) for input system support */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 /* String to be displayed in front of prompt of the minibuffer contents */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 Lisp_Object Vminibuf_preprompt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /* Hook to run just after entry to minibuffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 Lisp_Object Qminibuffer_setup_hook, Vminibuffer_setup_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 Lisp_Object Qappend_message, Qcurrent_message_label,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Qclear_message, Qdisplay_message;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 DEFUN ("minibuffer-depth", Fminibuffer_depth, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 Return current depth of activations of minibuffer, a nonnegative integer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 return make_int (minibuf_level);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 /* The default buffer to use as the window-buffer of minibuffer windows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 /* Note there is special code in kill-buffer to make this unkillable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 Lisp_Object Vminibuffer_zero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 /* Actual minibuffer invocation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 read_minibuffer_internal_unwind (Lisp_Object unwind_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 XWINDOW (minibuf_window)->last_modified[CURRENT_DISP] = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 XWINDOW (minibuf_window)->last_modified[DESIRED_DISP] = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 XWINDOW (minibuf_window)->last_modified[CMOTION_DISP] = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 XWINDOW (minibuf_window)->last_facechange[CURRENT_DISP] = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 XWINDOW (minibuf_window)->last_facechange[DESIRED_DISP] = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 XWINDOW (minibuf_window)->last_facechange[CMOTION_DISP] = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 Vminibuf_prompt = Felt (unwind_data, Qzero);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 minibuf_level = XINT (Felt (unwind_data, make_int (1)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 while (CONSP (unwind_data))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 Lisp_Object victim = unwind_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 unwind_data = XCDR (unwind_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 free_cons (XCONS (victim));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 /* If cursor is on the minibuffer line,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 show the user we have exited by putting it in column 0. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 frame = Fselected_frame (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 if (!noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 && !NILP (frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 && !NILP (XFRAME (frame)->minibuffer_window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 struct window *w = XWINDOW (XFRAME (frame)->minibuffer_window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 redisplay_move_cursor (w, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 /* 97/4/13 jhod: Added for input methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 DEFUN ("set-minibuffer-preprompt", Fset_minibuffer_preprompt, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 Set the minibuffer preprompt string to PREPROMPT. This is used by language
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 input methods to relay state information to the user.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (preprompt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 if (NILP (preprompt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 Vminibuf_preprompt = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 CHECK_STRING (preprompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 Vminibuf_preprompt = LISP_GETTEXT (preprompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 DEFUN ("read-minibuffer-internal", Fread_minibuffer_internal, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 Lowest-level interface to minibuffers. Don't call this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (prompt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 int speccount = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 Lisp_Object val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 CHECK_STRING (prompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 single_console_state ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 record_unwind_protect (read_minibuffer_internal_unwind,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 noseeum_cons
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (Vminibuf_prompt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 noseeum_cons (make_int (minibuf_level), Qnil)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 Vminibuf_prompt = LISP_GETTEXT (prompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 /* NOTE: Here (or somewhere around here), in FSFmacs 19.30,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 choose_minibuf_frame() is called. This is the only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 place in FSFmacs that it's called any more -- there's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 also a call in xterm.c, but commented out, and 19.28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 had the calls in different places.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 choose_minibuf_frame() does the following:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 if (!EQ (minibuf_window, selected_frame()->minibuffer_window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 Fset_window_buffer (selected_frame()->minibuffer_window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 XWINDOW (minibuf_window)->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 minibuf_window = selected_frame()->minibuffer_window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #### Note that we don't do the set-window-buffer. This call is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 similar, but not identical, to a set-window-buffer call made
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 in `read-from-minibuffer' in minibuf.el. I hope it's close
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 enough, because minibuf_window isn't really exported to Lisp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 The comment above choose_minibuf_frame() reads:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 Put minibuf on currently selected frame's minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 We do this whenever the user starts a new minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 or when a minibuffer exits. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 minibuf_window = FRAME_MINIBUF_WINDOW (selected_frame ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 run_hook (Qminibuffer_setup_hook);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 minibuf_level++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 clear_echo_area (selected_frame (), Qnil, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 val = call_command_loop (Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 return unbind_to (speccount, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 /* Completion hair */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 /* Compare exactly LEN chars of strings at S1 and S2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 ignoring case if appropriate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 Return -1 if strings match,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 else number of chars that match at the beginning. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 /* Note that this function works in Charcounts, unlike most functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 This is necessary for many reasons, one of which is that two
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 strings may match even if they have different numbers of bytes,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if IGNORE_CASE is true. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 Charcount
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
208 scmp_1 (const Bufbyte *s1, const Bufbyte *s2, Charcount len,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 int ignore_case)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 Charcount l = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 if (ignore_case)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 while (l)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 Emchar c1 = DOWNCASE (current_buffer, charptr_emchar (s1));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 Emchar c2 = DOWNCASE (current_buffer, charptr_emchar (s2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 if (c1 == c2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 l--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 INC_CHARPTR (s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 INC_CHARPTR (s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 while (l && charptr_emchar (s1) == charptr_emchar (s2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 l--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 INC_CHARPTR (s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 INC_CHARPTR (s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 if (l == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 else return len - l;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
247 regexp_ignore_completion_p (const Bufbyte *nonreloc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 Lisp_Object reloc, Bytecount offset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 Bytecount length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 /* Ignore this element if it fails to match all the regexps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 if (!NILP (Vcompletion_regexp_list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 Lisp_Object regexps;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 EXTERNAL_LIST_LOOP (regexps, Vcompletion_regexp_list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 Lisp_Object re = XCAR (regexps);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 CHECK_STRING (re);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 if (fast_string_match (re, nonreloc, reloc, offset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 length, 0, ERROR_ME, 0) < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 /* Callers should GCPRO, since this may call eval */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 ignore_completion_p (Lisp_Object completion_string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 Lisp_Object pred, Lisp_Object completion)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 if (regexp_ignore_completion_p (0, completion_string, 0, -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 /* Ignore this element if there is a predicate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 and the predicate doesn't like it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 if (!NILP (pred))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 Lisp_Object tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 if (EQ (pred, Qcommandp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 tem = Fcommandp (completion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 tem = call1 (pred, completion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 /* #### Maybe we should allow ALIST to be a hash table. It is wrong
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 for the use of obarrays to be better-rewarded than the use of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 hash tables. By better-rewarded I mean that you can pass an obarray
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 to all of the completion functions, whereas you can't do anything
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 like that with a hash table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 To do so, there should probably be a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 map_obarray_or_alist_or_hash_table function which would be used by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 both Ftry_completion and Fall_completions. But would the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 additional funcalls slow things down? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 DEFUN ("try-completion", Ftry_completion, 2, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 Return common substring of all completions of STRING in ALIST.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 Each car of each element of ALIST is tested to see if it begins with STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 All that match are compared together; the longest initial sequence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 common to all matches is returned as a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 If there is no match at all, nil is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 For an exact match, t is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 ALIST can be an obarray instead of an alist.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 Then the print names of all symbols in the obarray are the possible matches.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 ALIST can also be a function to do the completion itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 It receives three arguments: the values STRING, PREDICATE and nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 Whatever it returns becomes the value of `try-completion'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 If optional third argument PREDICATE is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 it is used to test each possible match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 The match is a candidate only if PREDICATE returns non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 The argument given to PREDICATE is the alist element or the symbol from the obarray.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (string, alist, pred))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 Lisp_Object bestmatch, tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Charcount bestmatchsize = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 int list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 int indice = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 int matchcount = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 int obsize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 Lisp_Object bucket;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 Charcount slength, blength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 CHECK_STRING (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 if (CONSP (alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 Lisp_Object tem = XCAR (alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 if (SYMBOLP (tem)) /* lambda, autoload, etc. Emacs-lisp sucks */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 return call3 (alist, string, pred, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 list = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 else if (VECTORP (alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 list = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 else if (NILP (alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 list = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 return call3 (alist, string, pred, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 bestmatch = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 blength = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 slength = XSTRING_CHAR_LENGTH (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 /* If ALIST is not a list, set TAIL just for gc pro. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 tail = alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 if (!list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 obsize = XVECTOR_LENGTH (alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 bucket = XVECTOR_DATA (alist)[indice];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 else /* warning suppression */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 obsize = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 bucket = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 /* Get the next element of the alist or obarray. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 /* Exit the loop if the elements are all used up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 /* elt gets the alist element or symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 eltstring gets the name to check as a completion. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 Lisp_Object elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 Lisp_Object eltstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 if (list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 if (NILP (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 elt = Fcar (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 eltstring = Fcar (elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 tail = Fcdr (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 if (!ZEROP (bucket))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
390 Lisp_Symbol *next;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 if (!SYMBOLP (bucket))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 signal_simple_error ("Bad obarray passed to try-completions",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 bucket);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 next = symbol_next (XSYMBOL (bucket));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 elt = bucket;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 eltstring = Fsymbol_name (elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 if (next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 XSETSYMBOL (bucket, next);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 bucket = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 else if (++indice >= obsize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 bucket = XVECTOR_DATA (alist)[indice];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 /* Is this element a possible completion? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 if (STRINGP (eltstring))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 Charcount eltlength = XSTRING_CHAR_LENGTH (eltstring);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 if (slength <= eltlength
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 && (0 > scmp (XSTRING_DATA (eltstring),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 XSTRING_DATA (string),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 slength)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 int loser;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 GCPRO4 (tail, string, eltstring, bestmatch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 loser = ignore_completion_p (eltstring, pred, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 if (loser) /* reject this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 /* Update computation of how much all possible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 completions match */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 matchcount++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 if (NILP (bestmatch))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 bestmatch = eltstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 blength = eltlength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 bestmatchsize = eltlength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 Charcount compare = min (bestmatchsize, eltlength);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 Charcount matchsize =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 scmp (XSTRING_DATA (bestmatch),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 XSTRING_DATA (eltstring),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 compare);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 if (matchsize < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 matchsize = compare;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 if (completion_ignore_case)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 /* If this is an exact match except for case,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 use it as the best match rather than one that is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 an exact match. This way, we get the case pattern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 of the actual match. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 if ((matchsize == eltlength
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 && matchsize < blength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 /* If there is more than one exact match ignoring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 case, and one of them is exact including case,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 prefer that one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 /* If there is no exact match ignoring case,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 prefer a match that does not change the case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 of the input. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 ((matchsize == eltlength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 ==
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 (matchsize == blength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 && 0 > scmp_1 (XSTRING_DATA (eltstring),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 XSTRING_DATA (string),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 slength, 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 && 0 <= scmp_1 (XSTRING_DATA (bestmatch),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 XSTRING_DATA (string),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 slength, 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 bestmatch = eltstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 blength = eltlength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 bestmatchsize = matchsize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 if (NILP (bestmatch))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 return Qnil; /* No completions found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 /* If we are ignoring case, and there is no exact match,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 and no additional text was supplied,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 don't change the case of what the user typed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 if (completion_ignore_case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 && bestmatchsize == slength
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 && blength > bestmatchsize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 return string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 /* Return t if the supplied string is an exact match (counting case);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 it does not require any change to be made. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 if (matchcount == 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 && bestmatchsize == slength
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 && 0 > scmp_1 (XSTRING_DATA (bestmatch),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 XSTRING_DATA (string),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 bestmatchsize, 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 /* Else extract the part in which all completions agree */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 DEFUN ("all-completions", Fall_completions, 2, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 Search for partial matches to STRING in ALIST.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 Each car of each element of ALIST is tested to see if it begins with STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 The value is a list of all the strings from ALIST that match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 ALIST can be an obarray instead of an alist.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 Then the print names of all symbols in the obarray are the possible matches.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 ALIST can also be a function to do the completion itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 It receives three arguments: the values STRING, PREDICATE and t.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 Whatever it returns becomes the value of `all-completions'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 If optional third argument PREDICATE is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 it is used to test each possible match.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 The match is a candidate only if PREDICATE returns non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 The argument given to PREDICATE is the alist element or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 the symbol from the obarray.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 (string, alist, pred))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 Lisp_Object allmatches;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 int list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 int indice = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 int obsize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 Lisp_Object bucket;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 Charcount slength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 CHECK_STRING (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 if (CONSP (alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 Lisp_Object tem = XCAR (alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 if (SYMBOLP (tem)) /* lambda, autoload, etc. Emacs-lisp sucks */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 return call3 (alist, string, pred, Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 list = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 else if (VECTORP (alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 list = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 else if (NILP (alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 list = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 return call3 (alist, string, pred, Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 allmatches = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 slength = XSTRING_CHAR_LENGTH (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 /* If ALIST is not a list, set TAIL just for gc pro. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 tail = alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 if (!list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 obsize = XVECTOR_LENGTH (alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 bucket = XVECTOR_DATA (alist)[indice];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 else /* warning suppression */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 obsize = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 bucket = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 /* Get the next element of the alist or obarray. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 /* Exit the loop if the elements are all used up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 /* elt gets the alist element or symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 eltstring gets the name to check as a completion. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 Lisp_Object elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 Lisp_Object eltstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 if (list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 if (NILP (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 elt = Fcar (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 eltstring = Fcar (elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 tail = Fcdr (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 if (!ZEROP (bucket))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
593 Lisp_Symbol *next = symbol_next (XSYMBOL (bucket));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 elt = bucket;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 eltstring = Fsymbol_name (elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 if (next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 XSETSYMBOL (bucket, next);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 bucket = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 else if (++indice >= obsize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 bucket = XVECTOR_DATA (alist)[indice];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 /* Is this element a possible completion? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 if (STRINGP (eltstring)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 && (slength <= XSTRING_CHAR_LENGTH (eltstring))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 /* Reject alternatives that start with space
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 unless the input starts with space. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 && ((XSTRING_CHAR_LENGTH (string) > 0 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 string_char (XSTRING (string), 0) == ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 || string_char (XSTRING (eltstring), 0) != ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 && (0 > scmp (XSTRING_DATA (eltstring),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 XSTRING_DATA (string),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 slength)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 /* Yes. Now check whether predicate likes it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 int loser;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 GCPRO4 (tail, eltstring, allmatches, string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 loser = ignore_completion_p (eltstring, pred, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 if (!loser)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 /* Ok => put it on the list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 allmatches = Fcons (eltstring, allmatches);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 return Fnreverse (allmatches);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 /* Useless FSFmacs functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 /* More than useless. I've nuked minibuf_prompt_width so they won't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 function at all in XEmacs at the moment. They are used to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 implement some braindamage in FSF which we aren't including. --cet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 xxDEFUN ("minibuffer-prompt", Fminibuffer_prompt, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 Return the prompt string of the currently-active minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 If no minibuffer is active, return nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 return Fcopy_sequence (Vminibuf_prompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 xxDEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 Return the display width of the minibuffer prompt.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 return make_int (minibuf_prompt_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 #endif /* 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 /* echo area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 extern int stdout_needs_newline;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 clear_echo_area_internal (struct frame *f, Lisp_Object label, int from_print,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 int no_restore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 if (!NILP (Ffboundp (Qclear_message)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 return call4 (Qclear_message, label, frame, from_print ? Qt : Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 no_restore ? Qt : Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 write_string_to_stdio_stream (stderr, 0, (const Bufbyte *) "\n", 0, 1,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 Qterminal, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 clear_echo_area (struct frame *f, Lisp_Object label, int no_restore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 return clear_echo_area_internal (f, label, 0, no_restore);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 clear_echo_area_from_print (struct frame *f, Lisp_Object label, int no_restore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 return clear_echo_area_internal (f, label, 1, no_restore);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 echo_area_append (struct frame *f, const Bufbyte *nonreloc, Lisp_Object reloc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 Bytecount offset, Bytecount length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 Lisp_Object label)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 Lisp_Object obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
714 /* There is an inlining bug in egcs-20000131 c++ that can be worked
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
715 around as follows: */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
716 #if defined (__GNUC__) && defined (__cplusplus)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
717 alloca (4);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
718 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
719
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 /* some callers pass in a null string as a way of clearing the echo area.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 check for length == 0 now; if this case, neither nonreloc nor reloc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 may be valid. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 if (length == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 fixup_internal_substring (nonreloc, reloc, offset, &length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 /* also check it here, in case the string was really blank. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 if (length == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 if (!NILP (Ffboundp (Qappend_message)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 if (STRINGP (reloc) && offset == 0 && length == XSTRING_LENGTH (reloc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 obj = reloc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 if (STRINGP (reloc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 nonreloc = XSTRING_DATA (reloc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 obj = make_string (nonreloc + offset, length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 GCPRO1 (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 call4 (Qappend_message, label, obj, frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 EQ (label, Qprint) ? Qt : Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 if (STRINGP (reloc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 nonreloc = XSTRING_DATA (reloc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 write_string_to_stdio_stream (stderr, 0, nonreloc, offset, length,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
754 Qterminal, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
759 echo_area_message (struct frame *f, const Bufbyte *nonreloc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 Lisp_Object reloc, Bytecount offset, Bytecount length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 Lisp_Object label)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 clear_echo_area (f, label, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 echo_area_append (f, nonreloc, reloc, offset, length, label);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 echo_area_active (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 /* By definition, the echo area is active if the echo-area buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 is not empty. No need to call Lisp code. (Anyway, this function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 is called from redisplay.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 struct buffer *echo_buffer = XBUFFER (Vecho_area_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 return BUF_BEGV (echo_buffer) != BUF_ZV (echo_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 echo_area_status (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 if (!NILP (Ffboundp (Qcurrent_message_label)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 return call1 (Qcurrent_message_label, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 return stdout_needs_newline ? Qmessage : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 echo_area_contents (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 /* See above. By definition, the contents of the echo-area buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 are the contents of the echo area. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 return Fbuffer_substring (Qnil, Qnil, Vecho_area_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 /* Dump an informative message to the echo area. This function takes a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 string in internal format. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
804 message_internal (const Bufbyte *nonreloc, Lisp_Object reloc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 Bytecount offset, Bytecount length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 if (NILP (Vexecuting_macro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 echo_area_message (selected_frame (), nonreloc, reloc, offset, length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 Qmessage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814 message_append_internal (const Bufbyte *nonreloc, Lisp_Object reloc,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 Bytecount offset, Bytecount length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 if (NILP (Vexecuting_macro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 echo_area_append (selected_frame (), nonreloc, reloc, offset, length,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 Qmessage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 /* The next three functions are interfaces to message_internal() that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 take strings in external format. message() does I18N3 translating
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 on the format string; message_no_translate() does not. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
828 message_1 (const char *fmt, va_list args)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 if (fmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 /* message_internal() might GC, e.g. if there are after-change-hooks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 on the echo area buffer */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
836 Lisp_Object obj = emacs_doprnt_string_va ((const Bufbyte *) fmt, Qnil,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 -1, args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 GCPRO1 (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 message_internal (0, obj, 0, -1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 message_internal (0, Qnil, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
847 message_append_1 (const char *fmt, va_list args)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 if (fmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 /* message_internal() might GC, e.g. if there are after-change-hooks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 on the echo area buffer */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
855 Lisp_Object obj = emacs_doprnt_string_va ((const Bufbyte *) fmt, Qnil,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 -1, args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 GCPRO1 (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 message_append_internal (0, obj, 0, -1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 message_append_internal (0, Qnil, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 clear_message (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 message_internal (0, Qnil, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
873 message (const char *fmt, ...)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 /* I think it's OK to pass the data of Lisp strings as arguments to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 this function. No GC'ing will occur until the data has already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 been copied. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 va_list args;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 va_start (args, fmt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 if (fmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 fmt = GETTEXT (fmt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 message_1 (fmt, args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 va_end (args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
889 message_append (const char *fmt, ...)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 va_list args;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 va_start (args, fmt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 if (fmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 fmt = GETTEXT (fmt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 message_append_1 (fmt, args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 va_end (args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
902 message_no_translate (const char *fmt, ...)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 /* I think it's OK to pass the data of Lisp strings as arguments to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 this function. No GC'ing will occur until the data has already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 been copied. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 va_list args;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 va_start (args, fmt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 message_1 (fmt, args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 va_end (args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 syms_of_minibuf (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 defsymbol (&Qminibuffer_setup_hook, "minibuffer-setup-hook");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 defsymbol (&Qcompletion_ignore_case, "completion-ignore-case");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 DEFSUBR (Fminibuffer_depth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 DEFSUBR (Fminibuffer_prompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 DEFSUBR (Fminibuffer_prompt_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 DEFSUBR (Fset_minibuffer_preprompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 DEFSUBR (Fread_minibuffer_internal);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 DEFSUBR (Ftry_completion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 DEFSUBR (Fall_completions);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 defsymbol (&Qappend_message, "append-message");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 defsymbol (&Qclear_message, "clear-message");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 defsymbol (&Qdisplay_message, "display-message");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 defsymbol (&Qcurrent_message_label, "current-message-label");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 reinit_vars_of_minibuf (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 minibuf_level = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 vars_of_minibuf (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 reinit_vars_of_minibuf ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 staticpro (&Vminibuf_prompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 Vminibuf_prompt = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 /* Added by Jareth Hein (jhod@po.iijnet.or.jp) for input system support */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 staticpro (&Vminibuf_preprompt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 Vminibuf_preprompt = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 Normal hook run just after entry to minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 Vminibuffer_setup_hook = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 Non-nil means don't consider case significant in completion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 completion_ignore_case = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 DEFVAR_LISP ("completion-regexp-list", &Vcompletion_regexp_list /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 List of regexps that should restrict possible completions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 Each completion has to match all regexps in this list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 Vcompletion_regexp_list = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 reinit_complex_vars_of_minibuf (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 /* #### This needs to be fixed up so that the gettext() gets called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 at runtime instead of at load time. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 Vminibuffer_zero
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 = Fget_buffer_create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 (build_string (DEFER_GETTEXT (" *Minibuf-0*")));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 Vecho_area_buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 = Fget_buffer_create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 (build_string (DEFER_GETTEXT (" *Echo Area*")));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 complex_vars_of_minibuf (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 reinit_complex_vars_of_minibuf ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 }