changeset 46877:2ff0df63c873

(Fminibufferp): New function. (syms_of_minibuf): Defsubr it. (Fminibuffer_prompt_end): Handle non-minibuffers specially.
author Richard M. Stallman <rms@gnu.org>
date Tue, 13 Aug 2002 22:52:05 +0000
parents 99501febdd3f
children 901426f0ae5f
files src/minibuf.c
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/minibuf.c	Tue Aug 13 19:12:46 2002 +0000
+++ b/src/minibuf.c	Tue Aug 13 22:52:05 2002 +0000
@@ -318,6 +318,17 @@
   return val;
 }
 
+DEFUN ("minibufferp", Fminibufferp,
+       Sminibufferp, 0, 0, 0,
+       doc: /* Return t if the current buffer is a minibuffer.  */)
+     ()
+{
+  Lisp_Object tem;
+
+  tem = Fmemq (Fcurrent_buffer (), Vminibuffer_list);
+  return ! NILP (tem) ? Qt : Qnil;
+}
+
 DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
        Sminibuffer_prompt_end, 0, 0, 0,
        doc: /* Return the buffer position of the end of the minibuffer prompt.
@@ -325,8 +336,14 @@
      ()
 {
   /* This function is written to be most efficient when there's a prompt.  */
-  Lisp_Object beg = make_number (BEGV);
-  Lisp_Object end = Ffield_end (beg, Qnil, Qnil);
+  Lisp_Object beg, end, tem;
+  beg = make_number (BEGV);
+
+  tem = Fmemq (Fcurrent_buffer (), Vminibuffer_list);
+  if (NILP (tem))
+    return beg;
+
+  end = Ffield_end (beg, Qnil, Qnil);
 
   if (XINT (end) == ZV && NILP (Fget_char_property (beg, Qfield, Qnil)))
     return beg;
@@ -2581,6 +2598,7 @@
   defsubr (&Sminibuffer_depth);
   defsubr (&Sminibuffer_prompt);
 
+  defsubr (&Sminibufferp);
   defsubr (&Sminibuffer_prompt_end);
   defsubr (&Sminibuffer_contents);
   defsubr (&Sminibuffer_contents_no_properties);