diff options
| author | Eli Zaretskii | 2002-02-22 13:14:27 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2002-02-22 13:14:27 +0000 |
| commit | 37323f344cae62760f64eeebe82d7a7f7a0b3078 (patch) | |
| tree | 5fed0731ff2ca98352966638d2e0066c46f1a7c3 /src | |
| parent | f5a55627d7af5733514030df73a64857bd532262 (diff) | |
| download | emacs-37323f344cae62760f64eeebe82d7a7f7a0b3078.tar.gz emacs-37323f344cae62760f64eeebe82d7a7f7a0b3078.zip | |
(x_encode_text): Accept additional arg SELECTIONP; all
callers changed. If SELECTIONP is non-zero, run the
pre-write-conversion function before encoding the selection text.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/xfns.c b/src/xfns.c index b8818b6c5be..748d8925a53 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -2345,6 +2345,10 @@ x_set_scroll_bar_background (f, value, oldval) | |||
| 2345 | CODING_SYSTEM, and return a newly allocated memory area which | 2345 | CODING_SYSTEM, and return a newly allocated memory area which |
| 2346 | should be freed by `xfree' by a caller. | 2346 | should be freed by `xfree' by a caller. |
| 2347 | 2347 | ||
| 2348 | SELECTIONP non-zero means the string is being encoded for an X | ||
| 2349 | selection, so it is safe to run pre-write conversions (which | ||
| 2350 | may run Lisp code). | ||
| 2351 | |||
| 2348 | Store the byte length of resulting text in *TEXT_BYTES. | 2352 | Store the byte length of resulting text in *TEXT_BYTES. |
| 2349 | 2353 | ||
| 2350 | If the text contains only ASCII and Latin-1, store 1 in *STRING_P, | 2354 | If the text contains only ASCII and Latin-1, store 1 in *STRING_P, |
| @@ -2353,9 +2357,10 @@ x_set_scroll_bar_background (f, value, oldval) | |||
| 2353 | the result should be `COMPOUND_TEXT'. */ | 2357 | the result should be `COMPOUND_TEXT'. */ |
| 2354 | 2358 | ||
| 2355 | unsigned char * | 2359 | unsigned char * |
| 2356 | x_encode_text (string, coding_system, text_bytes, stringp) | 2360 | x_encode_text (string, coding_system, selectionp, text_bytes, stringp) |
| 2357 | Lisp_Object string, coding_system; | 2361 | Lisp_Object string, coding_system; |
| 2358 | int *text_bytes, *stringp; | 2362 | int *text_bytes, *stringp; |
| 2363 | int selectionp; | ||
| 2359 | { | 2364 | { |
| 2360 | unsigned char *str = XSTRING (string)->data; | 2365 | unsigned char *str = XSTRING (string)->data; |
| 2361 | int chars = XSTRING (string)->size; | 2366 | int chars = XSTRING (string)->size; |
| @@ -2375,6 +2380,15 @@ x_encode_text (string, coding_system, text_bytes, stringp) | |||
| 2375 | } | 2380 | } |
| 2376 | 2381 | ||
| 2377 | setup_coding_system (coding_system, &coding); | 2382 | setup_coding_system (coding_system, &coding); |
| 2383 | if (selectionp | ||
| 2384 | && SYMBOLP (coding.pre_write_conversion) | ||
| 2385 | && !NILP (Ffboundp (coding.pre_write_conversion))) | ||
| 2386 | { | ||
| 2387 | string = run_pre_post_conversion_on_str (string, &coding, 1); | ||
| 2388 | str = XSTRING (string)->data; | ||
| 2389 | chars = XSTRING (string)->size; | ||
| 2390 | bytes = STRING_BYTES (XSTRING (string)); | ||
| 2391 | } | ||
| 2378 | coding.src_multibyte = 1; | 2392 | coding.src_multibyte = 1; |
| 2379 | coding.dst_multibyte = 0; | 2393 | coding.dst_multibyte = 0; |
| 2380 | coding.mode |= CODING_MODE_LAST_BLOCK; | 2394 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| @@ -2458,7 +2472,7 @@ x_set_name (f, name, explicit) | |||
| 2458 | coding_system = Vlocale_coding_system; | 2472 | coding_system = Vlocale_coding_system; |
| 2459 | if (NILP (coding_system)) | 2473 | if (NILP (coding_system)) |
| 2460 | coding_system = Qcompound_text; | 2474 | coding_system = Qcompound_text; |
| 2461 | text.value = x_encode_text (name, coding_system, &bytes, &stringp); | 2475 | text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); |
| 2462 | text.encoding = (stringp ? XA_STRING | 2476 | text.encoding = (stringp ? XA_STRING |
| 2463 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); | 2477 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
| 2464 | text.format = 8; | 2478 | text.format = 8; |
| @@ -2470,7 +2484,7 @@ x_set_name (f, name, explicit) | |||
| 2470 | } | 2484 | } |
| 2471 | else | 2485 | else |
| 2472 | { | 2486 | { |
| 2473 | icon.value = x_encode_text (f->icon_name, coding_system, | 2487 | icon.value = x_encode_text (f->icon_name, coding_system, 0, |
| 2474 | &bytes, &stringp); | 2488 | &bytes, &stringp); |
| 2475 | icon.encoding = (stringp ? XA_STRING | 2489 | icon.encoding = (stringp ? XA_STRING |
| 2476 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); | 2490 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
| @@ -2565,7 +2579,7 @@ x_set_title (f, name, old_name) | |||
| 2565 | coding_system = Vlocale_coding_system; | 2579 | coding_system = Vlocale_coding_system; |
| 2566 | if (NILP (coding_system)) | 2580 | if (NILP (coding_system)) |
| 2567 | coding_system = Qcompound_text; | 2581 | coding_system = Qcompound_text; |
| 2568 | text.value = x_encode_text (name, coding_system, &bytes, &stringp); | 2582 | text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); |
| 2569 | text.encoding = (stringp ? XA_STRING | 2583 | text.encoding = (stringp ? XA_STRING |
| 2570 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); | 2584 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
| 2571 | text.format = 8; | 2585 | text.format = 8; |
| @@ -2577,7 +2591,7 @@ x_set_title (f, name, old_name) | |||
| 2577 | } | 2591 | } |
| 2578 | else | 2592 | else |
| 2579 | { | 2593 | { |
| 2580 | icon.value = x_encode_text (f->icon_name, coding_system, | 2594 | icon.value = x_encode_text (f->icon_name, coding_system, 0, |
| 2581 | &bytes, &stringp); | 2595 | &bytes, &stringp); |
| 2582 | icon.encoding = (stringp ? XA_STRING | 2596 | icon.encoding = (stringp ? XA_STRING |
| 2583 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); | 2597 | : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |