/* Random utility Lisp functions.
- Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997,
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include "frame.h"
#include "window.h"
#include "blockinput.h"
-#if defined (HAVE_MENUS) && defined (HAVE_X_WINDOWS)
+#ifdef HAVE_MENUS
+#if defined (HAVE_X_WINDOWS)
#include "xterm.h"
+#elif defined (MAC_OS)
+#include "macterm.h"
+#endif
#endif
#ifndef NULL
extern Lisp_Object Qinput_method_function;
-static int internal_equal ();
+static int internal_equal P_ ((Lisp_Object , Lisp_Object, int, int));
extern long get_random ();
-extern void seed_random ();
+extern void seed_random P_ ((long));
#ifndef HAVE_UNISTD_H
extern long time ();
DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0,
doc: /* Return the number of bytes in STRING.
-If STRING is a multibyte string, this is greater than the length of STRING. */)
+If STRING is multibyte, this may be greater than the length of STRING. */)
(string)
Lisp_Object string;
{
return result;
}
+/* Like Fassoc but never report an error and do not allow quits.
+ Use only on lists known never to be circular. */
+
+Lisp_Object
+assoc_no_quit (key, list)
+ Lisp_Object key, list;
+{
+ while (CONSP (list)
+ && (!CONSP (XCAR (list))
+ || (!EQ (XCAR (XCAR (list)), key)
+ && NILP (Fequal (XCAR (XCAR (list)), key)))))
+ list = XCDR (list);
+
+ return CONSP (list) ? XCAR (list) : Qnil;
+}
+
DEFUN ("rassq", Frassq, Srassq, 2, 2, 0,
doc: /* Return non-nil if KEY is `eq' to the cdr of an element of LIST.
The value is actually the first element of LIST whose cdr is KEY. */)
doc: /* Sort LIST, stably, comparing elements using PREDICATE.
Returns the sorted list. LIST is modified by side effects.
PREDICATE is called with two elements of LIST, and should return non-nil
-if the first element is "less" than the second. */)
+if the first element should sort before the second. */)
(list, predicate)
Lisp_Object list, predicate;
{
if (!internal_equal (OVERLAY_START (o1), OVERLAY_START (o2),
depth + 1, props)
|| !internal_equal (OVERLAY_END (o1), OVERLAY_END (o2),
- depth + 1))
+ depth + 1, props))
return 0;
o1 = XOVERLAY (o1)->plist;
o2 = XOVERLAY (o2)->plist;
{
ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil,
Qyes_or_no_p_history, Qnil,
- Qnil, Qnil));
+ Qnil));
if (SCHARS (ans) == 3 && !strcmp (SDATA (ans), "yes"))
{
UNGCPRO;
CHECK_SYMBOL (feature);
CHECK_LIST (subfeatures);
if (!NILP (Vautoload_queue))
- Vautoload_queue = Fcons (Fcons (Vfeatures, Qnil), Vautoload_queue);
+ Vautoload_queue = Fcons (Fcons (make_number (0), Vfeatures),
+ Vautoload_queue);
tem = Fmemq (feature, Vfeatures);
if (NILP (tem))
Vfeatures = Fcons (feature, Vfeatures);
{
register Lisp_Object tem;
struct gcpro gcpro1, gcpro2;
+ int from_file = load_in_progress;
CHECK_SYMBOL (feature);
/* Record the presence of `require' in this file
even if the feature specified is already loaded.
But not more than once in any file,
- and not when we aren't loading a file. */
- if (load_in_progress)
+ and not when we aren't loading or reading from a file. */
+ if (!from_file)
+ for (tem = Vcurrent_load_list; CONSP (tem); tem = XCDR (tem))
+ if (NILP (XCDR (tem)) && STRINGP (XCAR (tem)))
+ from_file = 1;
+
+ if (from_file)
{
tem = Fcons (Qrequire, feature);
if (NILP (Fmember (tem, Vcurrent_load_list)))
hash = SXHASH_COMBINE (hash, hash2);
}
+ if (!NILP (list))
+ {
+ unsigned hash2 = sxhash (list, depth + 1);
+ hash = SXHASH_COMBINE (hash, hash2);
+ }
+
return hash;
}
DEFVAR_LISP ("features", &Vfeatures,
doc: /* A list of symbols which are the features of the executing emacs.
Used by `featurep' and `require', and altered by `provide'. */);
- Vfeatures = Qnil;
+ Vfeatures = Fcons (intern ("emacs"), Qnil);
Qsubfeatures = intern ("subfeatures");
staticpro (&Qsubfeatures);