annotate lisp/modeline.el @ 4981:4aebb0131297

Cleanups/renaming of EXTERNAL_TO_C_STRING and friends -------------------- ChangeLog entries follow: -------------------- modules/ChangeLog addition: 2010-02-05 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: * postgresql/postgresql.c (CHECK_LIVE_CONNECTION): * postgresql/postgresql.c (Fpq_connectdb): * postgresql/postgresql.c (Fpq_connect_start): * postgresql/postgresql.c (Fpq_lo_import): * postgresql/postgresql.c (Fpq_lo_export): * ldap/eldap.c (Fldap_open): * ldap/eldap.c (Fldap_search_basic): * ldap/eldap.c (Fldap_add): * ldap/eldap.c (Fldap_modify): * ldap/eldap.c (Fldap_delete): * canna/canna_api.c (Fcanna_initialize): * canna/canna_api.c (Fcanna_store_yomi): * canna/canna_api.c (Fcanna_parse): * canna/canna_api.c (Fcanna_henkan_begin): EXTERNAL_TO_C_STRING returns its argument instead of storing it in a parameter, and is renamed to EXTERNAL_TO_ITEXT. Similar things happen to related macros. See entry in src/ChangeLog. More Mule-izing of postgresql.c. Extract out common code between `pq-connectdb' and `pq-connect-start'. Fix places that signal an error string using a formatted string to instead follow the standard and have a fixed reason followed by the particular error message stored as one of the frobs. src/ChangeLog addition: 2010-02-05 Ben Wing <ben@xemacs.org> * console-msw.c (write_string_to_mswindows_debugging_output): * console-msw.c (Fmswindows_message_box): * console-x.c (x_perhaps_init_unseen_key_defaults): * console.c: * database.c (dbm_get): * database.c (dbm_put): * database.c (dbm_remove): * database.c (berkdb_get): * database.c (berkdb_put): * database.c (berkdb_remove): * database.c (Fopen_database): * device-gtk.c (gtk_init_device): * device-msw.c (msprinter_init_device_internal): * device-msw.c (msprinter_default_printer): * device-msw.c (msprinter_init_device): * device-msw.c (sync_printer_with_devmode): * device-msw.c (Fmsprinter_select_settings): * device-x.c (sanity_check_geometry_resource): * device-x.c (Dynarr_add_validified_lisp_string): * device-x.c (x_init_device): * device-x.c (Fx_put_resource): * device-x.c (Fx_valid_keysym_name_p): * device-x.c (Fx_set_font_path): * dialog-msw.c (push_lisp_string_as_unicode): * dialog-msw.c (handle_directory_dialog_box): * dialog-msw.c (handle_file_dialog_box): * dialog-x.c (dbox_descriptor_to_widget_value): * editfns.c (Fformat_time_string): * editfns.c (Fencode_time): * editfns.c (Fset_time_zone_rule): * emacs.c (make_argc_argv): * emacs.c (Fdump_emacs): * emodules.c (emodules_load): * eval.c: * eval.c (maybe_signal_error_1): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (mswindows_wnd_proc): * fileio.c (report_error_with_errno): * fileio.c (Fsysnetunam): * fileio.c (Fdo_auto_save): * font-mgr.c (extract_fcapi_string): * font-mgr.c (Ffc_config_app_font_add_file): * font-mgr.c (Ffc_config_app_font_add_dir): * font-mgr.c (Ffc_config_filename): * frame-gtk.c (gtk_set_frame_text_value): * frame-gtk.c (gtk_create_widgets): * frame-msw.c (mswindows_init_frame_1): * frame-msw.c (mswindows_set_title_from_ibyte): * frame-msw.c (msprinter_init_frame_3): * frame-x.c (x_set_frame_text_value): * frame-x.c (x_set_frame_properties): * frame-x.c (start_drag_internal_1): * frame-x.c (x_cde_transfer_callback): * frame-x.c (x_create_widgets): * glyphs-eimage.c (my_jpeg_output_message): * glyphs-eimage.c (jpeg_instantiate): * glyphs-eimage.c (gif_instantiate): * glyphs-eimage.c (png_instantiate): * glyphs-eimage.c (tiff_instantiate): * glyphs-gtk.c (xbm_instantiate_1): * glyphs-gtk.c (gtk_xbm_instantiate): * glyphs-gtk.c (gtk_xpm_instantiate): * glyphs-gtk.c (gtk_xface_instantiate): * glyphs-gtk.c (cursor_font_instantiate): * glyphs-gtk.c (gtk_redisplay_widget): * glyphs-gtk.c (gtk_widget_instantiate_1): * glyphs-gtk.c (gtk_add_tab_item): * glyphs-msw.c (mswindows_xpm_instantiate): * glyphs-msw.c (bmp_instantiate): * glyphs-msw.c (mswindows_resource_instantiate): * glyphs-msw.c (xbm_instantiate_1): * glyphs-msw.c (mswindows_xbm_instantiate): * glyphs-msw.c (mswindows_xface_instantiate): * glyphs-msw.c (mswindows_redisplay_widget): * glyphs-msw.c (mswindows_widget_instantiate): * glyphs-msw.c (add_tree_item): * glyphs-msw.c (add_tab_item): * glyphs-msw.c (mswindows_combo_box_instantiate): * glyphs-msw.c (mswindows_widget_query_string_geometry): * glyphs-x.c (x_locate_pixmap_file): * glyphs-x.c (xbm_instantiate_1): * glyphs-x.c (x_xbm_instantiate): * glyphs-x.c (extract_xpm_color_names): * glyphs-x.c (x_xpm_instantiate): * glyphs-x.c (x_xface_instantiate): * glyphs-x.c (autodetect_instantiate): * glyphs-x.c (safe_XLoadFont): * glyphs-x.c (cursor_font_instantiate): * glyphs-x.c (x_redisplay_widget): * glyphs-x.c (Fchange_subwindow_property): * glyphs-x.c (x_widget_instantiate): * glyphs-x.c (x_tab_control_redisplay): * glyphs.c (pixmap_to_lisp_data): * gui-x.c (menu_separator_style_and_to_external): * gui-x.c (add_accel_and_to_external): * gui-x.c (button_item_to_widget_value): * hpplay.c (player_error_internal): * hpplay.c (play_sound_file): * hpplay.c (play_sound_data): * intl.c (Fset_current_locale): * lisp.h: * menubar-gtk.c (gtk_xemacs_set_accel_keys): * menubar-msw.c (populate_menu_add_item): * menubar-msw.c (populate_or_checksum_helper): * menubar-x.c (menu_item_descriptor_to_widget_value_1): * nt.c (init_user_info): * nt.c (get_long_basename): * nt.c (nt_get_resource): * nt.c (init_mswindows_environment): * nt.c (get_cached_volume_information): * nt.c (mswindows_readdir): * nt.c (read_unc_volume): * nt.c (mswindows_stat): * nt.c (mswindows_getdcwd): * nt.c (mswindows_executable_type): * nt.c (Fmswindows_short_file_name): * ntplay.c (nt_play_sound_file): * objects-gtk.c: * objects-gtk.c (gtk_valid_color_name_p): * objects-gtk.c (gtk_initialize_font_instance): * objects-gtk.c (gtk_font_list): * objects-msw.c (font_enum_callback_2): * objects-msw.c (parse_font_spec): * objects-x.c (x_parse_nearest_color): * objects-x.c (x_valid_color_name_p): * objects-x.c (x_initialize_font_instance): * objects-x.c (x_font_instance_truename): * objects-x.c (x_font_list): * objects-xlike-inc.c (XFUN): * objects-xlike-inc.c (xft_find_charset_font): * process-nt.c (mswindows_report_winsock_error): * process-nt.c (nt_create_process): * process-nt.c (get_internet_address): * process-nt.c (nt_open_network_stream): * process-unix.c: * process-unix.c (allocate_pty): * process-unix.c (get_internet_address): * process-unix.c (unix_canonicalize_host_name): * process-unix.c (unix_open_network_stream): * realpath.c: * select-common.h (lisp_data_to_selection_data): * select-gtk.c (symbol_to_gtk_atom): * select-gtk.c (atom_to_symbol): * select-msw.c (symbol_to_ms_cf): * select-msw.c (mswindows_register_selection_data_type): * select-x.c (symbol_to_x_atom): * select-x.c (x_atom_to_symbol): * select-x.c (hack_motif_clipboard_selection): * select-x.c (Fx_store_cutbuffer_internal): * sound.c (Fplay_sound_file): * sound.c (Fplay_sound): * sound.h (sound_perror): * sysdep.c: * sysdep.c (qxe_allocating_getcwd): * sysdep.c (qxe_execve): * sysdep.c (copy_in_passwd): * sysdep.c (qxe_getpwnam): * sysdep.c (qxe_ctime): * sysdll.c (dll_open): * sysdll.c (dll_function): * sysdll.c (dll_variable): * sysdll.c (search_linked_libs): * sysdll.c (dll_error): * sysfile.h: * sysfile.h (PATHNAME_CONVERT_OUT_TSTR): * sysfile.h (PATHNAME_CONVERT_OUT_UTF_8): * sysfile.h (PATHNAME_CONVERT_OUT): * sysfile.h (LISP_PATHNAME_CONVERT_OUT): * syswindows.h (ITEXT_TO_TSTR): * syswindows.h (LOCAL_FILE_FORMAT_TO_TSTR): * syswindows.h (TSTR_TO_LOCAL_FILE_FORMAT): * syswindows.h (LOCAL_FILE_FORMAT_TO_INTERNAL_MSWIN): * syswindows.h (LISP_LOCAL_FILE_FORMAT_MAYBE_URL_TO_TSTR): * text.h: * text.h (eicpy_ext_len): * text.h (enum new_dfc_src_type): * text.h (EXTERNAL_TO_ITEXT): * text.h (GET_STRERROR): * tooltalk.c (check_status): * tooltalk.c (Fadd_tooltalk_message_arg): * tooltalk.c (Fadd_tooltalk_pattern_attribute): * tooltalk.c (Fadd_tooltalk_pattern_arg): * win32.c (tstr_to_local_file_format): * win32.c (mswindows_lisp_error_1): * win32.c (mswindows_report_process_error): * win32.c (Fmswindows_shell_execute): * win32.c (mswindows_read_link_1): Changes involving external/internal format conversion, mostly code cleanup and renaming. 1. Eliminate the previous macros like LISP_STRING_TO_EXTERNAL that stored its result in a parameter. The new version of LISP_STRING_TO_EXTERNAL returns its result through the return value, same as the previous NEW_LISP_STRING_TO_EXTERNAL. Use the new-style macros throughout the code. 2. Rename C_STRING_TO_EXTERNAL and friends to ITEXT_TO_EXTERNAL, in keeping with overall naming rationalization involving Itext and related types. Macros involved in previous two: EXTERNAL_TO_C_STRING -> EXTERNAL_TO_ITEXT EXTERNAL_TO_C_STRING_MALLOC -> EXTERNAL_TO_ITEXT_MALLOC SIZED_EXTERNAL_TO_C_STRING -> SIZED_EXTERNAL_TO_ITEXT SIZED_EXTERNAL_TO_C_STRING_MALLOC -> SIZED_EXTERNAL_TO_ITEXT_MALLOC C_STRING_TO_EXTERNAL -> ITEXT_TO_EXTERNAL C_STRING_TO_EXTERNAL_MALLOC -> ITEXT_TO_EXTERNAL_MALLOC LISP_STRING_TO_EXTERNAL LISP_STRING_TO_EXTERNAL_MALLOC LISP_STRING_TO_TSTR C_STRING_TO_TSTR -> ITEXT_TO_TSTR TSTR_TO_C_STRING -> TSTR_TO_ITEXT The following four still return their values through parameters, since they have more than one value to return: C_STRING_TO_SIZED_EXTERNAL -> ITEXT_TO_SIZED_EXTERNAL LISP_STRING_TO_SIZED_EXTERNAL C_STRING_TO_SIZED_EXTERNAL_MALLOC -> ITEXT_TO_SIZED_EXTERNAL_MALLOC LISP_STRING_TO_SIZED_EXTERNAL_MALLOC Sometimes additional casts had to be inserted, since the old macros played strange games and completely defeated the type system of the store params. 3. Rewrite many places where direct calls to TO_EXTERNAL_FORMAT occurred with calls to one of the convenience macros listed above, or to make_extstring(). 4. Eliminate SIZED_C_STRING macros (they were hardly used, anyway) and use a direct call to TO_EXTERNAL_FORMAT or TO_INTERNAL_FORMAT. 4. Use LISP_PATHNAME_CONVERT_OUT in many places instead of something like LISP_STRING_TO_EXTERNAL(..., Qfile_name). 5. Eliminate some temporary variables that are no longer necessary now that we return a value rather than storing it into a variable. 6. Some Mule-izing in database.c. 7. Error functions: -- A bit of code cleanup in maybe_signal_error_1. -- Eliminate report_file_type_error; it's just an alias for signal_error_2 with params in a different order. -- Fix some places in the hostname-handling code that directly inserted externally-retrieved error strings into the supposed ASCII "reason" param instead of doing the right thing and sticking text descriptive of what was going on in "reason" and putting the external message in a frob. 8. Use Ascbyte instead of CIbyte in process-unix.c and maybe one or two other places. 9. Some code cleanup in copy_in_passwd() in sysdep.c. 10. Fix a real bug due to accidental variable shadowing in tstr_to_local_file_format() in win32.c.
author Ben Wing <ben@xemacs.org>
date Fri, 05 Feb 2010 11:02:24 -0600
parents 49e17f7182f5
children 668c73e222fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; modeline.el --- modeline hackery.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1988, 1992-1994, 1997 Free Software Foundation, Inc.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
4 ;; Copyright (C) 1995, 1996, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: extensions, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;;; General mouse modeline stuff ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 (defgroup modeline nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 "Modeline customizations."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 :group 'environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
42 (defcustom modeline-3d-p ;; added for the options menu
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
43 (let ((thickness
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
44 (specifier-instance modeline-shadow-thickness)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 (and (integerp thickness)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 (> thickness 0)))
4578
49e17f7182f5 Fix docstring copy-pasto.
"Ville Skyttä <scop@xemacs.org>"
parents: 4043
diff changeset
47 "Whether the modeline is displayed with raised, 3-d appearance.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
48 This option only has an effect when set using `customize-set-variable',
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
49 or through the Options menu."
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 :group 'display
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51 :type 'boolean
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
52 :set #'(lambda (var val)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
53 (if val
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
54 (set-specifier modeline-shadow-thickness 2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
55 (set-specifier modeline-shadow-thickness 0))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
56 (redraw-modeline t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
57 (setq modeline-3d-p val))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
58 )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
59
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (defcustom drag-divider-event-lag 150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 "*The pause (in msecs) between divider drag events before redisplaying.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 If this value is too small, dragging will be choppy because redisplay cannot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 keep up. If it is too large, dragging will be choppy because of the explicit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 redisplay delay specified."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 :type 'integer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ;; #### Fix group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 :group 'modeline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (define-obsolete-variable-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 'drag-modeline-event-lag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 'drag-divider-event-lag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (defcustom modeline-click-swaps-buffers nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 "*If non-nil, clicking on the modeline changes the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 Click on the left half of the modeline cycles forward through the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 buffer list and clicking on the right half cycles backward."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 :group 'modeline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
80 (defcustom modeline-scrolling-method nil
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
81 "*If non-nil, dragging the modeline with the mouse may also scroll its
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
82 text horizontally (vertical motion controls window resizing and horizontal
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
83 motion controls modeline scrolling).
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
84
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
85 With a value of t, the modeline text is scrolled in the same direction as
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
86 the mouse motion. With a value of 'scrollbar, the modeline is considered as
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
87 a scrollbar for its own text, which then moves in the opposite direction.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
88
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
89 This option should be set using `customize-set-variable'."
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
90 :type '(choice (const :tag "none" nil)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
91 (const :tag "text" t)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
92 (const :tag "scrollbar" scrollbar))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
93 :set (lambda (sym val)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
94 (set-default sym val)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
95 (when (featurep 'x)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
96 (cond ((eq val t)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
97 (set-glyph-image modeline-pointer-glyph "hand2" 'global 'x))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
98 ((eq val 'scrollbar)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
99 (set-glyph-image modeline-pointer-glyph "fleur" 'global 'x))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
100 (t
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
101 (set-glyph-image modeline-pointer-glyph "sb_v_double_arrow"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
102 'global 'x))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
103 (when (featurep 'mswindows)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
104 (cond ((eq val t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
105 (set-glyph-image modeline-pointer-glyph
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
106 [mswindows-resource :resource-type cursor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
107 :resource-id "SizeAll"]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
108 'global 'mswindows))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
109 ((eq val 'scrollbar)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
110 (set-glyph-image modeline-pointer-glyph
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
111 [mswindows-resource :resource-type cursor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
112 :resource-id "Normal"]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
113 'global 'mswindows))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
114 (t
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
115 (set-glyph-image modeline-pointer-glyph
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
116 [mswindows-resource :resource-type cursor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
117 :resource-id "SizeNS"]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
118 'global 'mswindows)))))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
119 :group 'modeline)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
120
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (defun mouse-drag-modeline (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 "Resize a window by dragging its modeline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 This command should be bound to a button-press event in modeline-map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 Holding down a mouse button and moving the mouse up and down will
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
125 make the clicked-on window taller or shorter.
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
126
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
127 See also the variable `modeline-scrolling-method'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (or (button-press-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (error "%s must be invoked by a mouse-press" this-command))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 (or (event-over-modeline-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (error "not over a modeline"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 ;; Give the modeline a "pressed" look. --hniksic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 (let-specifier ((modeline-shadow-thickness
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (- (specifier-instance modeline-shadow-thickness
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (event-window event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 (event-window event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 (let ((done nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (depress-line (event-y event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (start-event-frame (event-frame event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (start-event-window (event-window event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (start-nwindows (count-windows t))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
143 (hscroll-delta (face-width 'modeline))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
144 (start-hscroll (modeline-hscroll (event-window event)))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
145 (start-x-pixel (event-x-pixel event))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (last-timestamp 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 default-line-height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 modeline-height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 should-enlarge-minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 event min-height minibuffer y top bot edges wconfig growth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (setq minibuffer (minibuffer-window start-event-frame)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 default-line-height (face-height 'default start-event-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 min-height (+ (* window-min-height default-line-height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 ;; Don't let the window shrink by a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 ;; non-multiple of the default line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 ;; height. (enlarge-window -1) will do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 ;; this if the difference between the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 ;; current window height and the minimum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 ;; window height is less than the height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 ;; of the default font. These extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 ;; lost pixels of height don't come back
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 ;; if you grow the window again. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 ;; can make it impossible to drag back
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 ;; to the exact original size, which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 ;; disconcerting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (% (window-pixel-height start-event-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 default-line-height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 modeline-height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (if (specifier-instance has-modeline-p start-event-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (+ (face-height 'modeline start-event-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (* 2 (specifier-instance modeline-shadow-thickness
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 start-event-window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (* 2 (specifier-instance modeline-shadow-thickness
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 start-event-window))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (if (not (eq (window-frame minibuffer) start-event-frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (setq minibuffer nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (if (and (null minibuffer) (one-window-p t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (error "Attempt to resize sole window"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 ;; if this is the bottommost ordinary window, then to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 ;; move its modeline the minibuffer must be enlarged.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (setq should-enlarge-minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (and minibuffer (window-lowest-p start-event-window)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 ;; loop reading events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (while (not done)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (setq event (next-event event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 ;; requeue event and quit if this is a misc-user, eval or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 ;; keypress event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 ;; quit if this is a button press or release event, or if the event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 ;; occurred in some other frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 ;; drag if this is a mouse motion event and the time
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 ;; between this event and the last event is greater than
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 ;; drag-divider-event-lag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 ;; do nothing if this is any other kind of event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (cond ((or (misc-user-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (key-press-event-p event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (setq unread-command-events (nconc unread-command-events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (list event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 done t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 ((button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (setq done t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 ;; Consider we have a mouse click neither X pos (modeline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 ;; scroll) nore Y pos (modeline drag) have changed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (and modeline-click-swaps-buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (= depress-line (event-y event))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
205 (or (not modeline-scrolling-method)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
206 (= start-hscroll
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
207 (modeline-hscroll start-event-window)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (modeline-swap-buffers event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 ((button-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 (setq done t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 ((not (motion-event-p event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (dispatch-event event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 ((not (eq start-event-frame (event-frame event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (setq done t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 ((< (abs (- (event-timestamp event) last-timestamp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 drag-divider-event-lag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (t
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
219 (when modeline-scrolling-method
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
220 (let ((delta (/ (- (event-x-pixel event) start-x-pixel)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
221 hscroll-delta)))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
222 (set-modeline-hscroll start-event-window
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
223 (if (eq modeline-scrolling-method t)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
224 (- start-hscroll delta)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
225 (+ start-hscroll delta)))
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
226 ))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (setq last-timestamp (event-timestamp event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 y (event-y-pixel event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 edges (window-pixel-edges start-event-window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 top (nth 1 edges)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 bot (nth 3 edges))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 ;; scale back a move that would make the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 ;; window too short.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (cond ((< (- y top (- modeline-height)) min-height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 (setq y (+ top min-height (- modeline-height)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 ;; compute size change needed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (setq growth (- y bot (/ (- modeline-height) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 wconfig (current-window-configuration))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 ;; grow/shrink minibuffer?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (if should-enlarge-minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 ;; yes. scale back shrinkage if it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 ;; would make the minibuffer less than 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 ;; line tall.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 ;; also flip the sign of the computed growth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 ;; since if we want to grow the window with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 ;; modeline we need to shrink the minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 ;; and vice versa.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 (if (and (> growth 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (< (- (window-pixel-height minibuffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 growth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 default-line-height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 (setq growth
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (- (window-pixel-height minibuffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 default-line-height)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (setq growth (- growth))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 ;; window grow and shrink by lines not pixels, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 ;; divide the pixel height by the height of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 ;; default face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (setq growth (/ growth default-line-height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 ;; grow/shrink the window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (enlarge-window growth nil (if should-enlarge-minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 start-event-window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 ;; if this window's growth caused another
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 ;; window to be deleted because it was too
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 ;; short, rescind the change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 ;; if size change caused space to be stolen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 ;; from a window above this one, rescind the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 ;; change, but only if we didn't grow/shrink
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 ;; the minibuffer. minibuffer size changes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 ;; can cause all windows to shrink... no way
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 ;; around it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 (if (or (/= start-nwindows (count-windows t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (and (not should-enlarge-minibuffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 (/= top (nth 1 (window-pixel-edges
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 start-event-window)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (set-window-configuration wconfig))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 ;; from Bob Weiner (bob_weiner@pts.mot.com)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 ;; Whether this function should be called is now decided in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 ;; mouse-drag-modeline - dverna feb. 98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (defun modeline-swap-buffers (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 "Handle mouse clicks on modeline by switching buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 If click on left half of a frame's modeline, bury current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 If click on right half of a frame's modeline, raise bottommost buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 Arg EVENT is the button release event that occurred on the modeline."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (or (event-over-modeline-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (error "not over a modeline"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (or (button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (error "not a button release event"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (if (< (event-x event) (/ (window-width (event-window event)) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 ;; On left half of modeline, bury current buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 ;; displaying second buffer on list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (mouse-bury-buffer event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 ;; On right half of modeline, raise and display bottommost
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 ;; buffer in buffer list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (mouse-unbury-buffer event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 (defconst modeline-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 '("Window Commands"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 ["Delete Window Above" delete-window t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 ["Delete Other Windows" delete-other-windows t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 ["Split Window Above" split-window-vertically t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 ["Split Window Horizontally" split-window-horizontally t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 ["Balance Windows" balance-windows t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 (defun modeline-menu (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (popup-menu-and-execute-in-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (cons (format "Window Commands for %S:"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (buffer-name (event-buffer event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 (cdr modeline-menu))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 (defvar modeline-map (make-sparse-keymap 'modeline-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 "Keymap consulted for mouse-clicks on the modeline of a window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 This variable may be buffer-local; its value will be looked up in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 the buffer of the window whose modeline was clicked upon.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (define-key modeline-map 'button1 'mouse-drag-modeline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 ;; button2 selects the window without setting point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (define-key modeline-map 'button2 (lambda () (interactive "@")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 (define-key modeline-map 'button3 'modeline-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 (make-face 'modeline-mousable "Face for mousable portions of the modeline.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 (set-face-parent 'modeline-mousable 'modeline nil '(default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (when (featurep 'window-system)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
332 (set-face-foreground 'modeline-mousable "firebrick" nil '(default color win))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
333 (set-face-font 'modeline-mousable [bold] nil '(default mono win))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
334 (set-face-font 'modeline-mousable [bold] nil '(default grayscale win)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (defmacro make-modeline-command-wrapper (command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 `#'(lambda (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (save-selected-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (select-window (event-window event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (call-interactively ',(eval command)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 ;;; Minor modes ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (defvar minor-mode-alist nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 "Alist saying how to show minor modes in the modeline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 Each element looks like (VARIABLE STRING);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 STRING is included in the modeline iff VARIABLE's value is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 Actually, STRING need not be a string; any possible modeline element
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 is okay. See `modeline-format'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 ;; Used by C code (lookup-key and friends) but defined here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (defvar minor-mode-map-alist nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 "Alist of keymaps to use for minor modes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 key sequences and look up bindings iff VARIABLE's value is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 If two active keymaps bind the same key, the keymap appearing earlier
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 in the list takes precedence.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (make-face 'modeline-mousable-minor-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 "Face for mousable minor-mode strings in the modeline.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (set-face-parent 'modeline-mousable-minor-mode 'modeline-mousable nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 '(default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (when (featurep 'window-system)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
368 (set-face-foreground 'modeline-mousable-minor-mode '("green4" "forestgreen")
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
369 nil '(default color win)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (defvar modeline-mousable-minor-mode-extent (make-extent nil nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 ;; alliteration at its finest.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 "Extent managing the mousable minor mode modeline strings.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 (set-extent-face modeline-mousable-minor-mode-extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 'modeline-mousable-minor-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 ;; This replaces the idiom
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 ;; (or (assq 'isearch-mode minor-mode-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 ;; (setq minor-mode-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 ;; (purecopy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 ;; (append minor-mode-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;; '((isearch-mode isearch-mode))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (defun add-minor-mode (toggle name &optional keymap after toggle-fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 TOGGLE is a symbol whose value as a variable specifies whether the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 minor mode is active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 NAME is the name that should appear in the modeline. It should either
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 be a string beginning with a space, or a symbol with a similar string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 as its value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 KEYMAP is a keymap to make active when the minor mode is active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 AFTER is the toggling symbol used for another minor mode. If AFTER is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 non-nil, then it is used to position the new mode in the minor-mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 alists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 TOGGLE-FUN specifies an interactive function that is called to toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 the mode on and off; this affects what happens when button2 is pressed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 on the mode, and when button3 is pressed somewhere in the list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 TOGGLE is used as the toggle function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 (let* ((add-elt #'(lambda (elt sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 (let (place)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 (cond ((null after) ; add to front
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (push elt (symbol-value sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ((and (not (eq after t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (setq place (memq (assq after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 (symbol-value sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (symbol-value sym))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 (push elt (cdr place)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (set sym (append (symbol-value sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (list elt))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (symbol-value sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 el toggle-keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 (if toggle-fun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (check-argument-type 'commandp toggle-fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (when (commandp toggle)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (setq toggle-fun toggle)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (when (and toggle-fun name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 (setq toggle-keymap (make-sparse-keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 (intern (concat "modeline-minor-"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (symbol-name toggle)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 "-map"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 (define-key toggle-keymap 'button2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 ;; defeat the DUMB-ASS byte-compiler, which tries to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 ;; expand the macro at compile time and fucks up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (eval '(make-modeline-command-wrapper toggle-fun)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (put toggle 'modeline-toggle-function toggle-fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (when name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (let ((hacked-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (if toggle-keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (cons (let ((extent (make-extent nil nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (set-extent-keymap extent toggle-keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (set-extent-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 extent 'help-echo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (concat "button2 turns off "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (if (symbolp toggle-fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (symbol-name toggle-fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (symbol-name toggle))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (cons modeline-mousable-minor-mode-extent name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (if (setq el (assq toggle minor-mode-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (setcdr el (list hacked-name))
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
452 (funcall add-elt
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (list toggle hacked-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 'minor-mode-alist))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (when keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (if (setq el (assq toggle minor-mode-map-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (setcdr el keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (funcall add-elt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (cons toggle keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 'minor-mode-map-alist)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
462 (defcustom abbrev-mode-line-string " Abbrev"
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
463 "*String to display in the modeline when `abbrev-mode' is active.
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
464 Set this to nil if you don't want a modeline indicator."
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
465 :type '(choice string
729
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
466 (const :tag "none" nil))
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
467 :group 'abbrev-mode)
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
468
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
469 (defcustom overwrite-mode-line-string " Ovwrt"
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
470 "*String to display in the modeline when `overwrite-mode' is active.
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
471 Set this to nil if you don't want a modeline indicator."
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
472 :type '(choice string
729
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
473 (const :tag "none" nil))
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
474 :group 'editing-basics)
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
475
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
476 (defcustom auto-fill-mode-line-string " Fill"
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
477 "*String to display in the modeline when `auto-fill-mode' is active.
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
478 Set this to nil if you don't want a modeline indicator."
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
479 :type '(choice string
729
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
480 (const :tag "none" nil))
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
481 :group 'fill)
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
482
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
483 (defcustom defining-kbd-macro-mode-line-string " Def"
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
484 "*String to display in the modeline when `defining-kbd-macro' is active.
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
485 Set this to nil if you don't want a modeline indicator."
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
486 :type '(choice string
729
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
487 (const :tag "none" nil))
217aff1c578d [xemacs-hg @ 2002-01-11 02:55:05 by youngs]
youngs
parents: 695
diff changeset
488 :group 'keyboard)
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
489
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ;; #### TODO: Add `:menu-tag' keyword to add-minor-mode. Or create a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 ;; separate function to manage the minor mode menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 ;(put 'abbrev-mode :menu-tag "Abbreviation Expansion")
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
494 (add-minor-mode 'abbrev-mode 'abbrev-mode-line-string)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 ;; only when visiting a file...
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
496 (add-minor-mode 'overwrite-mode 'overwrite-mode-line-string)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 ;(put 'auto-fill-function :menu-tag "Auto Fill")
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
498 (add-minor-mode 'auto-fill-function 'auto-fill-mode-line-string
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
499 nil nil 'auto-fill-mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 ;(put 'defining-kbd-macro :menu-tag "Keyboard Macro")
695
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
502 (add-minor-mode 'defining-kbd-macro 'defining-kbd-macro-mode-line-string
74f176715ed2 [xemacs-hg @ 2001-12-15 11:46:33 by youngs]
youngs
parents: 502
diff changeset
503 nil nil
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 (if defining-kbd-macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 ;; #### This means to disregard the last event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 ;; It is needed because the last recorded
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 ;; event is usually the mouse event that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 ;; invoked the menu item (and this function),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 ;; and having it in the macro causes problems.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (zap-last-kbd-macro-event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 (end-kbd-macro nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 (start-kbd-macro nil))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (defun modeline-minor-mode-menu (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 "The menu that pops up when you press `button3' inside the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 parentheses on the modeline."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (set-buffer (event-buffer event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (popup-menu-and-execute-in-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 (cons
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 "Minor Mode Toggles"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 (sort
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (delq nil (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 #'(lambda (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 (let* ((toggle-sym (car x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 (toggle-fun (or (get toggle-sym
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 'modeline-toggle-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 (and (commandp toggle-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 toggle-sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (menu-tag (symbol-name (if (symbolp toggle-fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 toggle-fun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 toggle-sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 ;; Here a function should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 ;; maybe be invoked to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 ;; beautify the symbol's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 ;; menu appearance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 (and toggle-fun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 (vector menu-tag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 toggle-fun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 ;; The following two are wrong
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 ;; because of possible name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 ;; clashes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 ;:active (get toggle-sym :active t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 ;:included (get toggle-sym :included t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 :style 'toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 :selected (and (boundp toggle-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 toggle-sym)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 minor-mode-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (lambda (e1 e2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (string< (aref e1 0) (aref e2 0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (defvar modeline-minor-mode-map (make-sparse-keymap 'modeline-minor-mode-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 "Keymap consulted for mouse-clicks on the minor-mode modeline list.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (define-key modeline-minor-mode-map 'button3 'modeline-minor-mode-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (defvar modeline-minor-mode-extent (make-extent nil nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 "Extent covering the minor mode modeline strings.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 (set-extent-face modeline-minor-mode-extent 'modeline-mousable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (set-extent-keymap modeline-minor-mode-extent modeline-minor-mode-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
569 ;;; Modeline definition ;;;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
572 (defmacro define-modeline-control (name contents doc-string &optional face
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
573 help-echo)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
574 "Define a modeline control named NAME, a symbol.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
575 A modeline control is a section of the modeline whose contents can easily
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
576 be changed independently of the rest of the modeline, which can have its
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
577 own color, and which can have its own mouse commands, which apply when the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
578 mouse is over the control.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
579
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
580 Logically, a modeline control should be an object; but we have terrible
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
581 object support in XEmacs, and so history has given us a series of related
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
582 variables, which [hopefully] all follow the same conventions.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
583
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
584 Three variables are created:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
585
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
586 1. The variable holding the control specification is called
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
587 `modeline-NAME', and is automatically buffer-local.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
588
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
589 2. The variable holding the extent that covers the control area in the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
590 modeline is called `modeline-NAME-extent'. Onto this extent, colors and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
591 keymaps (and possibly glyphs?) can be added, and will be noticed by the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
592 modeline redisplay code. The attachment of the extent and its control
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
593 is done somewhere in the modeline specification: either in the main spec
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
594 in `modeline-format', or in some other control, like this:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
595
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
596 (cons modeline-NAME-extent 'modeline-NAME)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
597
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
598 3. The keymap holding the mousable commands for the control is called
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
599 `modeline-NAME-map'. This is automatically attached to the extent by
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
600 this macro.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
601
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
602 Initial contents of the control are CONTENTS (see `modeline-format' for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
603 information about the structure of this contents). DOC-STRING specifies
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
604 help text that will be placed in the control variable's documentation,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
605 indicating what's supposed to be in the control.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
606
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
607 Optional argument FACE specifies the face of the control's
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
608 extent. (`modeline-mousable' is a good choice if your control is, in fact,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
609 mousable (i.e. it has some mouse commands defined for it). Optional
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
610 argument HELP-ECHO specifies some help-echo to be displayed when the mouse
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
611 moves over the control, indicating what mouse strokes are available. "
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
612 (let ((control-var (intern (format "modeline-%s" name)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
613 (extent-var (intern (format "modeline-%s-extent" name)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
614 (map-var (intern (format "modeline-%s-map" name)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
615 )
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
616 `(progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
617 (defconst ,control-var ,contents
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
618 ,(format "%s
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
619
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
620 The format of the contents of this variable is documented in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
621 `modeline-format'. The way the control is displayed can be changed by
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
622 setting the face of `%s'. Mouse commands
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
623 for the control can be set using `%s'." doc-string extent-var map-var))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
624 (make-variable-buffer-local ',control-var)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
625 (defvar ,extent-var (make-extent nil nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
626 ,(format "Extent covering the `%s' control." control-var))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
627 (defvar ,map-var (make-sparse-keymap 'modeline-narrowed-map)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
628 ,(format "Keymap consulted for mouse-clicks on the `%s' control."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
629 control-var))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
630 (set-extent-face ,extent-var ,face)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
631 (set-extent-keymap ,extent-var ,map-var)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
632 (set-extent-property ,extent-var 'help-echo ,help-echo))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
633 (put 'define-modeline-control 'lisp-indent-function 2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
634
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
635 ;; ------------------------ modeline buffer id -------------------
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
636
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 (defun modeline-buffers-menu (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 (popup-menu-and-execute-in-window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 '("Buffers Popup Menu"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 :filter buffers-menu-filter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 ["List All Buffers" list-buffers t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 "--"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
647 (define-modeline-control buffer-id-left
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
648 'modeline-modified-buffer-highlighted-name ;; "XEmacs:"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
649 "Modeline control for left half of buffer ID."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
650 'modeline-mousable
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
651 "button2 cycles to the previous buffer")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
653 (define-modeline-control buffer-id-right
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
654 'modeline-modified-buffer-non-highlighted-name ;; " %17b"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
655 "Modeline control for right half of buffer ID."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
656 nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
657 "button2 cycles to the next buffer")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 (define-key modeline-buffer-id-left-map 'button2 'mouse-unbury-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 (define-key modeline-buffer-id-right-map 'button2 'mouse-bury-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 (define-key modeline-buffer-id-left-map 'button3 'modeline-buffers-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (define-key modeline-buffer-id-right-map 'button3 'modeline-buffers-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 (make-face 'modeline-buffer-id
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 "Face for the buffer ID string in the modeline.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 (set-face-parent 'modeline-buffer-id 'modeline nil '(default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 (when (featurep 'window-system)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
668 (set-face-foreground 'modeline-buffer-id "blue4" nil '(default color win))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
669 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default mono win))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
670 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default grayscale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
671 win)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 (when (featurep 'tty)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (set-face-font 'modeline-buffer-id [bold-italic] nil '(default tty)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
675 (define-modeline-control buffer-id
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
676 (list (cons modeline-buffer-id-left-extent 'modeline-buffer-id-left)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
677 (cons modeline-buffer-id-right-extent 'modeline-buffer-id-right))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 "Modeline control for identifying the buffer being displayed.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 Its default value is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
681 (list (cons modeline-buffer-id-left-extent 'modeline-buffer-id-left)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
682 (cons modeline-buffer-id-right-extent 'modeline-buffer-id-right))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 Major modes that edit things other than ordinary files may change this
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
685 (e.g. Info, Dired,...)."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
686 'modeline-buffer-id)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
687
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
688 (defvaralias 'modeline-buffer-identification 'modeline-buffer-id)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
689
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
690 (defvar modeline-modified-buffer-non-highlighted-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
691 (make-variable-buffer-local 'modeline-modified-buffer-non-highlighted-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
692 (put 'modeline-modified-buffer-non-highlighted-name 'permanent-local t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
693
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
694 (defvar modeline-modified-buffer-highlighted-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
695 (make-variable-buffer-local 'modeline-modified-buffer-highlighted-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
696 (put 'modeline-modified-buffer-highlighted-name 'permanent-local t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
697
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
698 (defvar modeline-recorded-buffer-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
699 (make-variable-buffer-local 'modeline-recorded-buffer-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
700 (put 'modeline-recorded-buffer-name 'permanent-local t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
701
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
702 (defvar modeline-recorded-buffer-file-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
703 (make-variable-buffer-local 'modeline-recorded-buffer-file-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
704 (put 'modeline-recorded-buffer-file-name 'permanent-local t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
705
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
706 (add-hook 'buffer-list-changed-hook 'modeline-update-buffer-names)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
707
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
708 (defvar modeline-max-buffer-name-size 30)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
709
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
710 (defun modeline-update-buffer-names (frame)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
711 (mapc #'(lambda (buf)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
712 (when (or (not (eq (buffer-name buf)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
713 (symbol-value-in-buffer
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
714 'modeline-recorded-buffer-name buf)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
715 (not (eq (buffer-file-name buf)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
716 (symbol-value-in-buffer
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
717 'modeline-recorded-buffer-file-name buf))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
718 ;(dp "processing %s" buf)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
719 (with-current-buffer buf
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
720 (setq modeline-recorded-buffer-name (buffer-name))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
721 (setq modeline-recorded-buffer-file-name (buffer-file-name))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
722 (if (not modeline-recorded-buffer-file-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
723 (setq modeline-modified-buffer-non-highlighted-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
724 modeline-recorded-buffer-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
725 modeline-modified-buffer-highlighted-name nil)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
726 (let ((fn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
727 (if (<= (length modeline-recorded-buffer-file-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
728 modeline-max-buffer-name-size)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
729 modeline-recorded-buffer-file-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
730 (concat "..."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
731 (substring
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
732 modeline-recorded-buffer-file-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
733 (- modeline-max-buffer-name-size))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
734 (setq modeline-modified-buffer-non-highlighted-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
735 ;; if the filename is very long, the entire
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
736 ;; directory will get truncated to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
737 ;; non-existence.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
738 (let ((dir (file-name-directory fn)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
739 (if dir
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
740 (concat " ("
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
741 (directory-file-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
742 (file-name-directory fn))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
743 ")")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
744 ""))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
745 modeline-modified-buffer-highlighted-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
746 (file-name-nondirectory fn))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
747 (redraw-modeline))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
748 (buffer-list)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
749
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
750 (defcustom modeline-new-buffer-id-format t
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
751 "Whether the new format for the modeline buffer ID (with directory) is used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
752 This option only has an effect when set using `customize-set-variable',
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
753 or through the Options menu."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
754 :group 'modeline
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
755 :type 'boolean
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
756 :set #'(lambda (var val)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
757 (if val
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
758 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
759 (setq-default modeline-buffer-id-left
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
760 'modeline-modified-buffer-highlighted-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
761 modeline-buffer-id-right
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
762 'modeline-modified-buffer-non-highlighted-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
763 (set-extent-face modeline-buffer-id-left-extent
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
764 'modeline-mousable))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
765 (setq-default modeline-buffer-id-left "XEmacs:"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
766 modeline-buffer-id-right '(" %17b"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
767 (set-extent-face modeline-buffer-id-left-extent nil))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
768
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
769 ;; ------------------------ other modeline controls -------------------
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 ;; These are for the sake of minor mode menu. #### All of this is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 ;; kind of dirty. `add-minor-mode' started out as a simple substitute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 ;; for (or (assq ...) ...) FSF stuff, but now is used for all kind of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 ;; stuff. There should perhaps be a separate function to add toggles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 ;; to the minor-mode-menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 (add-minor-mode 'line-number-mode "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (add-minor-mode 'column-number-mode "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
779 (define-modeline-control coding-system '("%C")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
780 "Modeline control for showing current coding system.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
781 ;; added March 7, 2002
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
782 (define-obsolete-variable-alias 'modeline-multibyte-status
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
783 'modeline-coding-system)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
785 (define-modeline-control modified '("--%1*%1+-")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
786 "Modeline control for displaying whether current buffer is modified."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
787 'modeline-mousable
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
788 "button2 toggles the buffer's read-only status")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (define-key modeline-modified-map 'button2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 (make-modeline-command-wrapper 'modeline-toggle-read-only))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 ;;; Added for XEmacs 20.3. Provide wrapper for vc since it may not always be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 ;;; present, and its symbols are not visible this early in the dump if it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 ;;; is.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 (defun modeline-toggle-read-only ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 "Change whether this buffer is visiting its file read-only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 With arg, set read-only iff arg is positive.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 This function is designed to be called when the read-only indicator on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 modeline is clicked. It will call `vc-toggle-read-only' if available,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 otherwise it will call the usual `toggle-read-only'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 (interactive)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
803 (if-fboundp 'vc-toggle-read-only
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 (vc-toggle-read-only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (toggle-read-only)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
807 (define-modeline-control line-number (list 'line-number-mode "L%l ")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
808 "Modeline control for displaying the line number of point.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
809 (define-modeline-control column-number (list 'column-number-mode "C%c ")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
810 "Modeline control for displaying the column number of point.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
811 (define-modeline-control percentage (cons -3 "%p")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
812 "Modeline control for displaying percentage of file above point.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
813
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
814 (define-modeline-control position-status
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
815 (cons 15 (list
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
816 (cons modeline-line-number-extent
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
817 'modeline-line-number)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
818 (cons modeline-column-number-extent
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
819 'modeline-column-number)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
820 (cons modeline-percentage-extent
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
821 'modeline-percentage)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
822 "Modeline control for providing status about the location of point.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
823 Generally includes the line number of point, its column number, and the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
824 percentage of the file above point."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
825 'modeline-buffer-id)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
826
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
827 (defconst modeline-tty-frame-specifier (make-specifier 'boolean))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
828 (add-hook 'create-frame-hook 'modeline-update-tty-frame-specifier)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
829 (defun modeline-update-tty-frame-specifier (f)
4043
b325de44db27 [xemacs-hg @ 2007-06-29 08:17:44 by stephent]
stephent
parents: 771
diff changeset
830 (if (and (eq (frame-type f) 'tty)
b325de44db27 [xemacs-hg @ 2007-06-29 08:17:44 by stephent]
stephent
parents: 771
diff changeset
831 (> (frame-property f 'frame-number) 1))
b325de44db27 [xemacs-hg @ 2007-06-29 08:17:44 by stephent]
stephent
parents: 771
diff changeset
832 (set-specifier modeline-tty-frame-specifier t f)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
833
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
834 (define-modeline-control tty-frame-id (list modeline-tty-frame-specifier
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
835 " [%S]"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
836 )
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
837 "Modeline control for showing which TTY frame is selected.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
838
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
839 (define-modeline-control narrowed '("%n")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
840 "Modeline control for displaying whether current buffer is narrowed."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
841 'modeline-mousable
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
842 "button2 widens the buffer")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
843 (define-key modeline-narrowed-map 'button2
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
844 (make-modeline-command-wrapper 'widen))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
845
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
846 (define-modeline-control process nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
847 "Modeline control for displaying info on process status.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
848 Normally nil in most modes, since there is no process to display.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
849
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
850 (setq-default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
851 modeline-format
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
852 (list
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
853 ""
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
854 (cons modeline-coding-system-extent 'modeline-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
855 (cons modeline-modified-extent 'modeline-modified)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
856 (cons modeline-position-status-extent 'modeline-position-status)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
857 (cons modeline-tty-frame-id-extent 'modeline-tty-frame-id)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
858 (cons modeline-buffer-id-extent 'modeline-buffer-id)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
859 " "
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
860 'global-mode-string
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
861 " %[("
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
862 (cons modeline-minor-mode-extent
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
863 (list "" 'mode-name 'minor-mode-alist))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
864 (cons modeline-narrowed-extent 'modeline-narrowed)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
865 (cons modeline-process-extent 'modeline-process)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
866 ")%]%-"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 729
diff changeset
867
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 ;;; modeline.el ends here