diff options
| author | Richard M. Stallman | 1996-04-07 16:43:51 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-04-07 16:43:51 +0000 |
| commit | 748dc60a0ec333b98876303c14c102f2642a23dd (patch) | |
| tree | cb11aea2765677cb3ddcd2b694ffee756466abc0 /src | |
| parent | a0e06fd0c10e26e809c82df235db6b03909aecf9 (diff) | |
| download | emacs-748dc60a0ec333b98876303c14c102f2642a23dd.tar.gz emacs-748dc60a0ec333b98876303c14c102f2642a23dd.zip | |
(read_minibuf): Rearrange operations, mainly putting
the read_minibuf_unwind setup and the associated variable changes
together after saving the frame configuration.
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index 2abb46710e5..24cabccee30 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -175,7 +175,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 175 | { | 175 | { |
| 176 | Lisp_Object val; | 176 | Lisp_Object val; |
| 177 | int count = specpdl_ptr - specpdl; | 177 | int count = specpdl_ptr - specpdl; |
| 178 | Lisp_Object mini_frame; | 178 | Lisp_Object mini_frame, ambient_dir; |
| 179 | struct gcpro gcpro1, gcpro2, gcpro3; | 179 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 180 | 180 | ||
| 181 | single_kboard_state (); | 181 | single_kboard_state (); |
| @@ -194,23 +194,9 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 194 | && (EQ (selected_window, minibuf_window))) | 194 | && (EQ (selected_window, minibuf_window))) |
| 195 | error ("Command attempted to use minibuffer while in minibuffer"); | 195 | error ("Command attempted to use minibuffer while in minibuffer"); |
| 196 | 196 | ||
| 197 | /* Could we simply bind these variables instead? */ | 197 | ambient_dir = current_buffer->directory; |
| 198 | minibuf_save_list | ||
| 199 | = Fcons (Voverriding_local_map, | ||
| 200 | Fcons (minibuf_window, minibuf_save_list)); | ||
| 201 | minibuf_save_list | ||
| 202 | = Fcons (minibuf_prompt, | ||
| 203 | Fcons (make_number (minibuf_prompt_width), | ||
| 204 | Fcons (Vhelp_form, | ||
| 205 | Fcons (Vcurrent_prefix_arg, | ||
| 206 | Fcons (Vminibuffer_history_position, | ||
| 207 | Fcons (Vminibuffer_history_variable, | ||
| 208 | minibuf_save_list)))))); | ||
| 209 | 198 | ||
| 210 | minibuf_prompt_width = 0; /* xdisp.c puts in the right value. */ | 199 | /* Choose the minibuffer window and frame, and take action on them. */ |
| 211 | minibuf_prompt = Fcopy_sequence (prompt); | ||
| 212 | Vminibuffer_history_position = histpos; | ||
| 213 | Vminibuffer_history_variable = histvar; | ||
| 214 | 200 | ||
| 215 | choose_minibuf_frame (); | 201 | choose_minibuf_frame (); |
| 216 | 202 | ||
| @@ -233,7 +219,37 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 233 | Fraise_frame (mini_frame); | 219 | Fraise_frame (mini_frame); |
| 234 | #endif | 220 | #endif |
| 235 | 221 | ||
| 236 | val = current_buffer->directory; | 222 | /* We have to do this after saving the window configuration |
| 223 | since that is what restores the current buffer. */ | ||
| 224 | |||
| 225 | /* Arrange to restore a number of minibuffer-related variables. | ||
| 226 | We could bind each variable separately, but that would use lots of | ||
| 227 | specpdl slots. */ | ||
| 228 | minibuf_save_list | ||
| 229 | = Fcons (Voverriding_local_map, | ||
| 230 | Fcons (minibuf_window, minibuf_save_list)); | ||
| 231 | minibuf_save_list | ||
| 232 | = Fcons (minibuf_prompt, | ||
| 233 | Fcons (make_number (minibuf_prompt_width), | ||
| 234 | Fcons (Vhelp_form, | ||
| 235 | Fcons (Vcurrent_prefix_arg, | ||
| 236 | Fcons (Vminibuffer_history_position, | ||
| 237 | Fcons (Vminibuffer_history_variable, | ||
| 238 | minibuf_save_list)))))); | ||
| 239 | |||
| 240 | record_unwind_protect (read_minibuf_unwind, Qnil); | ||
| 241 | minibuf_level++; | ||
| 242 | |||
| 243 | /* Now that we can restore all those variables, start changing them. */ | ||
| 244 | |||
| 245 | minibuf_prompt_width = 0; /* xdisp.c puts in the right value. */ | ||
| 246 | minibuf_prompt = Fcopy_sequence (prompt); | ||
| 247 | Vminibuffer_history_position = histpos; | ||
| 248 | Vminibuffer_history_variable = histvar; | ||
| 249 | Vhelp_form = Vminibuffer_help_form; | ||
| 250 | |||
| 251 | /* Switch to the minibuffer. */ | ||
| 252 | |||
| 237 | Fset_buffer (get_minibuffer (minibuf_level)); | 253 | Fset_buffer (get_minibuffer (minibuf_level)); |
| 238 | 254 | ||
| 239 | /* The current buffer's default directory is usually the right thing | 255 | /* The current buffer's default directory is usually the right thing |
| @@ -244,8 +260,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 244 | up Emacs and buf's default directory is Qnil. Here's a hack; can | 260 | up Emacs and buf's default directory is Qnil. Here's a hack; can |
| 245 | you think of something better to do? Find another buffer with a | 261 | you think of something better to do? Find another buffer with a |
| 246 | better directory, and use that one instead. */ | 262 | better directory, and use that one instead. */ |
| 247 | if (STRINGP (val)) | 263 | if (STRINGP (ambient_dir)) |
| 248 | current_buffer->directory = val; | 264 | current_buffer->directory = ambient_dir; |
| 249 | else | 265 | else |
| 250 | { | 266 | { |
| 251 | Lisp_Object buf_list; | 267 | Lisp_Object buf_list; |
| @@ -269,16 +285,16 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 269 | if (XFRAME (mini_frame) != selected_frame) | 285 | if (XFRAME (mini_frame) != selected_frame) |
| 270 | Fredirect_frame_focus (Fselected_frame (), mini_frame); | 286 | Fredirect_frame_focus (Fselected_frame (), mini_frame); |
| 271 | #endif | 287 | #endif |
| 272 | Fmake_local_variable (Qprint_escape_newlines); | ||
| 273 | print_escape_newlines = 1; | ||
| 274 | |||
| 275 | record_unwind_protect (read_minibuf_unwind, Qnil); | ||
| 276 | 288 | ||
| 277 | Vminibuf_scroll_window = selected_window; | 289 | Vminibuf_scroll_window = selected_window; |
| 278 | Fset_window_buffer (minibuf_window, Fcurrent_buffer ()); | 290 | Fset_window_buffer (minibuf_window, Fcurrent_buffer ()); |
| 279 | Fselect_window (minibuf_window); | 291 | Fselect_window (minibuf_window); |
| 280 | XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0); | 292 | XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0); |
| 281 | 293 | ||
| 294 | Fmake_local_variable (Qprint_escape_newlines); | ||
| 295 | print_escape_newlines = 1; | ||
| 296 | |||
| 297 | /* Erase the buffer. */ | ||
| 282 | { | 298 | { |
| 283 | int count1 = specpdl_ptr - specpdl; | 299 | int count1 = specpdl_ptr - specpdl; |
| 284 | specbind (Qinhibit_read_only, Qt); | 300 | specbind (Qinhibit_read_only, Qt); |
| @@ -286,8 +302,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 286 | unbind_to (count1, Qnil); | 302 | unbind_to (count1, Qnil); |
| 287 | } | 303 | } |
| 288 | 304 | ||
| 289 | minibuf_level++; | 305 | /* Put in the initial input. */ |
| 290 | |||
| 291 | if (!NILP (initial)) | 306 | if (!NILP (initial)) |
| 292 | { | 307 | { |
| 293 | Finsert (1, &initial); | 308 | Finsert (1, &initial); |
| @@ -299,12 +314,11 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 299 | /* This is in case the minibuffer-setup-hook calls Fsit_for. */ | 314 | /* This is in case the minibuffer-setup-hook calls Fsit_for. */ |
| 300 | previous_echo_glyphs = 0; | 315 | previous_echo_glyphs = 0; |
| 301 | 316 | ||
| 302 | Vhelp_form = Vminibuffer_help_form; | ||
| 303 | current_buffer->keymap = map; | 317 | current_buffer->keymap = map; |
| 304 | 318 | ||
| 305 | /* Run our hook, but not if it is empty. | 319 | /* Run our hook, but not if it is empty. |
| 306 | (run-hooks would do nothing if it is empty, | 320 | (run-hooks would do nothing if it is empty, |
| 307 | but it's important to save time here in the usual case. */ | 321 | but it's important to save time here in the usual case). */ |
| 308 | if (!NILP (Vminibuffer_setup_hook) && !EQ (Vminibuffer_setup_hook, Qunbound) | 322 | if (!NILP (Vminibuffer_setup_hook) && !EQ (Vminibuffer_setup_hook, Qunbound) |
| 309 | && !NILP (Vrun_hooks)) | 323 | && !NILP (Vrun_hooks)) |
| 310 | call1 (Vrun_hooks, Qminibuffer_setup_hook); | 324 | call1 (Vrun_hooks, Qminibuffer_setup_hook); |