+/* Used to signal a user-friendly error when symbol WRONG is
+ not a member of CHOICE, which should be a list of symbols. */
+
+void
+wrong_choice (Lisp_Object choice, Lisp_Object wrong)
+{
+ ptrdiff_t i = 0, len = XINT (Flength (choice));
+ Lisp_Object obj, *args;
+ AUTO_STRING (one_of, "One of ");
+ AUTO_STRING (comma, ", ");
+ AUTO_STRING (or, " or ");
+ AUTO_STRING (should_be_specified, " should be specified");
+
+ USE_SAFE_ALLOCA;
+ SAFE_ALLOCA_LISP (args, len * 2 + 1);
+
+ args[i++] = one_of;
+
+ for (obj = choice; !NILP (obj); obj = XCDR (obj))
+ {
+ args[i++] = SYMBOL_NAME (XCAR (obj));
+ args[i++] = (NILP (XCDR (obj)) ? should_be_specified
+ : NILP (XCDR (XCDR (obj))) ? or : comma);
+ }
+
+ obj = Fconcat (i, args);
+ SAFE_FREE ();
+ xsignal2 (Qerror, obj, wrong);
+}
+
+/* Used to signal a user-friendly error if WRONG is not a number or
+ integer/floating-point number outsize of inclusive MIN..MAX range. */
+
+static void
+wrong_range (Lisp_Object min, Lisp_Object max, Lisp_Object wrong)
+{
+ AUTO_STRING (value_should_be_from, "Value should be from ");
+ AUTO_STRING (to, " to ");
+ xsignal2 (Qerror,
+ Fconcat (4, ((Lisp_Object [])
+ {value_should_be_from, Fnumber_to_string (min),
+ to, Fnumber_to_string (max)})),
+ wrong);
+}
+