diff --git a/src/minibuf.c b/src/minibuf.c index f957b2ae17..44852127ed 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -657,6 +657,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method))) call1 (Qactivate_input_method, input_method); + Vstart_display_at_beginning_of_minibuffer = Qnil; + run_hook (Qminibuffer_setup_hook); /* Don't allow the user to undo past this point. */ @@ -2097,6 +2099,15 @@ syms_of_minibuf (void) uses to hide passwords. */); Vread_hide_char = Qnil; + DEFVAR_LISP ("start-display-at-beginning-of-minibuffer", Vstart_display_at_beginning_of_minibuffer, + doc: /* Whether to preferably display the beginning of the minibuffer. +When the mini-window is not large enough to display the complete minibuffer, +the default behavior is to display the last part of the minibuffer and to +hide its first part. This variable reverses that behavior. This variable +is reset when the minibuffer is entered, and must be set in +`minibuffer-setup-hook'. */); + Vstart_display_at_beginning_of_minibuffer = Qnil; + defsubr (&Sactive_minibuffer_window); defsubr (&Sset_minibuffer_window); defsubr (&Sread_from_minibuffer); diff --git a/src/xdisp.c b/src/xdisp.c index 49225c56fe..1b1a34b97f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11804,7 +11804,7 @@ resize_mini_window (struct window *w, bool exact_p) } /* Compute a suitable window start. */ - if (height > max_height) + if (height > max_height && !EQ (Vstart_display_at_beginning_of_minibuffer, Qt)) { height = (max_height / unit) * unit; init_iterator (&it, w, ZV, ZV_BYTE, NULL, DEFAULT_FACE_ID); @@ -11812,7 +11812,10 @@ resize_mini_window (struct window *w, bool exact_p) start = it.current.pos; } else - SET_TEXT_POS (start, BEGV, BEGV_BYTE); + { + if (height > max_height) height = (max_height / unit) * unit; + SET_TEXT_POS (start, BEGV, BEGV_BYTE); + } SET_MARKER_FROM_TEXT_POS (w->start, start);