Mercurial > hg > xemacs-beta
comparison src/editfns.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 6075d714658b |
children | a2f645c6b9f8 |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
133 slow_down_interrupts (); | 133 slow_down_interrupts (); |
134 pw = (struct passwd *) | 134 pw = (struct passwd *) |
135 getpwnam ((char *) XSTRING_DATA (Vuser_login_name)); | 135 getpwnam ((char *) XSTRING_DATA (Vuser_login_name)); |
136 speed_up_interrupts (); | 136 speed_up_interrupts (); |
137 } | 137 } |
138 | 138 |
139 p = (Bufbyte *) ((pw) ? USER_FULL_NAME : "unknown"); /* don't gettext here */ | 139 p = (Bufbyte *) ((pw) ? USER_FULL_NAME : "unknown"); /* don't gettext here */ |
140 q = (Bufbyte *) strchr ((char *) p, ','); | 140 q = (Bufbyte *) strchr ((char *) p, ','); |
141 Vuser_full_name = make_ext_string (p, (q ? q - p : strlen ((char *) p)), | 141 Vuser_full_name = make_ext_string (p, (q ? q - p : strlen ((char *) p)), |
142 FORMAT_OS); | 142 FORMAT_OS); |
143 | 143 |
144 #ifdef AMPERSAND_FULL_NAME | 144 #ifdef AMPERSAND_FULL_NAME |
145 p = XSTRING_DATA (Vuser_full_name); | 145 p = XSTRING_DATA (Vuser_full_name); |
146 q = (Bufbyte *) strchr ((char *) p, '&'); | 146 q = (Bufbyte *) strchr ((char *) p, '&'); |
147 /* Substitute the login name for the &, upcasing the first character. */ | 147 /* Substitute the login name for the &, upcasing the first character. */ |
148 if (q) | 148 if (q) |
460 if that was true previously. That avoids some anomalies. | 460 if that was true previously. That avoids some anomalies. |
461 But it creates others, and it wasn't documented, and it is simpler | 461 But it creates others, and it wasn't documented, and it is simpler |
462 and cleaner never to alter the window/buffer connections. */ | 462 and cleaner never to alter the window/buffer connections. */ |
463 /* #### I'm certain some code somewhere depends on this behavior. --jwz */ | 463 /* #### I'm certain some code somewhere depends on this behavior. --jwz */ |
464 | 464 |
465 if (visible | 465 if (visible |
466 && (current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))) | 466 && (current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))) |
467 switch_to_buffer (Fcurrent_buffer (), Qnil); | 467 switch_to_buffer (Fcurrent_buffer (), Qnil); |
468 #endif | 468 #endif |
469 | 469 |
470 UNGCPRO; | 470 UNGCPRO; |
487 { | 487 { |
488 /* This function can GC */ | 488 /* This function can GC */ |
489 int speccount = specpdl_depth (); | 489 int speccount = specpdl_depth (); |
490 | 490 |
491 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 491 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
492 | 492 |
493 return unbind_to (speccount, Fprogn (args)); | 493 return unbind_to (speccount, Fprogn (args)); |
494 } | 494 } |
495 | 495 |
496 Lisp_Object | 496 Lisp_Object |
497 save_current_buffer_restore (Lisp_Object buffer) | 497 save_current_buffer_restore (Lisp_Object buffer) |
686 struct buffer *b = decode_buffer (buffer, 1); | 686 struct buffer *b = decode_buffer (buffer, 1); |
687 Bufpos n = ((NILP (pos) ? BUF_PT (b) : | 687 Bufpos n = ((NILP (pos) ? BUF_PT (b) : |
688 get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD))); | 688 get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD))); |
689 | 689 |
690 n--; | 690 n--; |
691 | 691 |
692 if (n < BUF_BEGV (b)) | 692 if (n < BUF_BEGV (b)) |
693 return Qnil; | 693 return Qnil; |
694 return make_char (BUF_FETCH_CHAR (b, n)); | 694 return make_char (BUF_FETCH_CHAR (b, n)); |
695 } | 695 } |
696 | 696 |
780 { | 780 { |
781 Lisp_Object user_name = (STRINGP (user) ? user : Fuser_login_name (user)); | 781 Lisp_Object user_name = (STRINGP (user) ? user : Fuser_login_name (user)); |
782 struct passwd *pw = NULL; | 782 struct passwd *pw = NULL; |
783 Lisp_Object tem; | 783 Lisp_Object tem; |
784 char *p, *q; | 784 char *p, *q; |
785 | 785 |
786 if (!NILP (user_name)) /* nil when nonexistent UID passed as arg */ | 786 if (!NILP (user_name)) /* nil when nonexistent UID passed as arg */ |
787 { | 787 { |
788 CONST char *user_name_ext; | 788 CONST char *user_name_ext; |
789 | 789 |
790 /* Fuck me. getpwnam() can call select() and (under IRIX at least) | 790 /* Fuck me. getpwnam() can call select() and (under IRIX at least) |
791 things get wedged if a SIGIO arrives during this time. */ | 791 things get wedged if a SIGIO arrives during this time. */ |
792 GET_C_STRING_OS_DATA_ALLOCA (user_name, user_name_ext); | 792 GET_C_STRING_OS_DATA_ALLOCA (user_name, user_name_ext); |
793 slow_down_interrupts (); | 793 slow_down_interrupts (); |
794 pw = (struct passwd *) getpwnam (user_name_ext); | 794 pw = (struct passwd *) getpwnam (user_name_ext); |
953 FORMAT-STRING may contain %-sequences to substitute parts of the time. | 953 FORMAT-STRING may contain %-sequences to substitute parts of the time. |
954 %a is replaced by the abbreviated name of the day of week. | 954 %a is replaced by the abbreviated name of the day of week. |
955 %A is replaced by the full name of the day of week. | 955 %A is replaced by the full name of the day of week. |
956 %b is replaced by the abbreviated name of the month. | 956 %b is replaced by the abbreviated name of the month. |
957 %B is replaced by the full name of the month. | 957 %B is replaced by the full name of the month. |
958 %c is a synonym for \"%x %X\". | 958 %c is a synonym for "%x %X". |
959 %C is a locale-specific synonym, which defaults to \"%A, %B %e, %Y\" in the C locale. | 959 %C is a locale-specific synonym, which defaults to "%A, %B %e, %Y" in the C locale. |
960 %d is replaced by the day of month, zero-padded. | 960 %d is replaced by the day of month, zero-padded. |
961 %D is a synonym for \"%m/%d/%y\". | 961 %D is a synonym for "%m/%d/%y". |
962 %e is replaced by the day of month, blank-padded. | 962 %e is replaced by the day of month, blank-padded. |
963 %h is a synonym for \"%b\". | 963 %h is a synonym for "%b". |
964 %H is replaced by the hour (00-23). | 964 %H is replaced by the hour (00-23). |
965 %I is replaced by the hour (00-12). | 965 %I is replaced by the hour (00-12). |
966 %j is replaced by the day of the year (001-366). | 966 %j is replaced by the day of the year (001-366). |
967 %k is replaced by the hour (0-23), blank padded. | 967 %k is replaced by the hour (0-23), blank padded. |
968 %l is replaced by the hour (1-12), blank padded. | 968 %l is replaced by the hour (1-12), blank padded. |
969 %m is replaced by the month (01-12). | 969 %m is replaced by the month (01-12). |
970 %M is replaced by the minute (00-59). | 970 %M is replaced by the minute (00-59). |
971 %n is a synonym for \"\\n\". | 971 %n is a synonym for "\\n". |
972 %p is replaced by AM or PM, as appropriate. | 972 %p is replaced by AM or PM, as appropriate. |
973 %r is a synonym for \"%I:%M:%S %p\". | 973 %r is a synonym for "%I:%M:%S %p". |
974 %R is a synonym for \"%H:%M\". | 974 %R is a synonym for "%H:%M". |
975 %S is replaced by the second (00-60). | 975 %S is replaced by the second (00-60). |
976 %t is a synonym for \"\\t\". | 976 %t is a synonym for "\\t". |
977 %T is a synonym for \"%H:%M:%S\". | 977 %T is a synonym for "%H:%M:%S". |
978 %U is replaced by the week of the year (00-53), first day of week is Sunday. | 978 %U is replaced by the week of the year (00-53), first day of week is Sunday. |
979 %w is replaced by the day of week (0-6), Sunday is day 0. | 979 %w is replaced by the day of week (0-6), Sunday is day 0. |
980 %W is replaced by the week of the year (00-53), first day of week is Monday. | 980 %W is replaced by the week of the year (00-53), first day of week is Monday. |
981 %x is a locale-specific synonym, which defaults to \"%D\" in the C locale. | 981 %x is a locale-specific synonym, which defaults to "%D" in the C locale. |
982 %X is a locale-specific synonym, which defaults to \"%T\" in the C locale. | 982 %X is a locale-specific synonym, which defaults to "%T" in the C locale. |
983 %y is replaced by the year without century (00-99). | 983 %y is replaced by the year without century (00-99). |
984 %Y is replaced by the year with century. | 984 %Y is replaced by the year with century. |
985 %Z is replaced by the time zone abbreviation. | 985 %Z is replaced by the time zone abbreviation. |
986 | 986 |
987 The number of options reflects the `strftime' function. | 987 The number of options reflects the `strftime' function. |
1034 { | 1034 { |
1035 time_t time_spec; | 1035 time_t time_spec; |
1036 struct tm save_tm; | 1036 struct tm save_tm; |
1037 struct tm *decoded_time; | 1037 struct tm *decoded_time; |
1038 Lisp_Object list_args[9]; | 1038 Lisp_Object list_args[9]; |
1039 | 1039 |
1040 if (! lisp_to_time (specified_time, &time_spec)) | 1040 if (! lisp_to_time (specified_time, &time_spec)) |
1041 error ("Invalid time specification"); | 1041 error ("Invalid time specification"); |
1042 | 1042 |
1043 decoded_time = localtime (&time_spec); | 1043 decoded_time = localtime (&time_spec); |
1044 XSETINT (list_args[0], decoded_time->tm_sec); | 1044 XSETINT (list_args[0], decoded_time->tm_sec); |
1102 else | 1102 else |
1103 { | 1103 { |
1104 char tzbuf[100]; | 1104 char tzbuf[100]; |
1105 char *tzstring; | 1105 char *tzstring; |
1106 char **oldenv = environ, **newenv; | 1106 char **oldenv = environ, **newenv; |
1107 | 1107 |
1108 if (STRINGP (zone)) | 1108 if (STRINGP (zone)) |
1109 tzstring = (char *) XSTRING_DATA (zone); | 1109 tzstring = (char *) XSTRING_DATA (zone); |
1110 else if (INTP (zone)) | 1110 else if (INTP (zone)) |
1111 { | 1111 { |
1112 int abszone = abs (XINT (zone)); | 1112 int abszone = abs (XINT (zone)); |
1115 tzstring = tzbuf; | 1115 tzstring = tzbuf; |
1116 } | 1116 } |
1117 else | 1117 else |
1118 error ("Invalid time zone specification"); | 1118 error ("Invalid time zone specification"); |
1119 | 1119 |
1120 /* Set TZ before calling mktime; merely adjusting mktime's returned | 1120 /* Set TZ before calling mktime; merely adjusting mktime's returned |
1121 value doesn't suffice, since that would mishandle leap seconds. */ | 1121 value doesn't suffice, since that would mishandle leap seconds. */ |
1122 set_time_zone_rule (tzstring); | 1122 set_time_zone_rule (tzstring); |
1123 | 1123 |
1124 _time = mktime (&tm); | 1124 _time = mktime (&tm); |
1125 | 1125 |
1449 charlen = set_charptr_emchar (str, XCHAR (chr)); | 1449 charlen = set_charptr_emchar (str, XCHAR (chr)); |
1450 n = cou * charlen; | 1450 n = cou * charlen; |
1451 if (n <= 0) | 1451 if (n <= 0) |
1452 return Qnil; | 1452 return Qnil; |
1453 slen = min (n, 768); | 1453 slen = min (n, 768); |
1454 string = (Bufbyte *) alloca (slen * sizeof (Bufbyte)); | 1454 string = alloca_array (Bufbyte, slen); |
1455 /* Write as many copies of the character into the temp string as will fit. */ | 1455 /* Write as many copies of the character into the temp string as will fit. */ |
1456 for (i = 0; i + charlen <= slen; i += charlen) | 1456 for (i = 0; i + charlen <= slen; i += charlen) |
1457 for (j = 0; j < charlen; j++) | 1457 for (j = 0; j < charlen; j++) |
1458 string[i + j] = str[j]; | 1458 string[i + j] = str[j]; |
1459 slen = i; | 1459 slen = i; |
1834 Bufpos start, end; | 1834 Bufpos start, end; |
1835 Bytind bi_start, bi_end; | 1835 Bytind bi_start, bi_end; |
1836 | 1836 |
1837 start = BUF_BEG (buf) + newhead; | 1837 start = BUF_BEG (buf) + newhead; |
1838 end = BUF_Z (buf) - newtail; | 1838 end = BUF_Z (buf) - newtail; |
1839 | 1839 |
1840 bi_start = bufpos_to_bytind (buf, start); | 1840 bi_start = bufpos_to_bytind (buf, start); |
1841 bi_end = bufpos_to_bytind (buf, end); | 1841 bi_end = bufpos_to_bytind (buf, end); |
1842 | 1842 |
1843 if (BUF_BEGV (buf) != start) | 1843 if (BUF_BEGV (buf) != start) |
1844 { | 1844 { |
1904 %X uppercase hex). | 1904 %X uppercase hex). |
1905 %c means print as a single character. | 1905 %c means print as a single character. |
1906 %f means print as a floating-point number in fixed notation (e.g. 785.200). | 1906 %f means print as a floating-point number in fixed notation (e.g. 785.200). |
1907 %e or %E means print as a floating-point number in scientific notation | 1907 %e or %E means print as a floating-point number in scientific notation |
1908 (e.g. 7.85200e+03). | 1908 (e.g. 7.85200e+03). |
1909 %g or %G means print as a floating-point number in \"pretty format\"; | 1909 %g or %G means print as a floating-point number in "pretty format"; |
1910 depending on the number, either %f or %e/%E format will be used, and | 1910 depending on the number, either %f or %e/%E format will be used, and |
1911 trailing zeroes are removed from the fractional part. | 1911 trailing zeroes are removed from the fractional part. |
1912 The argument used for all but %s and %S must be a number. It will be | 1912 The argument used for all but %s and %S must be a number. It will be |
1913 converted to an integer or a floating-point number as necessary. | 1913 converted to an integer or a floating-point number as necessary. |
1914 | 1914 |
1997 differ in size). | 1997 differ in size). |
1998 | 1998 |
1999 Traverses the entire marker list of the buffer to do so, adding an | 1999 Traverses the entire marker list of the buffer to do so, adding an |
2000 appropriate amount to some, subtracting from some, and leaving the | 2000 appropriate amount to some, subtracting from some, and leaving the |
2001 rest untouched. Most of this is copied from adjust_markers in insdel.c. | 2001 rest untouched. Most of this is copied from adjust_markers in insdel.c. |
2002 | 2002 |
2003 It's the caller's job to see that (start1 <= end1 <= start2 <= end2). */ | 2003 It's the caller's job to see that (start1 <= end1 <= start2 <= end2). */ |
2004 | 2004 |
2005 void | 2005 void |
2006 transpose_markers (Bufpos start1, Bufpos end1, Bufpos start2, Bufpos end2) | 2006 transpose_markers (Bufpos start1, Bufpos end1, Bufpos start2, Bufpos end2) |
2007 { | 2007 { |
2028 position is between GPT and GPT + GAP_SIZE, so it's simpler to leave | 2028 position is between GPT and GPT + GAP_SIZE, so it's simpler to leave |
2029 the dirty work to Fmarker_position, below. */ | 2029 the dirty work to Fmarker_position, below. */ |
2030 | 2030 |
2031 /* The difference between the region's lengths */ | 2031 /* The difference between the region's lengths */ |
2032 diff = (end2 - start2) - (end1 - start1); | 2032 diff = (end2 - start2) - (end1 - start1); |
2033 | 2033 |
2034 /* For shifting each marker in a region by the length of the other | 2034 /* For shifting each marker in a region by the length of the other |
2035 * region plus the distance between the regions. | 2035 * region plus the distance between the regions. |
2036 */ | 2036 */ |
2037 amt1 = (end2 - start2) + (start2 - end1); | 2037 amt1 = (end2 - start2) + (start2 - end1); |
2038 amt2 = (end1 - start1) + (start2 - end1); | 2038 amt2 = (end1 - start1) + (start2 - end1); |
2186 staticpro (&Vsystem_name); | 2186 staticpro (&Vsystem_name); |
2187 #if 0 | 2187 #if 0 |
2188 staticpro (&Vuser_full_name); | 2188 staticpro (&Vuser_full_name); |
2189 staticpro (&Vuser_name); | 2189 staticpro (&Vuser_name); |
2190 staticpro (&Vuser_real_name); | 2190 staticpro (&Vuser_real_name); |
2191 #endif | 2191 #endif |
2192 DEFVAR_BOOL ("zmacs-regions", &zmacs_regions /* | 2192 DEFVAR_BOOL ("zmacs-regions", &zmacs_regions /* |
2193 *Whether LISPM-style active regions should be used. | 2193 *Whether LISPM-style active regions should be used. |
2194 This means that commands which operate on the region (the area between the | 2194 This means that commands which operate on the region (the area between the |
2195 point and the mark) will only work while the region is in the ``active'' | 2195 point and the mark) will only work while the region is in the ``active'' |
2196 state, which is indicated by highlighting. Executing most commands causes | 2196 state, which is indicated by highlighting. Executing most commands causes |
2201 | 2201 |
2202 - Commands which operate on the region only work if the region is active. | 2202 - Commands which operate on the region only work if the region is active. |
2203 - Only a very small set of commands cause the region to become active: | 2203 - Only a very small set of commands cause the region to become active: |
2204 Those commands whose semantics are to mark an area, like mark-defun. | 2204 Those commands whose semantics are to mark an area, like mark-defun. |
2205 - The region is deactivated after each command that is executed, except that: | 2205 - The region is deactivated after each command that is executed, except that: |
2206 - \"Motion\" commands do not change whether the region is active or not. | 2206 - "Motion" commands do not change whether the region is active or not. |
2207 | 2207 |
2208 set-mark-command (C-SPC) pushes a mark and activates the region. Moving the | 2208 set-mark-command (C-SPC) pushes a mark and activates the region. Moving the |
2209 cursor with normal motion commands (C-n, C-p, etc) will cause the region | 2209 cursor with normal motion commands (C-n, C-p, etc) will cause the region |
2210 between point and the recently-pushed mark to be highlighted. It will | 2210 between point and the recently-pushed mark to be highlighted. It will |
2211 remain highlighted until some non-motion command is executed. | 2211 remain highlighted until some non-motion command is executed. |