bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: capitalize-word can't see thru the ' quote mark in text-mode


From: Stefan Monnier
Subject: Re: capitalize-word can't see thru the ' quote mark in text-mode
Date: 08 May 2001 12:00:02 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.103

>>>>> "Dan" == Dan Jacobson <jidanni@kimo.FiXcomTHiS.tw> writes:
> In text-mode, putting the cursor at the beginning of this line 'bla'
> and hitting ESC c [capitalize-word] has no effect. The " and ` quote
> marks are OK though.  Maybe there was fear of creating Can'T when
> invoked as ESC 2 ESC c ... well, at least the first word encountered
> should be assumed intentional and capitalized.

This is a known bug (it popped up in this newsgroup maybe a year ago).
But it's not so easy to solve satisfactorily because of the way
`capitalize' is implemented.
As for forcing capitalization of the "first word", it's rather inconvenient
because even if people don't do M-2 M-c, they do things like M-c M-c M-c
and also expect it to work.

My best effort so far is to define capitalize slightly differently:
instead of changing the case of the first letter of words, have it
change the case of the first letter that can be capitalized.
For example, currently (capitalize "2u") returns "2u", whereas with
the patch below it returns "2U" because "2" does not have upcase/downcase
variants.  Similarly the single quote does not have variants, so
(capitalize "can't you 'see'?") correctly returns "Can't You 'See'?".

But this might create unexpected behaviors, I'm sure.


        Stefan


--- casefiddle.c.~1.37.~        Wed Jan 24 10:33:32 2001
+++ casefiddle.c        Tue May  8 11:51:14 2001
@@ -31,6 +31,10 @@
 
 Lisp_Object Qidentity;
 
+
+#define INWORDP(c)\
+  (SYNTAX (c) == Sword && (inword || UPCASE (c) != DOWNCASE (c)))
+
 Lisp_Object
 casify_object (flag, obj)
      enum case_action flag;
@@ -91,7 +95,7 @@
 
              XSTRING (obj)->data[i] = c;
              if ((int) flag >= (int) CASE_CAPITALIZE)
-               inword = SYNTAX (c) == Sword;
+               inword = INWORDP (c);
              i++;
            }
 
@@ -121,7 +125,7 @@
                  i += fromlen;
                  j_byte += CHAR_STRING (c, buf + j_byte);
                  if ((int) flag >= (int) CASE_CAPITALIZE)
-                   inword = SYNTAX (c) == Sword;
+                   inword = INWORDP (c);
                }
              obj = make_multibyte_string (buf, XSTRING (obj)->size,
                                           j_byte);
@@ -226,7 +230,7 @@
       if (c != c2)
        changed = 1;
       if ((int) flag >= (int) CASE_CAPITALIZE)
-       inword = SYNTAX (c) == Sword;
+       inword = INWORDP (c);
     }
   if (i < end_byte)
     {
@@ -277,7 +281,7 @@
                }
            }
          if ((int) flag >= (int) CASE_CAPITALIZE)
-           inword = SYNTAX (c2) == Sword;
+           inword = INWORDP (c);
          INC_BOTH (start, i);
        }
       TEMP_SET_PT_BOTH (opoint, opoint_byte);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]