(init_filelock): Always copy lock_path.
[bpt/emacs.git] / src / casefiddle.c
index 5597ba6..f4f2e2a 100644 (file)
@@ -36,19 +36,19 @@ casify_object (flag, obj)
 
   while (1)
     {
-      if (XTYPE (obj) == Lisp_Int)
+      if (INTEGERP (obj))
        {
          c = XINT (obj);
          if (c >= 0 && c <= 0400)
            {
              if (inword)
-               XFASTINT (obj) = DOWNCASE (c);
+               XSETFASTINT (obj, DOWNCASE (c));
              else if (!UPPERCASEP (c))
-               XFASTINT (obj) = UPCASE1 (c);
+               XSETFASTINT (obj, UPCASE1 (c));
            }
          return obj;
        }
-      if (XTYPE (obj) == Lisp_String)
+      if (STRINGP (obj))
        {
          obj = Fcopy_sequence (obj);
          len = XSTRING (obj)->size;
@@ -73,7 +73,8 @@ casify_object (flag, obj)
 DEFUN ("upcase", Fupcase, Supcase, 1, 1, 0,
   "Convert argument to upper case and return that.\n\
 The argument may be a character or string.  The result has the same type.\n\
-The argument object is not altered.  See also `capitalize'.")
+The argument object is not altered--the value is a copy.\n\
+See also `capitalize', `downcase' and `upcase-initials'.")
   (obj)
      Lisp_Object obj;
 {
@@ -83,7 +84,7 @@ The argument object is not altered.  See also `capitalize'.")
 DEFUN ("downcase", Fdowncase, Sdowncase, 1, 1, 0,
   "Convert argument to lower case and return that.\n\
 The argument may be a character or string.  The result has the same type.\n\
-The argument object is not altered.")
+The argument object is not altered--the value is a copy.")
   (obj)
      Lisp_Object obj;
 {
@@ -95,13 +96,24 @@ DEFUN ("capitalize", Fcapitalize, Scapitalize, 1, 1, 0,
 This means that each word's first character is upper case\n\
 and the rest is lower case.\n\
 The argument may be a character or string.  The result has the same type.\n\
-The argument object is not altered.")
+The argument object is not altered--the value is a copy.")
   (obj)
      Lisp_Object obj;
 {
   return casify_object (CASE_CAPITALIZE, obj);
 }
 
+DEFUN ("upcase-initials", Fupcase_initials, Supcase_initials, 1, 1, 0,
+  "Convert the initial of each word in the argument to upper case.\n\
+Do not change the other letters of each word.\n\
+The argument may be a character or string.  The result has the same type.\n\
+The argument object is not altered--the value is a copy.")
+  (obj)
+     Lisp_Object obj;
+{
+  return casify_object (CASE_CAPITALIZE_UP, obj);
+}
+
 /* Like Fcapitalize but change only the initials.  */
 
 Lisp_Object
@@ -186,6 +198,19 @@ character positions to operate on.")
   return Qnil;
 }
 
+DEFUN ("upcase-initials-region", Fupcase_initials_region,
+       Supcase_initials_region, 2, 2, "r",
+  "Upcase the initial of each word in the region.\n\
+Subsequent letters of each word are not changed.\n\
+In programs, give two arguments, the starting and ending\n\
+character positions to operate on.")
+  (b, e)
+     Lisp_Object b, e;
+{
+  casify_region (CASE_CAPITALIZE_UP, b, e);
+  return Qnil;
+}
+
 /* Like Fcapitalize_region but change only the initials.  */
 
 Lisp_Object
@@ -210,7 +235,7 @@ operate_on_word (arg, newpoint)
     farend = XINT (arg) > 0 ? ZV : BEGV;
 
   *newpoint = point > farend ? point : farend;
-  XFASTINT (val) = farend;
+  XSETFASTINT (val, farend);
 
   return val;
 }
@@ -224,7 +249,7 @@ See also `capitalize-word'.")
 {
   Lisp_Object beg, end;
   int newpoint;
-  XFASTINT (beg) = point;
+  XSETFASTINT (beg, point);
   end = operate_on_word (arg, &newpoint);
   casify_region (CASE_UP, beg, end);
   SET_PT (newpoint);
@@ -239,7 +264,7 @@ With negative argument, convert previous words but do not move.")
 {
   Lisp_Object beg, end;
   int newpoint;
-  XFASTINT (beg) = point;
+  XSETFASTINT (beg, point);
   end = operate_on_word (arg, &newpoint);
   casify_region (CASE_DOWN, beg, end);
   SET_PT (newpoint);
@@ -256,7 +281,7 @@ With negative argument, capitalize previous words but do not move.")
 {
   Lisp_Object beg, end;
   int newpoint;
-  XFASTINT (beg) = point;
+  XSETFASTINT (beg, point);
   end = operate_on_word (arg, &newpoint);
   casify_region (CASE_CAPITALIZE, beg, end);
   SET_PT (newpoint);
@@ -268,9 +293,11 @@ syms_of_casefiddle ()
   defsubr (&Supcase);
   defsubr (&Sdowncase);
   defsubr (&Scapitalize);
+  defsubr (&Supcase_initials);
   defsubr (&Supcase_region);
   defsubr (&Sdowncase_region);
   defsubr (&Scapitalize_region);
+  defsubr (&Supcase_initials_region);
   defsubr (&Supcase_word);
   defsubr (&Sdowncase_word);
   defsubr (&Scapitalize_word);