Changeset 1721
- Timestamp:
- 02/17/98 01:45:22 (11 years ago)
- Files:
-
- branches/GNU/src/bitmaps (added)
- branches/GNU/src/bitmaps/cntrpmsk.xbm (added)
- branches/GNU/src/bitmaps/cntrptr.xbm (added)
- branches/GNU/src/bitmaps/crosswv.xbm (added)
- branches/GNU/src/bitmaps/dimple1.xbm (added)
- branches/GNU/src/bitmaps/dimple3.xbm (added)
- branches/GNU/src/bitmaps/gray.xbm (added)
- branches/GNU/src/bitmaps/gray1.xbm (added)
- branches/GNU/src/bitmaps/gray3.xbm (added)
- branches/GNU/src/xmenu.c (modified) (16 diffs)
- branches/GNU/src/xrdb.c (modified) (2 diffs)
- branches/GNU/src/xselect.c (modified) (25 diffs)
- branches/GNU/src/xterm.c (modified) (75 diffs)
- branches/GNU/src/xterm.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/GNU/src/xmenu.c
r1719 r1721 42 42 #include "keyboard.h" 43 43 #include "blockinput.h" 44 #include "puresize.h" 44 45 #include "buffer.h" 45 46 … … 90 91 Lisp_Object Qdebug_on_next_call; 91 92 93 Lisp_Object Qmenu_alias; 94 95 extern Lisp_Object Qmenu_enable; 92 96 extern Lisp_Object Qmenu_bar; 93 97 extern Lisp_Object Qmouse_click, Qevent_kind; 94 98 95 extern Lisp_Object QCtoggle, QCradio;99 extern Lisp_Object Vdefine_key_rebound_commands; 96 100 97 101 extern Lisp_Object Voverriding_local_map; … … 114 118 static void keymap_panes (); 115 119 static void single_keymap_panes (); 116 static void single_menu_item ();117 120 static void list_of_panes (); 118 121 static void list_of_items (); … … 337 340 } 338 341 342 /* Figure out the current keyboard equivalent of a menu item ITEM1. 343 The item string for menu display should be ITEM_STRING. 344 Store the equivalent keyboard key sequence's 345 textual description into *DESCRIP_PTR. 346 Also cache them in the item itself. 347 Return the real definition to execute. */ 348 349 static Lisp_Object 350 menu_item_equiv_key (item_string, item1, descrip_ptr) 351 Lisp_Object item_string; 352 Lisp_Object item1; 353 Lisp_Object *descrip_ptr; 354 { 355 /* This is the real definition--the function to run. */ 356 Lisp_Object def; 357 /* This is the sublist that records cached equiv key data 358 so we can save time. */ 359 Lisp_Object cachelist; 360 /* These are the saved equivalent keyboard key sequence 361 and its key-description. */ 362 Lisp_Object savedkey, descrip; 363 Lisp_Object def1; 364 int changed = 0; 365 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 366 367 /* If a help string follows the item string, skip it. */ 368 if (CONSP (XCONS (item1)->cdr) 369 && STRINGP (XCONS (XCONS (item1)->cdr)->car)) 370 item1 = XCONS (item1)->cdr; 371 372 def = Fcdr (item1); 373 374 /* Get out the saved equivalent-keyboard-key info. */ 375 cachelist = savedkey = descrip = Qnil; 376 if (CONSP (def) && CONSP (XCONS (def)->car) 377 && (NILP (XCONS (XCONS (def)->car)->car) 378 || VECTORP (XCONS (XCONS (def)->car)->car))) 379 { 380 cachelist = XCONS (def)->car; 381 def = XCONS (def)->cdr; 382 savedkey = XCONS (cachelist)->car; 383 descrip = XCONS (cachelist)->cdr; 384 } 385 386 GCPRO4 (def, def1, savedkey, descrip); 387 388 /* Is it still valid? */ 389 def1 = Qnil; 390 if (!NILP (savedkey)) 391 def1 = Fkey_binding (savedkey, Qnil); 392 /* If not, update it. */ 393 if (! EQ (def1, def) 394 /* If the command is an alias for another 395 (such as easymenu.el and lmenu.el set it up), 396 check if the original command matches the cached command. */ 397 && !(SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function) 398 && EQ (def1, XSYMBOL (def)->function)) 399 /* If something had no key binding before, don't recheck it 400 because that is too slow--except if we have a list of rebound 401 commands in Vdefine_key_rebound_commands, do recheck any command 402 that appears in that list. */ 403 && (NILP (cachelist) || !NILP (savedkey) 404 || (! EQ (Qt, Vdefine_key_rebound_commands) 405 && !NILP (Fmemq (def, Vdefine_key_rebound_commands))))) 406 { 407 changed = 1; 408 descrip = Qnil; 409 /* If the command is an alias for another 410 (such as easymenu.el and lmenu.el set it up), 411 see if the original command name has equivalent keys. */ 412 if (SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function) 413 && ! NILP (Fget (def, Qmenu_alias))) 414 savedkey = Fwhere_is_internal (XSYMBOL (def)->function, 415 Qnil, Qt, Qnil); 416 else 417 /* Otherwise look up the specified command itself. 418 We don't try both, because that makes easymenu menus slow. */ 419 savedkey = Fwhere_is_internal (def, Qnil, Qt, Qnil); 420 421 if (!NILP (savedkey)) 422 { 423 descrip = Fkey_description (savedkey); 424 descrip = concat2 (make_string (" (", 3), descrip); 425 descrip = concat2 (descrip, make_string (")", 1)); 426 } 427 } 428 429 /* Cache the data we just got in a sublist of the menu binding. */ 430 if (NILP (cachelist)) 431 { 432 CHECK_IMPURE (item1); 433 XCONS (item1)->cdr = Fcons (Fcons (savedkey, descrip), def); 434 } 435 else if (changed) 436 { 437 XCONS (cachelist)->car = savedkey; 438 XCONS (cachelist)->cdr = descrip; 439 } 440 441 UNGCPRO; 442 *descrip_ptr = descrip; 443 return def; 444 } 445 446 /* This is used as the handler when calling internal_condition_case_1. */ 447 448 static Lisp_Object 449 menu_item_enabled_p_1 (arg) 450 Lisp_Object arg; 451 { 452 /* If we got a quit from within the menu computation, 453 quit all the way out of it. This takes care of C-] in the debugger. */ 454 if (CONSP (arg) && EQ (XCONS (arg)->car, Qquit)) 455 Fsignal (Qquit, Qnil); 456 457 return Qnil; 458 } 459 460 /* Return non-nil if the command DEF is enabled when used as a menu item. 461 This is based on looking for a menu-enable property. 462 If NOTREAL is set, don't bother really computing this. */ 463 464 static Lisp_Object 465 menu_item_enabled_p (def, notreal) 466 Lisp_Object def; 467 int notreal; 468 { 469 Lisp_Object enabled, tem; 470 471 enabled = Qt; 472 if (notreal) 473 return enabled; 474 if (SYMBOLP (def)) 475 { 476 /* No property, or nil, means enable. 477 Otherwise, enable if value is not nil. */ 478 tem = Fget (def, Qmenu_enable); 479 if (!NILP (tem)) 480 /* (condition-case nil (eval tem) 481 (error nil)) */ 482 enabled = internal_condition_case_1 (Feval, tem, Qerror, 483 menu_item_enabled_p_1); 484 } 485 return enabled; 486 } 487 339 488 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long, 340 489 and generate menu panes for them in menu_items. … … 365 514 The other arguments are passed along 366 515 or point to local variables of the previous function. 367 If NOTREAL is nonzero, only check for equivalent key bindings, don't368 evaluate expressions in menu items and don't make any menu.516 If NOTREAL is nonzero, 517 don't bother really computing whether an item is enabled. 369 518 370 519 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */ … … 378 527 int maxdepth; 379 528 { 380 Lisp_Object pending_maps = Qnil; 381 Lisp_Object tail, item; 382 struct gcpro gcpro1, gcpro2; 383 int notbuttons = 0; 529 Lisp_Object pending_maps; 530 Lisp_Object tail, item, item1, item_string, table; 531 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 384 532 385 533 if (maxdepth <= 0) 386 534 return; 387 535 536 pending_maps = Qnil; 537 388 538 push_menu_pane (pane_name, prefix); 389 539 390 #ifndef HAVE_BOXES391 /* Remember index for first item in this pane so we can go back and392 add a prefix when (if) we see the first button. After that, notbuttons393 is set to 0, to mark that we have seen a button and all non button394 items need a prefix. */395 notbuttons = menu_items_used;396 #endif397 398 540 for (tail = keymap; CONSP (tail); tail = XCONS (tail)->cdr) 399 541 { 400 GCPRO2 (keymap, pending_maps); 401 /* Look at each key binding, and if it is a menu item add it 402 to this menu. */ 542 /* Look at each key binding, and if it has a menu string, 543 make a menu item from it. */ 403 544 item = XCONS (tail)->car; 404 545 if (CONSP (item)) 405 single_menu_item (XCONS (item)->car, XCONS (item)->cdr, 406 &pending_maps, notreal, maxdepth, ¬buttons); 546 { 547 item1 = XCONS (item)->cdr; 548 if (CONSP (item1)) 549 { 550 item_string = XCONS (item1)->car; 551 if (STRINGP (item_string)) 552 { 553 /* This is the real definition--the function to run. */ 554 Lisp_Object def; 555 /* These are the saved equivalent keyboard key sequence 556 and its key-description. */ 557 Lisp_Object descrip; 558 Lisp_Object tem, enabled; 559 560 /* GCPRO because ...enabled_p will call eval 561 and ..._equiv_key may autoload something. 562 Protecting KEYMAP preserves everything we use; 563 aside from that, must protect whatever might be 564 a string. Since there's no GCPRO5, we refetch 565 item_string instead of protecting it. */ 566 descrip = def = Qnil; 567 GCPRO4 (keymap, pending_maps, def, descrip); 568 569 def = menu_item_equiv_key (item_string, item1, &descrip); 570 enabled = menu_item_enabled_p (def, notreal); 571 572 UNGCPRO; 573 574 item_string = XCONS (item1)->car; 575 576 tem = Fkeymapp (def); 577 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) 578 pending_maps = Fcons (Fcons (def, Fcons (item_string, XCONS (item)->car)), 579 pending_maps); 580 else 581 { 582 Lisp_Object submap; 583 GCPRO4 (keymap, pending_maps, descrip, item_string); 584 submap = get_keymap_1 (def, 0, 1); 585 UNGCPRO; 586 #ifndef USE_X_TOOLKIT 587 /* Indicate visually that this is a submenu. */ 588 if (!NILP (submap)) 589 item_string = concat2 (item_string, 590 build_string (" >")); 591 #endif 592 /* If definition is nil, pass nil as the key. */ 593 push_menu_item (item_string, enabled, 594 XCONS (item)->car, def, 595 descrip); 596 #ifdef USE_X_TOOLKIT 597 /* Display a submenu using the toolkit. */ 598 if (! NILP (submap)) 599 { 600 push_submenu_start (); 601 single_keymap_panes (submap, Qnil, 602 XCONS (item)->car, notreal, 603 maxdepth - 1); 604 push_submenu_end (); 605 } 606 #endif 607 } 608 } 609 } 610 } 407 611 else if (VECTORP (item)) 408 612 { … … 414 618 Lisp_Object character; 415 619 XSETFASTINT (character, c); 416 single_menu_item (character, XVECTOR (item)->contents[c], 417 &pending_maps, notreal, maxdepth, ¬buttons); 620 item1 = XVECTOR (item)->contents[c]; 621 if (CONSP (item1)) 622 { 623 item_string = XCONS (item1)->car; 624 if (STRINGP (item_string)) 625 { 626 Lisp_Object def; 627 628 /* These are the saved equivalent keyboard key sequence 629 and its key-description. */ 630 Lisp_Object descrip; 631 Lisp_Object tem, enabled; 632 633 /* GCPRO because ...enabled_p will call eval 634 and ..._equiv_key may autoload something. 635 Protecting KEYMAP preserves everything we use; 636 aside from that, must protect whatever might be 637 a string. Since there's no GCPRO5, we refetch 638 item_string instead of protecting it. */ 639 GCPRO4 (keymap, pending_maps, def, descrip); 640 descrip = def = Qnil; 641 642 def = menu_item_equiv_key (item_string, item1, &descrip); 643 enabled = menu_item_enabled_p (def, notreal); 644 645 UNGCPRO; 646 647 item_string = XCONS (item1)->car; 648 649 tem = Fkeymapp (def); 650 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) 651 pending_maps = Fcons (Fcons (def, Fcons (item_string, character)), 652 pending_maps); 653 else 654 { 655 Lisp_Object submap; 656 GCPRO4 (keymap, pending_maps, descrip, item_string); 657 submap = get_keymap_1 (def, 0, 1); 658 UNGCPRO; 659 #ifndef USE_X_TOOLKIT 660 if (!NILP (submap)) 661 item_string = concat2 (item_string, 662 build_string (" >")); 663 #endif 664 /* If definition is nil, pass nil as the key. */ 665 push_menu_item (item_string, enabled, character, 666 def, descrip); 667 #ifdef USE_X_TOOLKIT 668 if (! NILP (submap)) 669 { 670 push_submenu_start (); 671 single_keymap_panes (submap, Qnil, 672 character, notreal, 673 maxdepth - 1); 674 push_submenu_end (); 675 } 676 #endif 677 } 678 } 679 } 418 680 } 419 681 } 420 UNGCPRO;421 682 } 422 683 … … 434 695 pending_maps = Fcdr (pending_maps); 435 696 } 436 }437 438 /* This is a subroutine of single_keymap_panes that handles one439 keymap entry.440 KEY is a key in a keymap and ITEM is its binding.441 PENDING_MAPS_PTR points to a list of keymaps waiting to be made into442 separate panes.443 If NOTREAL is nonzero, only check for equivalent key bindings, don't444 evaluate expressions in menu items and don't make any menu.445 If we encounter submenus deeper than MAXDEPTH levels, ignore them.446 NOTBUTTONS_PTR is only used when simulating toggle boxes and radio447 buttons. It points to variable notbuttons in single_keymap_panes,448 which keeps track of if we have seen a button in this menu or not. */449 450 static void451 single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth,452 notbuttons_ptr)453 Lisp_Object key, item;454 Lisp_Object *pending_maps_ptr;455 int maxdepth, notreal;456 int *notbuttons_ptr;457 {458 Lisp_Object def, map, item_string, enabled;459 struct gcpro gcpro1, gcpro2;460 int res;461 462 /* Parse the menu item and leave the result in item_properties. */463 GCPRO2 (key, item);464 res = parse_menu_item (item, notreal, 0);465 UNGCPRO;466 if (!res)467 return; /* Not a menu item. */468 469 map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP];470 471 if (notreal)472 {473 /* We don't want to make a menu, just traverse the keymaps to474 precompute equivalent key bindings. */475 if (!NILP (map))476 single_keymap_panes (map, Qnil, key, 1, maxdepth - 1);477 return;478 }479 480 enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE];481 item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME];482 483 if (!NILP (map) && XSTRING (item_string)->data[0] == '@')484 {485 if (!NILP (enabled))486 /* An enabled separate pane. Remember this to handle it later. */487 *pending_maps_ptr = Fcons (Fcons (map, Fcons (item_string, key)),488 *pending_maps_ptr);489 return;490 }491 492 #ifndef HAVE_BOXES493 /* Simulate radio buttons and toggle boxes by putting a prefix in494 front of them. */495 {496 Lisp_Object prefix = Qnil;497 Lisp_Object type = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE];498 if (!NILP (type))499 {500 Lisp_Object selected501 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED];502 503 if (*notbuttons_ptr)504 /* The first button. Line up previous items in this menu. */505 {506 int index = *notbuttons_ptr; /* Index for first item this menu. */507 int submenu = 0;508 Lisp_Object tem;509 while (index < menu_items_used)510 {511 tem512 = XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME];513 if (NILP (tem))514 {515 index++;516 submenu++; /* Skip sub menu. */517 }518 else if (EQ (tem, Qlambda))519 {520 index++;521 submenu--; /* End sub menu. */522 }523 else if (EQ (tem, Qt))524 index += 3; /* Skip new pane marker. */525 else if (EQ (tem, Qquote))526 index++; /* Skip a left, right divider. */527 else528 {529 if (!submenu && XSTRING (tem)->data[0] != '\0'530 && XSTRING (tem)->data[0] != '-')531 XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME]532 = concat2 (build_string (" "), tem);533 index += MENU_ITEMS_ITEM_LENGTH;534 }535 }536 *notbuttons_ptr = 0;537 }538 539 /* Calculate prefix, if any, for this item. */540 if (EQ (type, QCtoggle))541 prefix = build_string (NILP (selected) ? "[ ] " : "[X] ");542 else if (EQ (type, QCradio))543 prefix = build_string (NILP (selected) ? "( ) " : "(*) ");544 }545 /* Not a button. If we have earlier buttons, then we need a prefix. */546 else if (!*notbuttons_ptr && XSTRING (item_string)->data[0] != '\0'547 && XSTRING (item_string)->data[0] != '-')548 prefix = build_string (" ");549 550 if (!NILP (prefix))551 item_string = concat2 (prefix, item_string);552 }553 #endif /* not HAVE_BOXES */554 555 #ifndef USE_X_TOOLKIT556 if (!NILP(map))557 /* Indicate visually that this is a submenu. */558 item_string = concat2 (item_string, build_string (" >"));559 #endif560 561 push_menu_item (item_string, enabled, key,562 XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF],563 XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ]);564 565 #ifdef USE_X_TOOLKIT566 /* Display a submenu using the toolkit. */567 if (! (NILP (map) || NILP (enabled)))568 {569 push_submenu_start ();570 single_keymap_panes (map, Qnil, key, 0, maxdepth - 1);571 push_submenu_end ();572 }573 #endif574 697 } 575 698 … … 687 810 FRAME_PTR new_f = selected_frame; 688 811 Lisp_Object bar_window; 689 enum scroll_bar_part part;812 int part; 690 813 unsigned long time; 691 814 … … 1026 1149 && dpyinfo->display == event.xbutton.display) 1027 1150 { 1028 KeySym keysym = XLookupKeysym (&event.xkey, 0); 1029 if (!IsModifierKey (keysym)) 1030 { 1031 popup_activated_flag = 0; 1032 break; 1033 } 1151 popup_activated_flag = 0; 1152 break; 1034 1153 } 1035 1154 /* Button presses outside the menu also pop it down. */ … … 1096 1215 execute Lisp code. */ 1097 1216 1098 void1099 1217 x_activate_menubar (f) 1100 1218 FRAME_PTR f; … … 1567 1685 specbind (Qdebug_on_next_call, Qnil); 1568 1686 1569 record_unwind_protect (Fs et_match_data, Fmatch_data (Qnil, Qnil));1687 record_unwind_protect (Fstore_match_data, Fmatch_data (Qnil, Qnil)); 1570 1688 if (NILP (Voverriding_local_map_menu_flag)) 1571 1689 { … … 2442 2560 continue; 2443 2561 } 2444 width = STRING_BYTES (XSTRING (item));2562 width = XSTRING (item)->size; 2445 2563 if (width > maxwidth) 2446 2564 maxwidth = width; … … 2465 2583 if (!NILP (descrip)) 2466 2584 { 2467 int gap = maxwidth - STRING_BYTES (XSTRING (item_name));2585 int gap = maxwidth - XSTRING (item_name)->size; 2468 2586 #ifdef C_ALLOCA 2469 2587 Lisp_Object spacer; … … 2477 2595 item_data 2478 2596 = (unsigned char *) alloca (maxwidth 2479 + STRING_BYTES (XSTRING (descrip))+ 1);2597 + XSTRING (descrip)->size + 1); 2480 2598 bcopy (XSTRING (item_name)->data, item_data, 2481 STRING_BYTES (XSTRING (item_name)));2599 XSTRING (item_name)->size); 2482 2600 for (j = XSTRING (item_name)->size; j < maxwidth; j++) 2483 2601 item_data[j] = ' '; 2484 2602 bcopy (XSTRING (descrip)->data, item_data + j, 2485 STRING_BYTES (XSTRING (descrip)));2486 item_data[j + STRING_BYTES (XSTRING (descrip))] = 0;2603 XSTRING (descrip)->size); 2604 item_data[j + XSTRING (descrip)->size] = 0; 2487 2605 #endif 2488 2606 } … … 2608 2726 #endif /* HAVE_MENUS */ 2609 2727 2610 void2611 2728 syms_of_xmenu () 2612 2729 { 2613 2730 staticpro (&menu_items); 2614 2731 menu_items = Qnil; 2732 2733 Qmenu_alias = intern ("menu-alias"); 2734 staticpro (&Qmenu_alias); 2615 2735 2616 2736 Qdebug_on_next_call = intern ("debug-on-next-call"); branches/GNU/src/xrdb.c
r1719 r1721 23 23 #ifdef emacs 24 24 #include <config.h> 25 #endif26 27 #ifdef HAVE_UNISTD_H28 #include <unistd.h>29 25 #endif 30 26 … … 89 85 #define realloc xrealloc 90 86 #define free xfree 91 extern long *xmalloc (), *xrealloc ();92 87 #endif 93 88 branches/GNU/src/xselect.c
r1719 r1721 1 1 /* X Selection processing for Emacs. 2 Copyright (C) 1993, 1994, 1995, 1996 , 1997Free Software Foundation.2 Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation. 3 3 4 4 This file is part of GNU Emacs. … … 28 28 #include "frame.h" /* Need this to get the X window of selected_frame */ 29 29 #include "blockinput.h" 30 #include "buffer.h"31 30 #include "charset.h" 32 31 #include "coding.h" 33 #include "process.h"34 32 35 33 #define CUT_BUFFER_SUPPORT … … 50 48 /* Coding system for communicating with other X clients via cutbuffer, 51 49 selection, and clipboard. */ 52 static Lisp_Object Vselection_coding_system; 53 54 /* Coding system for the next communicating with other X clients. */ 55 static Lisp_Object Vnext_selection_coding_system; 50 static Lisp_Object Vclipboard_coding_system; 56 51 57 52 /* If this is a smaller number than the max-request-size of the display, … … 735 730 x_selection_current_request = 0; 736 731 737 /* Use xfree, not XFree, because lisp_data_to_selection_data732 /* Use free, not XFree, because lisp_data_to_selection_data 738 733 calls xmalloc itself. */ 739 734 if (!nofree) 740 xfree (data);735 free (data); 741 736 } 742 737 unbind_to (count, Qnil); … … 941 936 else 942 937 property_change_wait_list = rest->next; 943 xfree (rest);938 free (rest); 944 939 return; 945 940 } … … 1030 1025 else 1031 1026 property_change_wait_list = rest->next; 1032 xfree (rest);1027 free (rest); 1033 1028 return; 1034 1029 } … … 1174 1169 /* Subroutines of x_get_window_property_as_lisp_data */ 1175 1170 1176 /* Use xfree, not XFree, to free the data obtained with this function. */1171 /* Use free, not XFree, to free the data obtained with this function. */ 1177 1172 1178 1173 static void … … 1257 1252 } 1258 1253 1259 /* Use xfree, not XFree, to free the data obtained with this function. */1254 /* Use free, not XFree, to free the data obtained with this function. */ 1260 1255 1261 1256 static void … … 1319 1314 XSelectInput (display, window, STANDARD_EVENT_SET); 1320 1315 unexpect_property_change (wait_object); 1321 /* Use xfree, not XFree, because x_get_window_property1316 /* Use free, not XFree, because x_get_window_property 1322 1317 calls xmalloc itself. */ 1323 if (tmp_data) xfree (tmp_data);1318 if (tmp_data) free (tmp_data); 1324 1319 break; 1325 1320 } … … 1346 1341 bcopy (tmp_data, (*data_ret) + offset, tmp_size_bytes); 1347 1342 offset += tmp_size_bytes; 1348 /* Use xfree, not XFree, because x_get_window_property1343 /* Use free, not XFree, because x_get_window_property 1349 1344 calls xmalloc itself. */ 1350 xfree (tmp_data);1345 free (tmp_data); 1351 1346 } 1352 1347 } … … 1403 1398 unsigned int min_size_bytes = * ((unsigned int *) data); 1404 1399 BLOCK_INPUT; 1405 /* Use xfree, not XFree, because x_get_window_property1400 /* Use free, not XFree, because x_get_window_property 1406 1401 calls xmalloc itself. */ 1407 xfree ((char *) data);1402 free ((char *) data); 1408 1403 UNBLOCK_INPUT; 1409 1404 receive_incremental_selection (display, window, property, target_type, … … 1423 1418 actual_type, actual_format); 1424 1419 1425 /* Use xfree, not XFree, because x_get_window_property1420 /* Use free, not XFree, because x_get_window_property 1426 1421 calls xmalloc itself. */ 1427 xfree ((char *) data);1422 free ((char *) data); 1428 1423 return val; 1429 1424 } … … 1474 1469 int require_encoding = 0; 1475 1470 1476 if ( 1477 #if 1 1478 1 1479 #else 1480 ! NILP (buffer_defaults.enable_multibyte_characters) 1481 #endif 1482 ) 1471 /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode DATA 1472 to Emacs internal format because DATA may be encoded in 1473 compound text format. In addtion, if TYPE is `STRING' and 1474 DATA contains any 8-bit Latin-1 code, we should also decode 1475 it. */ 1476 if (type == dpyinfo->Xatom_TEXT || type == dpyinfo->Xatom_COMPOUND_TEXT) 1477 require_encoding = 1; 1478 else if (type == XA_STRING) 1483 1479 { 1484 /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode 1485 DATA to Emacs internal format because DATA may be encoded 1486 in compound text format. In addtion, if TYPE is `STRING' 1487 and DATA contains any 8-bit Latin-1 code, we should also 1488 decode it. */ 1489 if (type == dpyinfo->Xatom_TEXT 1490 || type == dpyinfo->Xatom_COMPOUND_TEXT) 1491 require_encoding = 1; 1492 else if (type == XA_STRING) 1480 int i; 1481 for (i = 0; i < size; i++) 1493 1482 { 1494 int i; 1495 for (i = 0; i < size; i++) 1483 if (data[i] >= 0x80) 1496 1484 { 1497 if (data[i] >= 0x80) 1498 { 1499 require_encoding = 1; 1500 break; 1501 } 1485 require_encoding = 1; 1486 break; 1502 1487 } 1503 1488 } 1504 1489 } 1505 1490 if (!require_encoding) 1506 { 1507 str = make_unibyte_string ((char *) data, size); 1508 Vlast_coding_system_used = Qraw_text; 1509 } 1491 str = make_string ((char *) data, size); 1510 1492 else 1511 1493 { 1512 int bufsize ;1494 int bufsize, dummy; 1513 1495 unsigned char *buf; 1514 1496 struct coding_system coding; 1515 1497 1516 if (NILP (Vnext_selection_coding_system))1517 Vnext_selection_coding_system = Vselection_coding_system;1518 1498 setup_coding_system 1519 (Fcheck_coding_system(Vnext_selection_coding_system), &coding); 1520 Vnext_selection_coding_system = Qnil; 1521 coding.mode |= CODING_MODE_LAST_BLOCK; 1499 (Fcheck_coding_system(Vclipboard_coding_system), &coding); 1500 coding.last_block = 1; 1522 1501 bufsize = decoding_buffer_size (&coding, size); 1523 1502 buf = (unsigned char *) xmalloc (bufsize); 1524 decode_coding (&coding, data, buf, size, bufsize); 1525 size = (coding.fake_multibyte 1526 ? multibyte_chars_in_text (buf, coding.produced) 1527 : coding.produced_char); 1528 str = make_string_from_bytes ((char *) buf, size, coding.produced); 1529 xfree (buf); 1530 Vlast_coding_system_used = coding.symbol; 1503 size = decode_coding (&coding, data, buf, size, bufsize, &dummy); 1504 str = make_string ((char *) buf, size); 1505 free (buf); 1531 1506 } 1532 1507 return str; … … 1589 1564 1590 1565 1591 /* Use xfree, not XFree, to free the data obtained with this function. */1566 /* Use free, not XFree, to free the data obtained with this function. */ 1592 1567 1593 1568 static void … … 1631 1606 1632 1607 *format_ret = 8; 1633 *size_ret = STRING_BYTES (XSTRING (obj));1608 *size_ret = XSTRING (obj)->size; 1634 1609 *data_ret = XSTRING (obj)->data; 1635 1610 bzero (charsets, (MAX_CHARSET + 1) * sizeof (int)); 1636 num = ((*size_ret <= 1 /* Check the possibility of short cut. */ 1637 || !STRING_MULTIBYTE (obj) 1638 || *size_ret == XSTRING (obj)->size) 1611 num = ((*size_ret <= 1) /* Check the possibility of short cut. */ 1639 1612 ? 0 1640 : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil , 1));1613 : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil)); 1641 1614 1642 1615 if (!num || (num == 1 && charsets[CHARSET_ASCII])) … … 1645 1618 *nofree_ret = 1; 1646 1619 if (NILP (type)) type = QSTRING; 1647 Vlast_coding_system_used = Qraw_text;1648 1620 } 1649 1621 else … … 1653 1625 expects if OBJ contains only ASCII and Latin-1 1654 1626 characters. */ 1655 int bufsize ;1627 int bufsize, dummy; 1656 1628 unsigned char *buf; 1657 1629 struct coding_system coding; 1658 1630 1659 if (NILP (Vnext_selection_coding_system))1660 Vnext_selection_coding_system = Vselection_coding_system;1661 1631 setup_coding_system 1662 (Fcheck_coding_system (Vnext_selection_coding_system), &coding); 1663 Vnext_selection_coding_system = Qnil; 1664 coding.mode |= CODING_MODE_LAST_BLOCK; 1632 (Fcheck_coding_system (Vclipboard_coding_system), &coding); 1633 coding.last_block = 1; 1665 1634 bufsize = encoding_buffer_size (&coding, *size_ret); 1666 1635 buf = (unsigned char *) xmalloc (bufsize); 1667 encode_coding (&coding, *data_ret, buf, *size_ret, bufsize);1668 *size_ret = coding.produced;1636 *size_ret = encode_coding (&coding, *data_ret, buf, 1637 *size_ret, bufsize, &dummy); 1669 1638 *data_ret = buf; 1670 if (charsets[ charset_latin_iso8859_1]1639 if (charsets[get_charset_id(charset_latin_iso8859_1)] 1671 1640 && (num == 1 || (num == 2 && charsets[CHARSET_ASCII]))) 1672 1641 { … … 1679 1648 if (NILP (type)) type = QCOMPOUND_TEXT; 1680 1649 } 1681 Vlast_coding_system_used = coding.symbol;1682 1650 } 1683 1651 } … … 1942 1910 Time timestamp; 1943 1911 Atom selection_atom; 1944 struct selection_input_event event;1912 XSelectionClearEvent event; 1945 1913 Display *display; 1946 1914 struct x_display_info *dpyinfo; … … 1972 1940 SELECTION_EVENT_SELECTION (&event) = selection_atom; 1973 1941 SELECTION_EVENT_TIME (&event) = timestamp; 1974 x_handle_selection_clear ( (struct input_event *)&event);1942 x_handle_selection_clear (&event); 1975 1943 1976 1944 return Qt; … … 2117 2085 x_get_window_property (display, window, buffer_atom, &data, &bytes, 2118 2086 &type, &format, &size, 0); 2119 if (!data || !format) 2120 return Qnil; 2087 if (!data) return Qnil; 2121 2088 2122 2089 if (format != 8 || type != XA_STRING) … … 2127 2094 2128 2095 ret = (bytes ? make_string ((char *) data, bytes) : Qnil); 2129 /* Use xfree, not XFree, because x_get_window_property2096 /* Use free, not XFree, because x_get_window_property 2130 2097 calls xmalloc itself. */ 2131 xfree (data);2098 free (data); 2132 2099 return ret; 2133 2100 } … … 2161 2128 display, buffer); 2162 2129 data = (unsigned char *) XSTRING (string)->data; 2163 bytes = STRING_BYTES (XSTRING (string));2130 bytes = XSTRING (string)->size; 2164 2131 bytes_remaining = bytes; 2165 2132 … … 2196 2163 DEFUN ("x-rotate-cut-buffers-internal", Fx_rotate_cut_buffers_internal, 2197 2164 Sx_rotate_cut_buffers_internal, 1, 1, 0, 2198 "Rotate the values of the cut buffers by the given number of step .\n\2199 Positive means shift the values forward, negative means backward.")2165 "Rotate the values of the cut buffers by the given number of steps;\n\ 2166 positive means move values forward, negative means backward.") 2200 2167 (n) 2201 2168 Lisp_Object n; … … 2298 2265 Vx_sent_selection_hooks = Qnil; 2299 2266 2300 DEFVAR_LISP (" selection-coding-system", &Vselection_coding_system,2267 DEFVAR_LISP ("clipboard-coding-system", &Vclipboard_coding_system, 2301 2268 "Coding sy
