annotate src/minibuf.c @ 282:c42ec1d1cded r21-0b39

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