diff options
| author | Kenichi Handa | 2012-08-16 21:25:17 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-08-16 21:25:17 +0900 |
| commit | d75ffb4ed0b2e72a9361a07d16a5c884a9459728 (patch) | |
| tree | 8ac5a6a8ae033fef7fbc7fb7b09a703ef4b0ed5b /src/editfns.c | |
| parent | 69c41c4070c86baac11a627e9c3d366420aeb7cc (diff) | |
| parent | 250c8ab9b8f6322959fa3122db83944c30c3894b (diff) | |
| download | emacs-d75ffb4ed0b2e72a9361a07d16a5c884a9459728.tar.gz emacs-d75ffb4ed0b2e72a9361a07d16a5c884a9459728.zip | |
merge trunk
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 98 |
1 files changed, 64 insertions, 34 deletions
diff --git a/src/editfns.c b/src/editfns.c index 32d11faa216..5ac012c8378 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -59,10 +59,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 59 | #include "window.h" | 59 | #include "window.h" |
| 60 | #include "blockinput.h" | 60 | #include "blockinput.h" |
| 61 | 61 | ||
| 62 | #ifndef USER_FULL_NAME | ||
| 63 | #define USER_FULL_NAME pw->pw_gecos | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #ifndef USE_CRT_DLL | 62 | #ifndef USE_CRT_DLL |
| 67 | extern char **environ; | 63 | extern char **environ; |
| 68 | #endif | 64 | #endif |
| @@ -886,7 +882,7 @@ save_excursion_restore (Lisp_Object info) | |||
| 886 | info = XCDR (info); | 882 | info = XCDR (info); |
| 887 | tem = XCAR (info); | 883 | tem = XCAR (info); |
| 888 | tem1 = BVAR (current_buffer, mark_active); | 884 | tem1 = BVAR (current_buffer, mark_active); |
| 889 | BVAR (current_buffer, mark_active) = tem; | 885 | BSET (current_buffer, mark_active, tem); |
| 890 | 886 | ||
| 891 | /* If mark is active now, and either was not active | 887 | /* If mark is active now, and either was not active |
| 892 | or was at a different place, run the activate hook. */ | 888 | or was at a different place, run the activate hook. */ |
| @@ -950,8 +946,8 @@ usage: (save-excursion &rest BODY) */) | |||
| 950 | } | 946 | } |
| 951 | 947 | ||
| 952 | DEFUN ("save-current-buffer", Fsave_current_buffer, Ssave_current_buffer, 0, UNEVALLED, 0, | 948 | DEFUN ("save-current-buffer", Fsave_current_buffer, Ssave_current_buffer, 0, UNEVALLED, 0, |
| 953 | doc: /* Save the current buffer; execute BODY; restore the current buffer. | 949 | doc: /* Record which buffer is current; execute BODY; make that buffer current. |
| 954 | Executes BODY just like `progn'. | 950 | BODY is executed just like `progn'. |
| 955 | usage: (save-current-buffer &rest BODY) */) | 951 | usage: (save-current-buffer &rest BODY) */) |
| 956 | (Lisp_Object args) | 952 | (Lisp_Object args) |
| 957 | { | 953 | { |
| @@ -1797,7 +1793,7 @@ format_time_string (char const *format, ptrdiff_t formatlen, | |||
| 1797 | if (STRING_BYTES_BOUND <= len) | 1793 | if (STRING_BYTES_BOUND <= len) |
| 1798 | string_overflow (); | 1794 | string_overflow (); |
| 1799 | size = len + 1; | 1795 | size = len + 1; |
| 1800 | SAFE_ALLOCA (buf, char *, size); | 1796 | buf = SAFE_ALLOCA (size); |
| 1801 | } | 1797 | } |
| 1802 | 1798 | ||
| 1803 | UNBLOCK_INPUT; | 1799 | UNBLOCK_INPUT; |
| @@ -2076,7 +2072,7 @@ the data it can't find. */) | |||
| 2076 | int m = offset / 60; | 2072 | int m = offset / 60; |
| 2077 | int am = offset < 0 ? - m : m; | 2073 | int am = offset < 0 ? - m : m; |
| 2078 | char buf[sizeof "+00" + INT_STRLEN_BOUND (int)]; | 2074 | char buf[sizeof "+00" + INT_STRLEN_BOUND (int)]; |
| 2079 | zone_name = make_formatted_string (buf, "%c%02d%02d", | 2075 | zone_name = make_formatted_string (buf, "%c%02d%02d", |
| 2080 | (offset < 0 ? '-' : '+'), | 2076 | (offset < 0 ? '-' : '+'), |
| 2081 | am / 60, am % 60); | 2077 | am / 60, am % 60); |
| 2082 | } | 2078 | } |
| @@ -2368,11 +2364,35 @@ usage: (insert-before-markers-and-inherit &rest ARGS) */) | |||
| 2368 | return Qnil; | 2364 | return Qnil; |
| 2369 | } | 2365 | } |
| 2370 | 2366 | ||
| 2371 | DEFUN ("insert-char", Finsert_char, Sinsert_char, 2, 3, 0, | 2367 | DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, |
| 2368 | "(list (read-char-by-name \"Insert character (Unicode name or hex): \")\ | ||
| 2369 | (prefix-numeric-value current-prefix-arg)\ | ||
| 2370 | t))", | ||
| 2372 | doc: /* Insert COUNT copies of CHARACTER. | 2371 | doc: /* Insert COUNT copies of CHARACTER. |
| 2373 | Point, and before-insertion markers, are relocated as in the function `insert'. | 2372 | Interactively, prompt for CHARACTER. You can specify CHARACTER in one |
| 2374 | The optional third arg INHERIT, if non-nil, says to inherit text properties | 2373 | of these ways: |
| 2375 | from adjoining text, if those properties are sticky. */) | 2374 | |
| 2375 | - As its Unicode character name, e.g. \"LATIN SMALL LETTER A\". | ||
| 2376 | Completion is available; if you type a substring of the name | ||
| 2377 | preceded by an asterisk `*', Emacs shows all names which include | ||
| 2378 | that substring, not necessarily at the beginning of the name. | ||
| 2379 | |||
| 2380 | - As a hexadecimal code point, e.g. 263A. Note that code points in | ||
| 2381 | Emacs are equivalent to Unicode up to 10FFFF (which is the limit of | ||
| 2382 | the Unicode code space). | ||
| 2383 | |||
| 2384 | - As a code point with a radix specified with #, e.g. #o21430 | ||
| 2385 | (octal), #x2318 (hex), or #10r8984 (decimal). | ||
| 2386 | |||
| 2387 | If called interactively, COUNT is given by the prefix argument. If | ||
| 2388 | omitted or nil, it defaults to 1. | ||
| 2389 | |||
| 2390 | Inserting the character(s) relocates point and before-insertion | ||
| 2391 | markers in the same ways as the function `insert'. | ||
| 2392 | |||
| 2393 | The optional third argument INHERIT, if non-nil, says to inherit text | ||
| 2394 | properties from adjoining text, if those properties are sticky. If | ||
| 2395 | called interactively, INHERIT is t. */) | ||
| 2376 | (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) | 2396 | (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) |
| 2377 | { | 2397 | { |
| 2378 | int i, stringlen; | 2398 | int i, stringlen; |
| @@ -2382,6 +2402,8 @@ from adjoining text, if those properties are sticky. */) | |||
| 2382 | char string[4000]; | 2402 | char string[4000]; |
| 2383 | 2403 | ||
| 2384 | CHECK_CHARACTER (character); | 2404 | CHECK_CHARACTER (character); |
| 2405 | if (NILP (count)) | ||
| 2406 | XSETFASTINT (count, 1); | ||
| 2385 | CHECK_NUMBER (count); | 2407 | CHECK_NUMBER (count); |
| 2386 | c = XFASTINT (character); | 2408 | c = XFASTINT (character); |
| 2387 | 2409 | ||
| @@ -2794,13 +2816,13 @@ determines whether case is significant or ignored. */) | |||
| 2794 | static Lisp_Object | 2816 | static Lisp_Object |
| 2795 | subst_char_in_region_unwind (Lisp_Object arg) | 2817 | subst_char_in_region_unwind (Lisp_Object arg) |
| 2796 | { | 2818 | { |
| 2797 | return BVAR (current_buffer, undo_list) = arg; | 2819 | return BSET (current_buffer, undo_list, arg); |
| 2798 | } | 2820 | } |
| 2799 | 2821 | ||
| 2800 | static Lisp_Object | 2822 | static Lisp_Object |
| 2801 | subst_char_in_region_unwind_1 (Lisp_Object arg) | 2823 | subst_char_in_region_unwind_1 (Lisp_Object arg) |
| 2802 | { | 2824 | { |
| 2803 | return BVAR (current_buffer, filename) = arg; | 2825 | return BSET (current_buffer, filename, arg); |
| 2804 | } | 2826 | } |
| 2805 | 2827 | ||
| 2806 | DEFUN ("subst-char-in-region", Fsubst_char_in_region, | 2828 | DEFUN ("subst-char-in-region", Fsubst_char_in_region, |
| @@ -2874,11 +2896,11 @@ Both characters must have the same length of multi-byte form. */) | |||
| 2874 | { | 2896 | { |
| 2875 | record_unwind_protect (subst_char_in_region_unwind, | 2897 | record_unwind_protect (subst_char_in_region_unwind, |
| 2876 | BVAR (current_buffer, undo_list)); | 2898 | BVAR (current_buffer, undo_list)); |
| 2877 | BVAR (current_buffer, undo_list) = Qt; | 2899 | BSET (current_buffer, undo_list, Qt); |
| 2878 | /* Don't do file-locking. */ | 2900 | /* Don't do file-locking. */ |
| 2879 | record_unwind_protect (subst_char_in_region_unwind_1, | 2901 | record_unwind_protect (subst_char_in_region_unwind_1, |
| 2880 | BVAR (current_buffer, filename)); | 2902 | BVAR (current_buffer, filename)); |
| 2881 | BVAR (current_buffer, filename) = Qnil; | 2903 | BSET (current_buffer, filename, Qnil); |
| 2882 | } | 2904 | } |
| 2883 | 2905 | ||
| 2884 | if (pos_byte < GPT_BYTE) | 2906 | if (pos_byte < GPT_BYTE) |
| @@ -2960,7 +2982,7 @@ Both characters must have the same length of multi-byte form. */) | |||
| 2960 | INC_POS (pos_byte_next); | 2982 | INC_POS (pos_byte_next); |
| 2961 | 2983 | ||
| 2962 | if (! NILP (noundo)) | 2984 | if (! NILP (noundo)) |
| 2963 | BVAR (current_buffer, undo_list) = tem; | 2985 | BSET (current_buffer, undo_list, tem); |
| 2964 | 2986 | ||
| 2965 | UNGCPRO; | 2987 | UNGCPRO; |
| 2966 | } | 2988 | } |
| @@ -3353,6 +3375,10 @@ save_restriction_restore (Lisp_Object data) | |||
| 3353 | 3375 | ||
| 3354 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ | 3376 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ |
| 3355 | } | 3377 | } |
| 3378 | /* These aren't needed anymore, so don't wait for GC. */ | ||
| 3379 | free_marker (XCAR (data)); | ||
| 3380 | free_marker (XCDR (data)); | ||
| 3381 | free_cons (XCONS (data)); | ||
| 3356 | } | 3382 | } |
| 3357 | else | 3383 | else |
| 3358 | /* A buffer, which means that there was no old restriction. */ | 3384 | /* A buffer, which means that there was no old restriction. */ |
| @@ -3589,9 +3615,13 @@ where flags is [+ #-0]+, width is [0-9]+, and precision is .[0-9]+ | |||
| 3589 | The + flag character inserts a + before any positive number, while a | 3615 | The + flag character inserts a + before any positive number, while a |
| 3590 | space inserts a space before any positive number; these flags only | 3616 | space inserts a space before any positive number; these flags only |
| 3591 | affect %d, %e, %f, and %g sequences, and the + flag takes precedence. | 3617 | affect %d, %e, %f, and %g sequences, and the + flag takes precedence. |
| 3618 | The - and 0 flags affect the width specifier, as described below. | ||
| 3619 | |||
| 3592 | The # flag means to use an alternate display form for %o, %x, %X, %e, | 3620 | The # flag means to use an alternate display form for %o, %x, %X, %e, |
| 3593 | %f, and %g sequences. The - and 0 flags affect the width specifier, | 3621 | %f, and %g sequences: for %o, it ensures that the result begins with |
| 3594 | as described below. | 3622 | \"0\"; for %x and %X, it prefixes the result with \"0x\" or \"0X\"; |
| 3623 | for %e, %f, and %g, it causes a decimal point to be included even if | ||
| 3624 | the precision is zero. | ||
| 3595 | 3625 | ||
| 3596 | The width specifier supplies a lower limit for the length of the | 3626 | The width specifier supplies a lower limit for the length of the |
| 3597 | printed representation. The padding, if any, normally goes on the | 3627 | printed representation. The padding, if any, normally goes on the |
| @@ -3660,7 +3690,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3660 | ptrdiff_t i; | 3690 | ptrdiff_t i; |
| 3661 | if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) | 3691 | if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) |
| 3662 | memory_full (SIZE_MAX); | 3692 | memory_full (SIZE_MAX); |
| 3663 | SAFE_ALLOCA (info, struct info *, (nargs + 1) * sizeof *info + formatlen); | 3693 | info = SAFE_ALLOCA ((nargs + 1) * sizeof *info + formatlen); |
| 3664 | discarded = (char *) &info[nargs + 1]; | 3694 | discarded = (char *) &info[nargs + 1]; |
| 3665 | for (i = 0; i < nargs + 1; i++) | 3695 | for (i = 0; i < nargs + 1; i++) |
| 3666 | { | 3696 | { |
| @@ -3907,7 +3937,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3907 | 3937 | ||
| 3908 | /* If this argument has text properties, record where | 3938 | /* If this argument has text properties, record where |
| 3909 | in the result string it appears. */ | 3939 | in the result string it appears. */ |
| 3910 | if (STRING_INTERVALS (args[n])) | 3940 | if (string_get_intervals (args[n])) |
| 3911 | info[n].intervals = arg_intervals = 1; | 3941 | info[n].intervals = arg_intervals = 1; |
| 3912 | 3942 | ||
| 3913 | continue; | 3943 | continue; |
| @@ -4251,7 +4281,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 4251 | arguments has text properties, set up text properties of the | 4281 | arguments has text properties, set up text properties of the |
| 4252 | result string. */ | 4282 | result string. */ |
| 4253 | 4283 | ||
| 4254 | if (STRING_INTERVALS (args[0]) || arg_intervals) | 4284 | if (string_get_intervals (args[0]) || arg_intervals) |
| 4255 | { | 4285 | { |
| 4256 | Lisp_Object len, new_len, props; | 4286 | Lisp_Object len, new_len, props; |
| 4257 | struct gcpro gcpro1; | 4287 | struct gcpro gcpro1; |
| @@ -4501,7 +4531,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4501 | Lisp_Object buf; | 4531 | Lisp_Object buf; |
| 4502 | 4532 | ||
| 4503 | XSETBUFFER (buf, current_buffer); | 4533 | XSETBUFFER (buf, current_buffer); |
| 4504 | cur_intv = BUF_INTERVALS (current_buffer); | 4534 | cur_intv = buffer_get_intervals (current_buffer); |
| 4505 | 4535 | ||
| 4506 | validate_region (&startr1, &endr1); | 4536 | validate_region (&startr1, &endr1); |
| 4507 | validate_region (&startr2, &endr2); | 4537 | validate_region (&startr2, &endr2); |
| @@ -4611,7 +4641,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4611 | /* Don't use Fset_text_properties: that can cause GC, which can | 4641 | /* Don't use Fset_text_properties: that can cause GC, which can |
| 4612 | clobber objects stored in the tmp_intervals. */ | 4642 | clobber objects stored in the tmp_intervals. */ |
| 4613 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); | 4643 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); |
| 4614 | if (!NULL_INTERVAL_P (tmp_interval3)) | 4644 | if (tmp_interval3) |
| 4615 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); | 4645 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
| 4616 | 4646 | ||
| 4617 | /* First region smaller than second. */ | 4647 | /* First region smaller than second. */ |
| @@ -4619,7 +4649,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4619 | { | 4649 | { |
| 4620 | USE_SAFE_ALLOCA; | 4650 | USE_SAFE_ALLOCA; |
| 4621 | 4651 | ||
| 4622 | SAFE_ALLOCA (temp, unsigned char *, len2_byte); | 4652 | temp = SAFE_ALLOCA (len2_byte); |
| 4623 | 4653 | ||
| 4624 | /* Don't precompute these addresses. We have to compute them | 4654 | /* Don't precompute these addresses. We have to compute them |
| 4625 | at the last minute, because the relocating allocator might | 4655 | at the last minute, because the relocating allocator might |
| @@ -4637,7 +4667,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4637 | { | 4667 | { |
| 4638 | USE_SAFE_ALLOCA; | 4668 | USE_SAFE_ALLOCA; |
| 4639 | 4669 | ||
| 4640 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); | 4670 | temp = SAFE_ALLOCA (len1_byte); |
| 4641 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4671 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4642 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4672 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4643 | memcpy (temp, start1_addr, len1_byte); | 4673 | memcpy (temp, start1_addr, len1_byte); |
| @@ -4670,14 +4700,14 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4670 | tmp_interval2 = copy_intervals (cur_intv, start2, len2); | 4700 | tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
| 4671 | 4701 | ||
| 4672 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr1, 0); | 4702 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr1, 0); |
| 4673 | if (!NULL_INTERVAL_P (tmp_interval3)) | 4703 | if (tmp_interval3) |
| 4674 | set_text_properties_1 (startr1, endr1, Qnil, buf, tmp_interval3); | 4704 | set_text_properties_1 (startr1, endr1, Qnil, buf, tmp_interval3); |
| 4675 | 4705 | ||
| 4676 | tmp_interval3 = validate_interval_range (buf, &startr2, &endr2, 0); | 4706 | tmp_interval3 = validate_interval_range (buf, &startr2, &endr2, 0); |
| 4677 | if (!NULL_INTERVAL_P (tmp_interval3)) | 4707 | if (tmp_interval3) |
| 4678 | set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3); | 4708 | set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3); |
| 4679 | 4709 | ||
| 4680 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); | 4710 | temp = SAFE_ALLOCA (len1_byte); |
| 4681 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4711 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4682 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4712 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4683 | memcpy (temp, start1_addr, len1_byte); | 4713 | memcpy (temp, start1_addr, len1_byte); |
| @@ -4703,11 +4733,11 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4703 | tmp_interval2 = copy_intervals (cur_intv, start2, len2); | 4733 | tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
| 4704 | 4734 | ||
| 4705 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); | 4735 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); |
| 4706 | if (!NULL_INTERVAL_P (tmp_interval3)) | 4736 | if (tmp_interval3) |
| 4707 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); | 4737 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
| 4708 | 4738 | ||
| 4709 | /* holds region 2 */ | 4739 | /* holds region 2 */ |
| 4710 | SAFE_ALLOCA (temp, unsigned char *, len2_byte); | 4740 | temp = SAFE_ALLOCA (len2_byte); |
| 4711 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4741 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4712 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4742 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4713 | memcpy (temp, start2_addr, len2_byte); | 4743 | memcpy (temp, start2_addr, len2_byte); |
| @@ -4736,11 +4766,11 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4736 | tmp_interval2 = copy_intervals (cur_intv, start2, len2); | 4766 | tmp_interval2 = copy_intervals (cur_intv, start2, len2); |
| 4737 | 4767 | ||
| 4738 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); | 4768 | tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0); |
| 4739 | if (!NULL_INTERVAL_P (tmp_interval3)) | 4769 | if (tmp_interval3) |
| 4740 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); | 4770 | set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3); |
| 4741 | 4771 | ||
| 4742 | /* holds region 1 */ | 4772 | /* holds region 1 */ |
| 4743 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); | 4773 | temp = SAFE_ALLOCA (len1_byte); |
| 4744 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4774 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4745 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4775 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4746 | memcpy (temp, start1_addr, len1_byte); | 4776 | memcpy (temp, start1_addr, len1_byte); |