Mercurial > hg > xemacs-beta
view lisp/menubar.el @ 2720:6fa9919a9a0b
[xemacs-hg @ 2005-04-08 23:10:01 by crestani]
ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* configure.ac (XE_COMPLEX_ARG_ENABLE): Add `--enable-mc-alloc' as
a new configure flag.
* configure.in (AC_INIT_PARSE_ARGS): Add `--mc-alloc' as a new
configure flag.
* configure.usage: Add description for `mc-alloc'.
DUMP_IN_EXEC:
* Makefile.in.in: Condition the installation of a separate dump
file on !DUMP_ON_EXEC.
* configure.ac (XE_COMPLEX_ARG_ENABLE): Add
`--enable-dump-in-exec' as a new configure flag.
* configure.ac: DUMP_IN_EXEC is define as default for PDUMP but
not default for MC_ALLOC.
* configure.in (AC_INIT_PARSE_ARGS): Add `--dump-in-exec' as a
new configure flag.
* configure.in: DUMP_IN_EXEC is define as default for PDUMP but
not default for MC_ALLOC.
* configure.usage: Add description for `dump-in-exec'.
lib-src/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
DUMP_IN_EXEC:
* Makefile.in.in: Only compile insert-data-in-exec if
DUMP_IN_EXEC is defined.
lisp/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
MEMORY_USAGE_STATS
* diagnose.el: Add new lisp function to pretty print statistics
about the new allocator.
* diagnose.el (show-mc-alloc-memory-usage): New.
modules/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
Remove Lcrecords:
* postgresql/postgresql.c (allocate_pgconn): Allocate with new
allocator.
* postgresql/postgresql.c (allocate_pgresult): Allocate PGresult
with new allocator.
* postgresql/postgresql.h (struct Lisp_PGconn): Add
lrecord_header.
* postgresql/postgresql.h (struct Lisp_PGresult): Add
lrecord_header.
* ldap/eldap.c (allocate_ldap): Allocate with new allocator.
* ldap/eldap.h (struct Lisp_LDAP): Add lrecord_header.
nt/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* config.inc.samp: Add new flag `MC_ALLOC'.
* xemacs.mak: Add flag and configuration output for `MC_ALLOC'.
New files:
* xemacs.dsp: Add source files mc-alloc.c and mc-alloc.h.
* xemacs.mak: Add new object file mc-alloc.obj to dependencies.
src/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* config.h.in: Add new flag `MC_ALLOC'.
New files:
* Makefile.in.in: Add new object file mc-alloc.o.
* depend: Add new files to dependencies.
* mc-alloc.c: New.
* mc-alloc.h: New.
Running the new allocator from XEmacs:
* alloc.c (deadbeef_memory): Moved to mc-alloc.c.
* emacs.c (main_1): Initialize the new allocator and add
syms_of_mc_alloc.
* symsinit.h: Add syms_of_mc_alloc.
New lrecord allocation and free functions:
* alloc.c (alloc_lrecord): New. Allocates an lrecord, includes
type checking and initializing of the lrecord_header.
* alloc.c (noseeum_alloc_lrecord): Same as above, but increments
the NOSEEUM cons counter.
* alloc.c (free_lrecord): New. Calls the finalizer and frees the
lrecord.
* lrecord.h: Add lrecord allocation prototypes and comments.
Remove old lrecord FROB block allocation:
* alloc.c (allocate_lisp_storage): Former function to expand
heap. Not needed anymore, remove.
* alloc.c: Completely remove `Fixed-size type macros'
* alloc.c (release_breathing_space): Remove.
* alloc.c (memory_full): Remove release_breathing_space.
* alloc.c (refill_memory_reserve): Remove.
* alloc.c (TYPE_ALLOC_SIZE): Remove.
* alloc.c (DECLARE_FIXED_TYPE_ALLOC): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE_FROM_BLOCK): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE_1): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE): Remove.
* alloc.c (NOSEEUM_ALLOCATE_FIXED_TYPE): Remove.
* alloc.c (struct Lisp_Free): Remove.
* alloc.c (LRECORD_FREE_P): Remove.
* alloc.c (MARK_LRECORD_AS_FREE): Remove.
* alloc.c (MARK_LRECORD_AS_NOT_FREE): Remove.
* alloc.c (PUT_FIXED_TYPE_ON_FREE_LIST): Remove.
* alloc.c (FREE_FIXED_TYPE): Remove.
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC): Remove.
Allocate old lrecords with new allocator:
* alloc.c: DECLARE_FIXED_TYPE_ALLOC removed for all lrecords
defined in alloc.c.
* alloc.c (Fcons): Allocate with new allocator.
* alloc.c (noseeum_cons): Allocate with new allocator.
* alloc.c (make_float): Allocate with new allocator.
* alloc.c (make_bignum): Allocate with new allocator.
* alloc.c (make_bignum_bg): Allocate with new allocator.
* alloc.c (make_ratio): Allocate with new allocator.
* alloc.c (make_ratio_bg): Allocate with new allocator.
* alloc.c (make_ratio_rt): Allocate with new allocator.
* alloc.c (make_bigfloat): Allocate with new allocator.
* alloc.c (make_bigfloat_bf): Allocate with new allocator.
* alloc.c (make_compiled_function): Allocate with new allocator.
* alloc.c (Fmake_symbol): Allocate with new allocator.
* alloc.c (allocate_extent): Allocate with new allocator.
* alloc.c (allocate_event): Allocate with new allocator.
* alloc.c (make_key_data): Allocate with new allocator.
* alloc.c (make_button_data): Allocate with new allocator.
* alloc.c (make_motion_data): Allocate with new allocator.
* alloc.c (make_process_data): Allocate with new allocator.
* alloc.c (make_timeout_data): Allocate with new allocator.
* alloc.c (make_magic_data): Allocate with new allocator.
* alloc.c (make_magic_eval_data): Allocate with new allocator.
* alloc.c (make_eval_data): Allocate with new allocator.
* alloc.c (make_misc_user_data): Allocate with new allocator.
* alloc.c (Fmake_marker): Allocate with new allocator.
* alloc.c (noseeum_make_marker): Allocate with new allocator.
* alloc.c (make_uninit_string): Allocate with new allocator.
* alloc.c (resize_string): Allocate with new allocator.
* alloc.c (make_string_nocopy): Allocate with new allocator.
Garbage Collection:
* alloc.c (GC_CHECK_NOT_FREE): Remove obsolete assertions.
* alloc.c (SWEEP_FIXED_TYPE_BLOCK): Remove.
* alloc.c (SWEEP_FIXED_TYPE_BLOCK_1): Remove.
* alloc.c (sweep_conses): Remove.
* alloc.c (free_cons): Use new allocator to free.
* alloc.c (sweep_compiled_functions): Remove.
* alloc.c (sweep_floats): Remove.
* alloc.c (sweep_bignums): Remove.
* alloc.c (sweep_ratios): Remove.
* alloc.c (sweep_bigfloats): Remove.
* alloc.c (sweep_symbols): Remove.
* alloc.c (sweep_extents): Remove.
* alloc.c (sweep_events): Remove.
* alloc.c (sweep_key_data): Remove.
* alloc.c (free_key_data): Use new allocator to free.
* alloc.c (sweep_button_data): Remove.
* alloc.c (free_button_data): Use new allocator to free.
* alloc.c (sweep_motion_data): Remove.
* alloc.c (free_motion_data): Use new allocator to free.
* alloc.c (sweep_process_data): Remove.
* alloc.c (free_process_data): Use new allocator to free.
* alloc.c (sweep_timeout_data): Remove.
* alloc.c (free_timeout_data): Use new allocator to free.
* alloc.c (sweep_magic_data): Remove.
* alloc.c (free_magic_data): Use new allocator to free.
* alloc.c (sweep_magic_eval_data): Remove.
* alloc.c (free_magic_eval_data): Use new allocator to free.
* alloc.c (sweep_eval_data): Remove.
* alloc.c (free_eval_data): Use new allocator to free.
* alloc.c (sweep_misc_user_data): Remove.
* alloc.c (free_misc_user_data): Use new allocator to free.
* alloc.c (sweep_markers): Remove.
* alloc.c (free_marker): Use new allocator to free.
* alloc.c (garbage_collect_1): Remove release_breathing_space.
* alloc.c (gc_sweep): Remove all the old lcrecord and lrecord
related stuff. Sweeping now works like this: compact string
chars, finalize, sweep.
* alloc.c (common_init_alloc_early): Remove old lrecord
initializations, remove breathing_space.
* emacs.c (Fdump_emacs): Remove release_breathing_space.
* lisp.h: Remove prototype for release_breathing_space.
* lisp.h: Adjust the special cons mark makros.
Lrecord Finalizer:
* alloc.c: Add finalizer to lrecord definition.
* alloc.c (finalize_string): Add finalizer for string.
* bytecode.c: Add finalizer to lrecord definition.
* bytecode.c (finalize_compiled_function): Add finalizer for
compiled function.
* marker.c: Add finalizer to lrecord definition.
* marker.c (finalize_marker): Add finalizer for marker.
These changes build the interface to mc-alloc:
* lrecord.h (MC_ALLOC_CALL_FINALIZER): Tell mc-alloc how to
finalize lrecords.
* lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE): Tell
mc-alloc how to finalize for disksave.
Unify lrecords and lcrecords:
* lisp.h (struct Lisp_String): Adjust string union hack to
new lrecord header.
* lrecord.h: Adjust comments.
* lrecord.h (struct lrecord_header): The new lrecord header
includes type, lisp-readonly, free, and uid.
* lrecord.h (set_lheader_implementation): Adjust to new
lrecord_header.
* lrecord.h (struct lrecord_implementation): The field basic_p
for indication of an old lrecord is not needed anymore, remove.
* lrecord.h (MAKE_LRECORD_IMPLEMENTATION): Remove basic_p.
* lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): Remove
basic_p.
* lrecord.h (copy_sized_lrecord): Remove distinction between
old lrecords and lcrecords.
* lrecord.h (copy_lrecord): Remove distinction between old
lrecords and lcrecords.
* lrecord.h (zero_sized_lrecord): Remove distinction between
old lrecords and lcrecords.
* lrecord.h (zero_lrecord): Remove distinction between old
lrecords and lcrecords.
Remove lcrecords and lcrecord lists:
* alloc.c (basic_alloc_lcrecord): Not needed anymore, remove.
* alloc.c (very_old_free_lcrecord): Not needed anymore, remove.
* alloc.c (copy_lisp_object): No more distinction between
lrecords and lcrecords.
* alloc.c (all_lcrecords): Not needed anymore, remove.
* alloc.c (make_vector_internal): Allocate as lrecord.
* alloc.c (make_bit_vector_internal): Allocate as lrecord.
* alloc.c: Completely remove `lcrecord lists'.
* alloc.c (free_description): Remove.
* alloc.c (lcrecord_list_description): Remove.
* alloc.c (mark_lcrecord_list): Remove.
* alloc.c (make_lcrecord_list): Remove.
* alloc.c (alloc_managed_lcrecord): Remove.
* alloc.c (free_managed_lcrecord): Remove.
* alloc.c (alloc_automanaged_lcrecord): Remove.
* alloc.c (free_lcrecord): Remove.
* alloc.c (lcrecord_stats): Remove.
* alloc.c (tick_lcrecord_stats): Remove.
* alloc.c (disksave_object_finalization_1): Add call to
mc_finalize_for_disksave. Remove the lcrecord way to visit all
objects.
* alloc.c (kkcc_marking): Remove XD_FLAG_FREE_LISP_OBJECT
* alloc.c (sweep_lcrecords_1): Remove.
* alloc.c (common_init_alloc_early): Remove everything related
to lcrecords, remove old lrecord initializations,
* alloc.c (init_lcrecord_lists): Not needed anymore, remove.
* alloc.c (reinit_alloc_early): Remove everything related to
lcrecords.
* alloc.c (init_alloc_once_early): Remove everything related to
lcrecords.
* buffer.c (allocate_buffer): Allocate as lrecord.
* buffer.c (nuke_all_buffer_slots): Use lrecord functions.
* buffer.c (common_init_complex_vars_of_buffer): Allocate as
lrecord.
* buffer.h (struct buffer): Add lrecord_header.
* casetab.c (allocate_case_table): Allocate as lrecord.
* casetab.h (struct Lisp_Case_Table): Add lrecord_header.
* charset.h (struct Lisp_Charset): Add lrecord_header.
* chartab.c (fill_char_table): Use lrecord functions.
* chartab.c (Fmake_char_table): Allocate as lrecord.
* chartab.c (make_char_table_entry): Allocate as lrecord.
* chartab.c (copy_char_table_entry): Allocate as lrecord.
* chartab.c (Fcopy_char_table): Allocate as lrecord.
* chartab.c (put_char_table): Use lrecord functions.
* chartab.h (struct Lisp_Char_Table_Entry): Add lrecord_header.
* chartab.h (struct Lisp_Char_Table): Add lrecord_header.
* console-impl.h (struct console): Add lrecord_header.
* console-msw-impl.h (struct Lisp_Devmode): Add lrecord_header.
* console-msw-impl.h (struct mswindows_dialog_id): Add
lrecord_header.
* console.c (allocate_console): Allocate as lrecord.
* console.c (nuke_all_console_slots): Use lrecord functions.
* console.c (common_init_complex_vars_of_console): Allocate as
lrecord.
* data.c (make_weak_list): Allocate as lrecord.
* data.c (make_weak_box): Allocate as lrecord.
* data.c (make_ephemeron): Allocate as lrecord.
* database.c (struct Lisp_Database): Add lrecord_header.
* database.c (allocate_database): Allocate as lrecord.
* device-impl.h (struct device): Add lrecord_header.
* device-msw.c (allocate_devmode): Allocate as lrecord.
* device.c (nuke_all_device_slots): Use lrecord functions.
* device.c (allocate_device): Allocate as lrecord.
* dialog-msw.c (handle_question_dialog_box): Allocate as lrecord.
* elhash.c (struct Lisp_Hash_Table): Add lrecord_header.
* elhash.c (make_general_lisp_hash_table): Allocate as lrecord.
* elhash.c (Fcopy_hash_table): Allocate as lrecord.
* event-stream.c: Lcrecord lists Vcommand_builder_free_list and
Vtimeout_free_list are no longer needed. Remove.
* event-stream.c (allocate_command_builder): Allocate as lrecord.
* event-stream.c (free_command_builder): Use lrecord functions.
* event-stream.c (event_stream_generate_wakeup): Allocate as
lrecord.
* event-stream.c (event_stream_resignal_wakeup): Use lrecord
functions.
* event-stream.c (event_stream_disable_wakeup): Use lrecord
functions.
* event-stream.c (reinit_vars_of_event_stream): Lcrecord lists
remove.
* events.h (struct Lisp_Timeout): Add lrecord_header.
* events.h (struct command_builder): Add lrecord_header.
* extents-impl.h (struct extent_auxiliary): Add lrecord_header.
* extents-impl.h (struct extent_info): Add lrecord_header.
* extents.c (allocate_extent_auxiliary): Allocate as lrecord.
* extents.c (allocate_extent_info): Allocate as lrecord.
* extents.c (copy_extent): Allocate as lrecord.
* faces.c (allocate_face): Allocate as lrecord.
* faces.h (struct Lisp_Face): Add lrecord_header.
* file-coding.c (allocate_coding_system): Allocate as lrecord.
* file-coding.c (Fcopy_coding_system): Allocate as lrecord.
* file-coding.h (struct Lisp_Coding_System): Add lrecord_header.
* fns.c (Ffillarray): Allocate as lrecord.
* frame-impl.h (struct frame): Add lrecord_header.
* frame.c (nuke_all_frame_slots): Use lrecord functions.
* frame.c (allocate_frame_core): Allocate as lrecord.
* glyphs.c (allocate_image_instance): Allocate as lrecord.
* glyphs.c (Fcolorize_image_instance): Allocate as lrecord.
* glyphs.c (allocate_glyph): Allocate as lrecord.
* glyphs.h (struct Lisp_Image_Instance): Add lrecord_header.
* glyphs.h (struct Lisp_Glyph): Add lrecord_header.
* gui.c (allocate_gui_item): Allocate as lrecord.
* gui.h (struct Lisp_Gui_Item): Add lrecord_header.
* keymap.c (struct Lisp_Keymap): Add lrecord_header.
* keymap.c (make_keymap): Allocate as lrecord.
* lisp.h (struct Lisp_Vector): Add lrecord_header.
* lisp.h (struct Lisp_Bit_Vector): Add lrecord_header.
* lisp.h (struct weak_box): Add lrecord_header.
* lisp.h (struct ephemeron): Add lrecord_header.
* lisp.h (struct weak_list): Add lrecord_header.
* lrecord.h (struct lcrecord_header): Not used, remove.
* lrecord.h (struct free_lcrecord_header): Not used, remove.
* lrecord.h (struct lcrecord_list): Not needed anymore, remove.
* lrecord.h (lcrecord_list): Not needed anymore, remove.
* lrecord.h: (enum data_description_entry_flags): Remove
XD_FLAG_FREE_LISP_OBJECT.
* lstream.c: Lrecord list Vlstream_free_list remove.
* lstream.c (Lstream_new): Allocate as lrecord.
* lstream.c (Lstream_delete): Use lrecod functions.
* lstream.c (reinit_vars_of_lstream): Vlstream_free_list
initialization remove.
* lstream.h (struct lstream): Add lrecord_header.
* emacs.c (main_1): Remove lstream initialization.
* mule-charset.c (make_charset): Allocate as lrecord.
* objects-impl.h (struct Lisp_Color_Instance): Add
lrecord_header.
* objects-impl.h (struct Lisp_Font_Instance): Add lrecord_header.
* objects.c (Fmake_color_instance): Allocate as lrecord.
* objects.c (Fmake_font_instance): Allocate as lrecord.
* objects.c (reinit_vars_of_objects): Allocate as lrecord.
* opaque.c: Lcreord list Vopaque_ptr_list remove.
* opaque.c (make_opaque): Allocate as lrecord.
* opaque.c (make_opaque_ptr): Allocate as lrecord.
* opaque.c (free_opaque_ptr): Use lrecord functions.
* opaque.c (reinit_opaque_early):
* opaque.c (init_opaque_once_early): Vopaque_ptr_list
initialization remove.
* opaque.h (Lisp_Opaque): Add lrecord_header.
* opaque.h (Lisp_Opaque_Ptr): Add lrecord_header.
* emacs.c (main_1): Remove opaque variable initialization.
* print.c (default_object_printer): Use new lrecord_header.
* print.c (print_internal): Use new lrecord_header.
* print.c (debug_p4): Use new lrecord_header.
* process.c (make_process_internal): Allocate as lrecord.
* procimpl.h (struct Lisp_Process): Add lrecord_header.
* rangetab.c (Fmake_range_table): Allocate as lrecord.
* rangetab.c (Fcopy_range_table): Allocate as lrecord.
* rangetab.h (struct Lisp_Range_Table): Add lrecord_header.
* scrollbar.c (create_scrollbar_instance): Allocate as lrecord.
* scrollbar.h (struct scrollbar_instance): Add lrecord_header.
* specifier.c (make_specifier_internal): Allocate as lrecord.
* specifier.h (struct Lisp_Specifier): Add lrecord_header.
* symbols.c:
* symbols.c (Fmake_variable_buffer_local): Allocate as lrecord.
* symbols.c (Fdontusethis_set_symbol_value_handler): Allocate
as lrecord.
* symbols.c (Fdefvaralias): Allocate as lrecord.
* symeval.h (struct symbol_value_magic): Add lrecord_header.
* toolbar.c (update_toolbar_button): Allocate as lrecord.
* toolbar.h (struct toolbar_button): Add lrecord_header.
* tooltalk.c (struct Lisp_Tooltalk_Message): Add lrecord_header.
* tooltalk.c (make_tooltalk_message): Allocate as lrecord.
* tooltalk.c (struct Lisp_Tooltalk_Pattern): Add lrecord_header.
* tooltalk.c (make_tooltalk_pattern): Allocate as lrecord.
* ui-gtk.c (allocate_ffi_data): Allocate as lrecord.
* ui-gtk.c (allocate_emacs_gtk_object_data): Allocate as lrecord.
* ui-gtk.c (allocate_emacs_gtk_boxed_data): Allocate as lrecord.
* ui-gtk.h (structs): Add lrecord_header.
* window-impl.h (struct window): Add lrecord_header.
* window-impl.h (struct window_mirror): Add lrecord_header.
* window.c (allocate_window): Allocate as lrecord.
* window.c (new_window_mirror): Allocate as lrecord.
* window.c (make_dummy_parent): Allocate as lrecord.
MEMORY_USAGE_STATS
* alloc.c (fixed_type_block_overhead): Not used anymore, remove.
* buffer.c (compute_buffer_usage): Get storage size from new
allocator.
* marker.c (compute_buffer_marker_usage): Get storage size from
new allocator.
* mule-charset.c (compute_charset_usage): Get storage size from
new allocator.
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): Get
storage size from new allocator.
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
Get storage size from new allocator.
* scrollbar-x.c (x_compute_scrollbar_instance_usage): Get
storage size from new allocator.
* scrollbar.c (compute_scrollbar_instance_usage): Get storage
size from new allocator.
* unicode.c (compute_from_unicode_table_size_1): Get storage
size from new allocator.
* unicode.c (compute_to_unicode_table_size_1): Get storage size
from new allocator.
* window.c (compute_window_mirror_usage): Get storage size from
new allocator.
* window.c (compute_window_usage): Get storage size from new
allocator.
MC_ALLOC_TYPE_STATS:
* alloc.c (alloc_lrecord): Bump lrecord count.
* alloc.c (noseeum_alloc_lrecord): Bump lrecord count.
* alloc.c (struct lrecord_stats): Storage for counts.
* alloc.c (init_lrecord_stats): Zero statistics.
* alloc.c (inc_lrecord_stats): Increase the statistic.
* alloc.c (dec_lrecord_stats): Decrease the statistic.
* alloc.c (gc_plist_hack): Used to print the information.
* alloc.c (Fgarbage_collect): Return the collected information.
* mc-alloc.c (remove_cell): Decrease lrecord count.
* mc-alloc.h: Set flag MC_ALLOC_TYPE_STATS.
* emacs.c (main_1): Init lrecord statistics.
* lrecord.h: Add prototypes for *_lrecord_stats.
Strings:
* alloc.c (Fmake_string): Initialize ascii_begin to zero.
* alloc.c (gc_count_num_short_string_in_use): Remove.
* alloc.c (gc_count_string_total_size): Remove.
* alloc.c (gc_count_short_string_total_size): Remove.
* alloc.c (debug_string_purity): Remove.
* alloc.c (debug_string_purity_print): Remove.
* alloc.c (sweep_strings): Remove.
Remove static C-readonly Lisp objects:
* alloc.c (c_readonly): Not needed anymore, remove.
* alloc.c (GC_CHECK_LHEADER_INVARIANTS): Remove some obsolete
lheader invariants assertions.
* buffer.c (DEFVAR_BUFFER_LOCAL_1): Allocate dynamically.
* console.c (DEFVAR_CONSOLE_LOCAL_1): Allocate dynamically.
* gpmevent.c: Indirection via MC_ALLOC_Freceive_gpm_event.
* gpmevent.c (Fgpm_enable): Allocate dynamically.
* gpmevent.c (syms_of_gpmevent): Allocate dynamically.
* lisp.h (C_READONLY): Not needed anymore, remove.
* lisp.h (DEFUN): Allocate dynamically.
* lrecord.h (C_READONLY_RECORD_HEADER_P): Not needed anymore,
remove.
* lrecord.h (SET_C_READONLY_RECORD_HEADER): Not needed anymore,
remove.
* symbols.c (guts_of_unbound_marker):
* symeval.h (defsubr): Allocate dynamically.
* symeval.h (DEFSUBR_MACRO): Allocate dynamically.
* symeval.h (DEFVAR_ SYMVAL_FWD): Allocate dynamically.
* tests.c (TESTS_DEFSUBR): Allocate dynamically.
Definition of mcpro:
* lisp.h: Add mcpro prototypes.
* alloc.c (common_init_alloc_early): Add initialization for
mcpros.
* alloc.c (mcpro_description_1): New.
* alloc.c (mcpro_description): New.
* alloc.c (mcpros_description_1): New.
* alloc.c (mcpros_description): New.
* alloc.c (mcpro_one_name_description_1): New.
* alloc.c (mcpro_one_name_description): New.
* alloc.c (mcpro_names_description_1): New.
* alloc.c (mcpro_names_description): New.
* alloc.c (mcpros): New.
* alloc.c (mcpro_names): New.
* alloc.c (mcpro_1): New.
* alloc.c (mc_pro): New.
* alloc.c (garbage_collect_1): Add mcpros to root set.
Usage of mcpro:
* alloc.c (make_string_nocopy): Add string to root set.
* symbols.c (init_symbols_once_early): Add Qunbound to root set.
Changes to the Portable Dumper:
* alloc.c (FREE_OR_REALLOC_BEGIN): Since dumped objects can be
freed with the new allocator, remove assertion for !DUMPEDP.
* dumper.c: Adjust comments, increase PDUMP_HASHSIZE.
* dumper.c (pdump_make_hash): Shift address only 2 bytes, to
avoid collisions.
* dumper.c (pdump_objects_unmark): No more mark bits within
the object, remove.
* dumper.c (mc_addr_elt): New. Element data structure for mc
hash table.
* dumper.c (pdump_mc_hash): New hash table: `lookup table'.
* dumper.c (pdump_get_mc_addr): New. Lookup for hash table.
* dumper.c (pdump_get_indirect_mc_addr): New. Lookup for
convertibles.
* dumper.c (pdump_put_mc_addr): New. Putter for hash table.
* dumper.c (pdump_dump_mc_data): New. Writes the table for
relocation at load time to the dump file.
* dumper.c (pdump_scan_lisp_objects_by_alignment): New.
Visits all dumped Lisp objects.
* dumper.c (pdump_scan_non_lisp_objects_by_alignment): New.
Visits all other dumped objects.
* dumper.c (pdump_reloc_one_mc): New. Updates all pointers
of an object by using the hash table pdump_mc_hash.
* dumper.c (pdump_reloc_one): Replaced by pdump_reloc_one_mc.
* dumper.c (pdump): Change the structure of the dump file, add
the mc post dump relocation table to dump file.
* dumper.c (pdump_load_finish): Hand all dumped objects to the
new allocator and use the mc post dump relocation table for
relocating the dumped objects at dump file load time, free not
longer used data structures.
* dumper.c (pdump_load): Free the dump file.
* dumper.h: Remove pdump_objects_unmark.
* lrecord.h (DUMPEDP): Dumped objects can be freed, remove.
DUMP_IN_EXEC:
* Makefile.in.in: Linking for and with dump in executable only if
DUMP_IN_EXEC is defined.
* config.h.in: Add new flag `DUMP_IN_EXEC'
* emacs.c: Condition dump-data.h on DUMP_IN_EXEC.
* emacs.c (main_1): Flag `-si' only works if dump image is
written into executable.
Miscellanious
* lrecord.h (enum lrecord_type): Added numbers to all types,
very handy for debugging.
* xemacs.def.in.in: Add mc-alloc functions to make them visible
to the modules.
author | crestani |
---|---|
date | Fri, 08 Apr 2005 23:11:35 +0000 |
parents | 979c4c930bb5 |
children | 79c5457563f6 |
line wrap: on
line source
;;; menubar.el --- Menubar support for XEmacs ;; Copyright (C) 1991-4, 1997-1998 Free Software Foundation, Inc. ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp. ;; Copyright (C) 1995, 1996, 2003 Ben Wing. ;; Maintainer: XEmacs Development Team ;; Keywords: internal, extensions, dumped ;; This file is part of XEmacs. ;; XEmacs is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; XEmacs is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with XEmacs; see the file COPYING. If not, write to the ;; Free Software Foundation, 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Synched up with: Not in FSF. (Completely divergent from FSF menu-bar.el) ;;; Commentary: ;; This file is dumped with XEmacs (when menubar support is compiled in). ;; Some stuff in FSF menu-bar.el is in menubar-items.el ;;; Code: (defgroup menu nil "Input from the menus." :group 'environment) (defvar default-menubar nil) ;; this function is considered "part of the lexicon" by many, ;; so we'll leave it here. (defun kill-this-buffer () ; for the menubar "Kill the current buffer." (interactive) (kill-buffer (current-buffer))) (defun set-menubar-dirty-flag () "Tell XEmacs that the menubar has to be updated. NOTE: XEmacs now recognizes when you set a different value for `current-menubar'. You *only* need to call this function if you destructively modify a part of the menubar and don't set `current-menubar'. Note that all the functions that modify a menu call this automatically." (setq-default current-menubar (default-value 'current-menubar))) ;; #### shouldn't this perhaps be `copy-tree'? (defun set-menubar (menubar) "Set the default menubar to be MENUBAR. See `current-menubar' for a description of the syntax of a menubar." (check-menu-syntax menubar t) (setq-default current-menubar (copy-sequence menubar))) (defun set-buffer-menubar (menubar) "Set the buffer-local menubar to be MENUBAR. See `current-menubar' for a description of the syntax of a menubar." (check-menu-syntax menubar t) (make-local-variable 'current-menubar) (setq current-menubar (copy-sequence menubar))) (defun check-menu-syntax (menu &optional menubar-p) ;; The C code does syntax checking on the value of `current-menubar', ;; but it's better to do it early, before things have gotten messed up. (if menubar-p nil (or (stringp (car menu)) (signal 'error (list "menu name (first element) must be a string" menu))) ;;(or (cdr menu) (signal 'error (list "menu is empty" menu))) (setq menu (cdr menu))) (let (menuitem item) (while (keywordp (setq item (car menu))) (or (memq item '(:config :included :filter :accelerator)) (signal 'error (list "menu keyword must be :config, :included, :accelerator or :filter" item))) (if (or (not (cdr menu)) (vectorp (nth 1 menu)) (keywordp (nth 1 menu))) (signal 'error (list "strange keyword value" item (nth 1 menu)))) (setq menu (nthcdr 2 menu))) (while menu (setq menuitem (car menu)) (cond ((stringp menuitem) (and (string-match "^\\(-+\\|=+\\):\\(.*\\)" menuitem) (setq item (match-string 2 menuitem)) (or (member item '(;; Motif-compatible "singleLine" "doubleLine" "singleDashedLine" "doubleDashedLine" "noLine" "shadowEtchedIn" "shadowEtchedOut" "shadowEtchedInDash" "shadowEtchedOutDash" ;; non-Motif (Lucid menubar widget only) "shadowDoubleEtchedIn" "shadowDoubleEtchedOut" "shadowDoubleEtchedInDash" "shadowDoubleEtchedOutDash" )) (signal 'error (list "bogus separator style in menu item" item))) )) ((null menuitem) (or menubar-p (signal 'error (list "nil is only permitted in the top level of menubars")))) ((consp menuitem) (check-menu-syntax menuitem)) ((vectorp menuitem) (let ((L (length menuitem)) plistp) (and (< L 2) (signal 'error (list "button descriptors must be at least 2 long" menuitem))) (setq plistp (or (>= L 5) (and (> L 2) (keywordp (aref menuitem 2))))) (if plistp (let ((i 2) selp style item) (while (< i L) (setq item (aref menuitem i)) (cond ((not (memq item '(:active :suffix :keys :style :full :included :selected :accelerator))) (signal 'error (list (if (keywordp item) "unknown menu item keyword" "not a keyword") item menuitem))) ((eq item :style) (setq style (aref menuitem (1+ i))) (or (memq style '(nil toggle radio button text)) (signal 'error (list "unknown style" style menuitem)))) ((eq item :selected) (setq selp t)) ) (setq i (+ i (if (eq item :full) 1 2)))) (if (and selp (not (memq style '(toggle button radio)))) (signal 'error (list ":selected only makes sense with :style toggle, radio, or button" menuitem))) ))) ) ;; (t (signal 'error (list "unrecognized menu descriptor" menuitem)))) (t (message "unrecognized menu descriptor %s" (prin1-to-string menuitem)))) (setq menu (cdr menu))))) ;;; basic menu manipulation functions (defun menu-item-text (item &optional normalize) "Return the text that is displayed for a menu item. If ITEM is a string (unselectable text), it is returned; otherwise, the first element of the cons or vector is returned. If NORMALIZE is non-nil, pass the text through `normalize-menu-text' before being returned, to remove accelerator specs and convert %% to %." (let ((val (if (stringp item) item (elt item 0)))) (if normalize (normalize-menu-text val) val))) (defun find-menu-item (menubar item-path-list) "Search MENUBAR for item given by ITEM-PATH-LIST. Returns (ITEM . PARENT), where PARENT is the immediate parent of the item found. If the item does not exist, the car of the returned value is nil. If some menu in the ITEM-PATH-LIST does not exist, an error is signalled." (find-menu-item-1 menubar item-path-list)) (defun find-menu-item-1 (menubar item-path-list &optional parent) (check-argument-type 'listp item-path-list) (if (not (consp menubar)) nil (let ((rest menubar) result) (when (stringp (car rest)) (setq rest (cdr rest))) (while (keywordp (car rest)) (setq rest (cddr rest))) (while rest (if (and (car rest) (stringp (car item-path-list)) (= 0 (compare-menu-text (car item-path-list) (menu-item-text (car rest))))) (setq result (car rest) rest nil) (setq rest (cdr rest)))) (if (cdr item-path-list) (cond ((consp result) (find-menu-item-1 (cdr result) (cdr item-path-list) result)) (result (signal 'error (list (gettext "not a submenu") result))) (t (signal 'error (list (gettext "no such submenu") (car item-path-list))))) (cons result parent))))) (defun add-menu-item-1 (leaf-p menu-path new-item before in-menu) ;; This code looks like it could be cleaned up some more ;; Do we really need 6 calls to find-menu-item? (let* ((item-name (cond ((vectorp new-item) (aref new-item 0)) ((consp new-item) (car new-item)) (t nil))) (menubar (or in-menu current-menubar)) (menu (condition-case () (car (find-menu-item menubar menu-path)) (error nil))) (item-found (cond ((null item-name) nil) ((not (listp menu)) (signal 'error (list (gettext "not a submenu") menu-path))) (menu (find-menu-item (cdr menu) (list item-name))) (t (find-menu-item menubar (list item-name))) ))) (unless menubar (error "`current-menubar' is nil: can't add menus to it.")) (unless menu (let ((rest menu-path) (so-far menubar)) (while rest ;;; (setq menu (car (find-menu-item (cdr so-far) (list (car rest))))) (setq menu (if (eq so-far menubar) (car (find-menu-item so-far (list (car rest)))) (car (find-menu-item (cdr so-far) (list (car rest)))))) (unless menu (let ((rest2 so-far)) (while (and (cdr rest2) (car (cdr rest2))) (setq rest2 (cdr rest2))) (setcdr rest2 (nconc (list (setq menu (list (car rest)))) (cdr rest2))))) (setq so-far menu) (setq rest (cdr rest))))) (if (and item-found (car item-found)) ;; hack the item in place. (if menu ;; Isn't it very bad form to use nsubstitute for side effects? (nsubstitute new-item (car item-found) menu) (setq current-menubar (nsubstitute new-item (car item-found) current-menubar))) ;; OK, we have to add the whole thing... ;; if BEFORE is specified, try to add it there. (unless menu (setq menu current-menubar)) (when before (setq before (car (find-menu-item menu (list before))))) (let ((rest menu) (added-before nil)) (while rest (if (eq before (car (cdr rest))) (progn (setcdr rest (cons new-item (cdr rest))) (setq rest nil added-before t)) (setq rest (cdr rest)))) (when (not added-before) ;; adding before the first item on the menubar itself is harder (if (and (eq menu menubar) (eq before (car menu))) (setq menu (cons new-item menu) current-menubar menu) ;; otherwise, add the item to the end. (nconc menu (list new-item)))))) (set-menubar-dirty-flag) new-item)) (defun add-menu-button (menu-path menu-leaf &optional before in-menu) "Add a menu item to some menu, creating the menu first if necessary. If the named item exists already, it is changed. MENU-PATH identifies the menu under which the new menu item should be inserted. It is a list of strings; for example, (\"File\") names the top-level \"File\" menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". MENU-LEAF is a menubar leaf node. See the documentation of `current-menubar'. BEFORE, if provided, is the name of a menu item before which this item should be added, if this item is not on the menu already. If the item is already present, it will not be moved. IN-MENU, if provided, means use that instead of `current-menubar' as the menu to change." ;; Note easymenu.el uses the fact that menu-leaf can be a submenu. (add-menu-item-1 t menu-path menu-leaf before in-menu)) ;; I actually liked the old name better, but the interface has changed too ;; drastically to keep it. --Stig (defun add-submenu (menu-path submenu &optional before in-menu) "Add a menu to the menubar or one of its submenus. If the named menu exists already, it is changed. MENU-PATH identifies the menu under which the new menu should be inserted. It is a list of strings; for example, (\"File\") names the top-level \"File\" menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". If MENU-PATH is nil, then the menu will be added to the menubar itself. SUBMENU is the new menu to add. See the documentation of `current-menubar' for the syntax. BEFORE, if provided, is the name of a menu before which this menu should be added, if this menu is not on its parent already. If the menu is already present, it will not be moved. IN-MENU, if provided, means use that instead of `current-menubar' as the menu to change." (check-menu-syntax submenu nil) (add-menu-item-1 nil menu-path submenu before in-menu)) ;; purespace is no more, so this function is unnecessary ;(defun purecopy-menubar (x) ; ;; this calls purecopy on the strings, and the contents of the vectors, ; ;; but not on the vectors themselves, or the conses - those must be ; ;; writable. ; (cond ((vectorp x) ; (let ((i (length x))) ; (while (> i 0) ; (aset x (1- i) (purecopy (aref x (1- i)))) ; (setq i (1- i)))) ; x) ; ((consp x) ; (let ((rest x)) ; (while rest ; (setcar rest (purecopy-menubar (car rest))) ; (setq rest (cdr rest)))) ; x) ; (t ; (purecopy x)))) (defun delete-menu-item (path &optional from-menu) "Remove the named menu item from the menu hierarchy. PATH is a list of strings which identify the position of the menu item in the menu hierarchy. The documentation of `add-submenu' describes menu paths. FROM-MENU, if provided, means use that instead of `current-menubar' as the menu to change." (let* ((pair (condition-case nil (find-menu-item (or from-menu current-menubar) path) (error nil))) (item (car pair)) (parent (or (cdr pair) current-menubar))) (if (not item) nil ;; the menubar is the only special case, because other menus begin ;; with their name. (if (eq parent current-menubar) (setq current-menubar (delq item parent)) (delq item parent)) (set-menubar-dirty-flag) item))) (defun relabel-menu-item (path new-name) "Change the string of the specified menu item. PATH is a list of strings which identify the position of the menu item in the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the menu item called \"Item\" under the \"Foo\" submenu of \"Menu\". NEW-NAME is the string that the menu item will be printed as from now on." (check-type new-name string) (let* ((menubar current-menubar) (pair (find-menu-item menubar path)) (item (car pair)) (menu (cdr pair))) (or item (signal 'error (list (if menu (gettext "No such menu item") (gettext "No such menu")) path))) (if (and (consp item) (stringp (car item))) (setcar item new-name) (aset item 0 new-name)) (set-menubar-dirty-flag) item)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; these are all bad style. Why in the world would we put evaluable forms ;; into the menubar if we didn't want people to use 'em? ;; x-font-menu.el is the only known offender right now and that ought to be ;; rehashed a bit. ;; (defun enable-menu-item-1 (path toggle-p on-p) (let (menu item) (if (and (vectorp path) (> (length path) 2)) ; limited syntax checking... (setq item path) (let* ((menubar current-menubar) (pair (find-menu-item menubar path))) (setq item (car pair) menu (cdr pair)) (or item (signal 'error (list (if menu "No such menu item" "No such menu") path))) (if (consp item) (error "%S is a menu, not a menu item" path)))) (if (or (> (length item) 4) (and (symbolp (aref item 2)) (= ?: (aref (symbol-name (aref item 2)) 0)))) ;; plist-like syntax (let ((i 2) (keyword (if toggle-p :selected :active)) (ok nil)) (while (< i (length item)) (cond ((eq (aref item i) keyword) (aset item (1+ i) on-p) (setq ok t))) (setq i (+ i 2))) (cond (ok nil) (toggle-p (signal 'error (list "not a toggle menu item" item))) (t ;; Need to copy the item to extend it, sigh... (let ((cons (memq item menu)) (new-item (vconcat item (list keyword on-p)))) (if cons (setcar cons (setq item new-item)) (if menu (error "couldn't find %S on its parent?" item) (error "no %S slot to set: %S" keyword item))))))) ;; positional syntax (if toggle-p (signal 'error (list "not a toggle menu item" item)) (aset item 2 on-p))) (set-menubar-dirty-flag) item)) (defun enable-menu-item (path) "Make the named menu item be selectable. PATH is a list of strings which identify the position of the menu item in the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." (enable-menu-item-1 path nil t)) (defun disable-menu-item (path) "Make the named menu item be unselectable. PATH is a list of strings which identify the position of the menu item in the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." (enable-menu-item-1 path nil nil)) (defun select-toggle-menu-item (path) "Make the named toggle- or radio-style menu item be in the `selected' state. PATH is a list of strings which identify the position of the menu item in the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." (enable-menu-item-1 path t t)) (defun deselect-toggle-menu-item (path) "Make the named toggle- or radio-style menu item be in the `unselected' state. PATH is a list of strings which identify the position of the menu item in the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." (enable-menu-item-1 path t nil)) ;;; functions for manipulating whole menus -- adding accelerators, sorting, ;;; splitting long menus, etc. (defun submenu-generate-accelerator-spec (list &optional omit-chars-list) "Add auto-generated accelerator specifications to a submenu. This can be used to add accelerators to the return value of a menu filter function. It correctly ignores unselectable items. It will destructively modify the list passed to it. If an item already has an auto-generated accelerator spec, this will be removed before the new one is added, making this function idempotent. If OMIT-CHARS-LIST is given, it should be a list of lowercase characters, which will not be used as accelerators." (let ((n 0)) (dolist (item list list) (cond ((or (vectorp item) (consp item)) (incf n) (setf (elt item 0) (concat (menu-item-generate-accelerator-spec n omit-chars-list) (menu-item-strip-accelerator-spec (elt item 0))))))))) (defun menu-item-strip-accelerator-spec (item) "Strip an auto-generated accelerator spec off of ITEM. ITEM should be a string. This removes specs added by `menu-item-generate-accelerator-spec' and `submenu-generate-accelerator-spec'." (if (string-match "%_. " item) (substring item 4) item)) (defun menu-item-generate-accelerator-spec (n &optional omit-chars-list) "Return an accelerator specification for use with auto-generated menus. This should be concat'd onto the beginning of each menu line. The spec allows the Nth line to be selected by the number N. '0' is used for the 10th line, and 'a' through 'z' are used for the following 26 lines. If OMIT-CHARS-LIST is given, it should be a list of lowercase characters, which will not be used as accelerators." (cond ((< n 10) (concat "%_" (int-to-string n) " ")) ((= n 10) "%_0 ") ((<= n 36) (setq n (- n 10)) (let ((m 0)) (while (> n 0) (setq m (1+ m)) (while (memq (int-to-char (+ m (- (char-to-int ?a) 1))) omit-chars-list) (setq m (1+ m))) (setq n (1- n))) (if (<= m 26) (concat "%_" (char-to-string (int-to-char (+ m (- (char-to-int ?a) 1)))) " ") ""))) (t ""))) (defcustom menu-max-items 25 "*Maximum number of items in generated menus. If number of entries in such a menu is larger than this value, split menu into submenus of nearly equal length (see `menu-submenu-max-items'). If nil, never split menu into submenus." :group 'menu :type '(choice (const :tag "no submenus" nil) (integer))) (defcustom menu-submenu-max-items 20 "*Maximum number of items in submenus when splitting menus. We split large menus into submenus of this many items, and then balance them out as much as possible (otherwise the last submenu may have very few items)." :group 'menu :type 'integer) (defcustom menu-submenu-name-format "%-12.12s ... %.12s" "*Format specification of the submenu name when splitting menus. Used by `menu-split-long-menu' if the number of entries in a menu is larger than `menu-menu-max-items'. This string should contain one %s for the name of the first entry and one %s for the name of the last entry in the submenu. If the value is a function, it should return the submenu name. The function is be called with two arguments, the names of the first and the last entry in the menu." :group 'menu :type '(choice (string :tag "Format string") (function))) (defun menu-split-long-menu-and-sort (menu) "Sort MENU, split according to `menu-max-items' and add accelerator specs. This is useful for menus generated by filter functions, to make them look nice. This is equivalent to \(menu-split-long-menu (menu-sort-menu menu)) and you can call those functions individually if necessary. You can also call `submenu-generate-accelerator-spec' yourself to add accelerator specs -- this works even if the specs have already been added." (menu-split-long-menu (menu-sort-menu menu))) (defun menu-split-long-menu (menu) "Split MENU according to `menu-max-items' and add accelerator specs. If MENU already has accelerator specs, they will be removed and new ones generated. You should normally use `menu-split-long-menu-and-sort' instead. The menu should already be sorted to get meaningful results when it is split, since the outer menus are of the format `FROM ... TO'." (let ((len (length menu))) (if (or (null menu-max-items) (<= len menu-max-items)) (submenu-generate-accelerator-spec menu) (let* ((outer (/ (+ len (1- menu-submenu-max-items)) menu-submenu-max-items)) (inner (/ (+ len (1- outer)) outer)) (result nil)) (while menu (let ((sub nil) (from (car menu))) (dotimes (foo (min inner len)) (setq sub (cons (car menu) sub) menu (cdr menu))) (setq len (- len inner)) (let* ((to (car sub)) (ftext (menu-item-strip-accelerator-spec (menu-item-text from))) (ttext (menu-item-strip-accelerator-spec (menu-item-text to)))) (setq sub (nreverse sub)) (setq result (cons (cons (if (stringp menu-submenu-name-format) (format menu-submenu-name-format ftext ttext) (funcall menu-submenu-name-format ftext ttext)) (submenu-generate-accelerator-spec sub)) result))))) (submenu-generate-accelerator-spec (nreverse result)))))) (defun menu-sort-menu (menu) "Sort MENU alphabetically. You should normally use `menu-split-long-menu-and-sort' instead." (sort menu #'(lambda (a b) (< (compare-menu-text (menu-item-text a) (menu-item-text b)) 0)))) ;;;;;;; popup menus (defvar global-popup-menu nil "The global popup menu. This is present in all modes. See the function `popup-menu' for a description of menu syntax.") (defvar mode-popup-menu nil "The mode-specific popup menu. Automatically buffer local. This is appended to the default items in `global-popup-menu'. See the function `popup-menu' for a description of menu syntax.") (make-variable-buffer-local 'mode-popup-menu) (defvar activate-popup-menu-hook nil "Function or functions run before a mode-specific popup menu is made visible. These functions are called with no arguments, and should interrogate and modify the value of `global-popup-menu' or `mode-popup-menu' as desired. Note: this hook is only run if you use `popup-mode-menu' for activating the global and mode-specific commands; if you have your own binding for button3, this hook won't be run.") (defvar last-popup-menu-event nil "The mouse event that invoked the last popup menu. NOTE: This is EXPERIMENTAL and may change at any time.") (defun popup-mode-menu (&optional event) "Pop up a menu of global and mode-specific commands. The menu is computed by combining `global-popup-menu' and `mode-popup-menu' with any items derived from the `context-menu' property of the extent where the button was clicked." (interactive "_e") (setq last-popup-menu-event (or (and event (button-event-p event) event) (let* ((mouse-pos (mouse-position)) (win (car mouse-pos)) (x (cadr mouse-pos)) (y (cddr mouse-pos)) (edges (window-pixel-edges win)) (winx (first edges)) (winy (second edges)) (x (+ x winx)) (y (+ y winy))) (make-event 'button-press `(button 3 x ,x y ,y channel ,(window-frame win) timestamp ,(current-event-timestamp (cdfw-console win))))))) (run-hooks 'activate-popup-menu-hook) (let* ((context-window (and event (event-window event))) (context-point (and event (event-point event))) (context-extents (and context-window context-point (extents-at context-point (window-buffer context-window) 'context-menu))) (context-menu-items (apply 'append (mapcar #'(lambda (extent) (extent-property extent 'context-menu)) context-extents)))) (popup-menu (progn ;; Merge global-popup-menu and mode-popup-menu (and mode-popup-menu (check-menu-syntax mode-popup-menu)) (let* ((mode-title (and (stringp (car mode-popup-menu)) (car mode-popup-menu))) (mode-items (if mode-title (cdr mode-popup-menu) mode-popup-menu)) (global-title (and (stringp (car global-popup-menu)) (car global-popup-menu))) (global-items (if global-title (cdr global-popup-menu) global-popup-menu)) mode-filters) ;; Strip keywords from local menu for attaching them at the top (while (and mode-items (keywordp (car mode-items))) ;; Push both keyword and its argument. (push (pop mode-items) mode-filters) (push (pop mode-items) mode-filters)) (setq mode-filters (nreverse mode-filters)) ;; If mode-filters contains a keyword already present in ;; `global-popup-menu', you will probably lose. (append (and popup-menu-titles (cond (mode-title (list mode-title)) (global-title (list global-title)) (t ""))) mode-filters context-menu-items (and context-menu-items mode-items '("---")) mode-items (and (or context-menu-items mode-items) global-items '("---" "---")) (and global-title (list global-title)) global-items )))) (while (popup-up-p) (dispatch-event (next-event))) )) (defun popup-buffer-menu (event) "Pop up a copy of the menubar Buffers menu where the mouse is clicked." (interactive "e") (let ((window (and (event-over-text-area-p event) (event-window event))) (bmenu nil)) (or window (error "Pointer must be in a normal window")) (select-window window) (if current-menubar (setq bmenu (assoc "%_Buffers" current-menubar))) (if (null bmenu) (setq bmenu (assoc "%_Buffers" default-menubar))) (if (null bmenu) (error "Can't find the Buffers menu")) (popup-menu bmenu))) (defun popup-menubar-menu (event) "Pop up a copy of menu that also appears in the menubar." (interactive "e") (let ((window (and (event-over-text-area-p event) (event-window event))) popup-menubar) (or window (error "Pointer must be in a normal window")) (select-window window) (and current-menubar (run-hooks 'activate-menubar-hook)) ;; #### Instead of having to copy this just to safely get rid of ;; any nil what we should really do is fix up the internal menubar ;; code to just ignore nil if generating a popup menu (setq popup-menubar (delete nil (copy-sequence (or current-menubar default-menubar)))) (popup-menu (cons "%_Menubar Menu" popup-menubar)) )) (defun menu-call-at-event (form &optional event default-behavior-fallback) "Call FORM while temporarily setting point to the position in EVENT. NOTE: This is EXPERIMENTAL and may change at any time. FORM is called the way forms in menu specs are: i.e. if a symbol, it's called with `call-interactively', otherwise with `eval'. EVENT defaults to `last-popup-menu-event', making this function especially useful in popup menus. The buffer and point are set temporarily within a `save-excursion'. If EVENT is not a mouse event, or was not over a buffer, nothing happens unless DEFAULT-BEHAVIOR-FALLBACK is non-nil, in which case the FORM is called normally." (or event (setq event last-popup-menu-event)) (let ((buf (event-buffer event)) (p (event-closest-point event))) (cond ((and buf p (> p 0)) (save-excursion (set-buffer buf) (goto-char p) (if (symbolp form) (call-interactively form) (eval form)))) (default-behavior-fallback (if (symbolp form) (call-interactively form) (eval form)))))) (global-set-key 'button3 'popup-mode-menu) ;; shift button3 and shift button2 are reserved for Hyperbole (global-set-key '(meta control button3) 'popup-buffer-menu) ;; The following command is way too dangerous with Custom. ;; (global-set-key '(meta shift button3) 'popup-menubar-menu) ;; Here's a test of the cool new menu features (from Stig). ;;(setq mode-popup-menu ;; '("Test Popup Menu" ;; :filter cdr ;; ["this item won't appear because of the menu filter" ding t] ;; "--:singleLine" ;; "singleLine" ;; "--:doubleLine" ;; "doubleLine" ;; "--:singleDashedLine" ;; "singleDashedLine" ;; "--:doubleDashedLine" ;; "doubleDashedLine" ;; "--:noLine" ;; "noLine" ;; "--:shadowEtchedIn" ;; "shadowEtchedIn" ;; "--:shadowEtchedOut" ;; "shadowEtchedOut" ;; "--:shadowDoubleEtchedIn" ;; "shadowDoubleEtchedIn" ;; "--:shadowDoubleEtchedOut" ;; "shadowDoubleEtchedOut" ;; "--:shadowEtchedInDash" ;; "shadowEtchedInDash" ;; "--:shadowEtchedOutDash" ;; "shadowEtchedOutDash" ;; "--:shadowDoubleEtchedInDash" ;; "shadowDoubleEtchedInDash" ;; "--:shadowDoubleEtchedOutDash" ;; "shadowDoubleEtchedOutDash" ;; )) (defun get-popup-menu-response (menu-desc &optional event) "Pop up the given menu and wait for a response. This blocks until the response is received, and returns the misc-user event that encapsulates the response. To execute it, you can do (funcall (event-function response) (event-object response)) If no response was received, nil is returned. MENU-DESC and EVENT are as in the call to `popup-menu'." ;; partially stolen from w3 ;; This function is way gross and assumes to much about menu ;; processing that is X specific. Under mswindows popup menus behave ;; in reasonable ways that you can't obstruct. (let ((echo-keystrokes 0) new-event) (popup-menu menu-desc event) (catch 'popup-done (while t (setq new-event (next-command-event new-event)) (cond ((misc-user-event-p new-event) (throw 'popup-done new-event)) ((button-release-event-p new-event);; don't beep twice nil) ;; It shows how bogus this function is that the event ;; arg could be missing and no-one noticed ... ((event-matches-key-specifier-p new-event (quit-char)) (signal 'quit nil)) ;; mswindows has no pop-down processing (selection is ;; atomic) so doing anything more makes no sense. Since ;; popup-up-p is always false under mswindows, this ;; function has been ordered to do essentially X-specifc ;; processing after this check. ((not (popup-up-p)) (setq unread-command-events (cons new-event unread-command-events)) (throw 'popup-done nil)) ;; mswindows never gets here (t (beep) (message "please make a choice from the menu."))))))) (defun popup-menu-and-execute-in-window (menu-desc event) "Pop up the given menu and execute its response in EVENT's window. This blocks until the response is received, temporarily selects EVENT's window, and executes the command specified in the response. EVENT can also be a window. See `popup-menu' for the semantics of MENU-DESC." (let ((response (get-popup-menu-response menu-desc (and (eventp event) event)))) (and (misc-user-event-p response) (save-selected-window (select-window (if (windowp event) event (event-window event))) (funcall (event-function response) (event-object response)))))) ;; provide default bindings for menu accelerator map (and (boundp 'menu-accelerator-map) (keymapp menu-accelerator-map) (progn (define-key menu-accelerator-map "\e" 'menu-escape) (define-key menu-accelerator-map [left] 'menu-left) (define-key menu-accelerator-map [right] 'menu-right) (define-key menu-accelerator-map [up] 'menu-up) (define-key menu-accelerator-map [down] 'menu-down) (define-key menu-accelerator-map [return] 'menu-select) (define-key menu-accelerator-map [kp-down] 'menu-down) (define-key menu-accelerator-map [kp-up] 'menu-down) (define-key menu-accelerator-map [kp-left] 'menu-left) (define-key menu-accelerator-map [kp-right] 'menu-right) (define-key menu-accelerator-map [kp-enter] 'menu-select) (define-key menu-accelerator-map "\C-g" 'menu-quit))) (provide 'menubar) ;;; menubar.el ends here