diff options
| author | Chong Yidong | 2012-06-03 17:03:23 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-06-03 17:03:23 +0800 |
| commit | 5f2c76c6cee2b5d2d84ffd409839fd58d2ad16fa (patch) | |
| tree | ccab5d66cbd6666671d529849c174c5701508d1e /src | |
| parent | 773d47f6b23a2294baaf577f5cb783338232008c (diff) | |
| download | emacs-5f2c76c6cee2b5d2d84ffd409839fd58d2ad16fa.tar.gz emacs-5f2c76c6cee2b5d2d84ffd409839fd58d2ad16fa.zip | |
Implement default help-echo for mode line.
* lisp/bindings.el: Remove explicit help-echo from format-mode-line.
(mode-line-front-space, mode-line-end-spaces)
(mode-line-misc-info): New variables.
(mode-line-modes, mode-line-position): Move the default value to
the variable definition.
(mode-line-default-help-echo): New defcustom.
* src/buffer.c (buffer_local_value_1): New function, split from
Fbuffer_local_value; can return Qunbound.
(Fbuffer_local_value): Use it.
(Vmode_line_format): Docstring tweaks.
* src/xdisp.c (calc_pixel_width_or_height): Use Fbuffer_local_value.
(note_mode_line_or_margin_highlight): If there is no help echo,
use mode-line-default-help-echo. Handle the case where the mouse
position is past the end of the mode line string.
* doc/lispref/modes.texi (Mode Line Data): Use "mode line construct"
terminology for consistency.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/buffer.c | 75 | ||||
| -rw-r--r-- | src/buffer.h | 1 | ||||
| -rw-r--r-- | src/xdisp.c | 83 |
4 files changed, 121 insertions, 50 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b90db0b7fa9..c0098445cb8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2012-06-03 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (calc_pixel_width_or_height): Use Fbuffer_local_value. | ||
| 4 | (note_mode_line_or_margin_highlight): If there is no help echo, | ||
| 5 | use mode-line-default-help-echo. Handle the case where the mouse | ||
| 6 | position is past the end of the mode line string. | ||
| 7 | |||
| 8 | * buffer.c (buffer_local_value_1): New function, split from | ||
| 9 | Fbuffer_local_value; can return Qunbound. | ||
| 10 | (Fbuffer_local_value): Use it. | ||
| 11 | (Vmode_line_format): Docstring tweaks. | ||
| 12 | |||
| 1 | 2012-06-02 Paul Eggert <eggert@cs.ucla.edu> | 13 | 2012-06-02 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 14 | ||
| 3 | * sysdep.c (system_process_attributes): Improve comment. | 15 | * sysdep.c (system_process_attributes): Improve comment. |
diff --git a/src/buffer.c b/src/buffer.c index 20260d5a5d8..386d9a78153 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -933,6 +933,21 @@ If VARIABLE does not have a buffer-local binding in BUFFER, the value | |||
| 933 | is the default binding of the variable. */) | 933 | is the default binding of the variable. */) |
| 934 | (register Lisp_Object variable, register Lisp_Object buffer) | 934 | (register Lisp_Object variable, register Lisp_Object buffer) |
| 935 | { | 935 | { |
| 936 | register Lisp_Object result = buffer_local_value_1 (variable, buffer); | ||
| 937 | |||
| 938 | if (EQ (result, Qunbound)) | ||
| 939 | xsignal1 (Qvoid_variable, variable); | ||
| 940 | |||
| 941 | return result; | ||
| 942 | } | ||
| 943 | |||
| 944 | |||
| 945 | /* Like Fbuffer_local_value, but return Qunbound if the variable is | ||
| 946 | locally unbound. */ | ||
| 947 | |||
| 948 | Lisp_Object | ||
| 949 | buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer) | ||
| 950 | { | ||
| 936 | register struct buffer *buf; | 951 | register struct buffer *buf; |
| 937 | register Lisp_Object result; | 952 | register Lisp_Object result; |
| 938 | struct Lisp_Symbol *sym; | 953 | struct Lisp_Symbol *sym; |
| @@ -985,10 +1000,7 @@ is the default binding of the variable. */) | |||
| 985 | default: abort (); | 1000 | default: abort (); |
| 986 | } | 1001 | } |
| 987 | 1002 | ||
| 988 | if (!EQ (result, Qunbound)) | 1003 | return result; |
| 989 | return result; | ||
| 990 | |||
| 991 | xsignal1 (Qvoid_variable, variable); | ||
| 992 | } | 1004 | } |
| 993 | 1005 | ||
| 994 | /* Return an alist of the Lisp-level buffer-local bindings of | 1006 | /* Return an alist of the Lisp-level buffer-local bindings of |
| @@ -5329,31 +5341,40 @@ the mode line appears at the bottom. */); | |||
| 5329 | DEFVAR_PER_BUFFER ("mode-line-format", &BVAR (current_buffer, mode_line_format), | 5341 | DEFVAR_PER_BUFFER ("mode-line-format", &BVAR (current_buffer, mode_line_format), |
| 5330 | Qnil, | 5342 | Qnil, |
| 5331 | doc: /* Template for displaying mode line for current buffer. | 5343 | doc: /* Template for displaying mode line for current buffer. |
| 5332 | Each buffer has its own value of this variable. | 5344 | |
| 5333 | Value may be nil, a string, a symbol or a list or cons cell. | 5345 | The value may be nil, a string, a symbol or a list. |
| 5346 | |||
| 5334 | A value of nil means don't display a mode line. | 5347 | A value of nil means don't display a mode line. |
| 5335 | For a symbol, its value is used (but it is ignored if t or nil). | 5348 | |
| 5336 | A string appearing directly as the value of a symbol is processed verbatim | 5349 | For any symbol other than t or nil, the symbol's value is processed as |
| 5337 | in that the %-constructs below are not recognized. | 5350 | a mode line construct. As a special exception, if that value is a |
| 5338 | Note that unless the symbol is marked as a `risky-local-variable', all | 5351 | string, the string is processed verbatim, without handling any |
| 5339 | properties in any strings, as well as all :eval and :propertize forms | 5352 | %-constructs (see below). Also, unless the symbol has a non-nil |
| 5340 | in the value of that symbol will be ignored. | 5353 | `risky-local-variable' property, all properties in any strings, as |
| 5341 | For a list of the form `(:eval FORM)', FORM is evaluated and the result | 5354 | well as all :eval and :propertize forms in the value, are ignored. |
| 5342 | is used as a mode line element. Be careful--FORM should not load any files, | 5355 | |
| 5343 | because that can cause an infinite recursion. | 5356 | A list whose car is a string or list is processed by processing each |
| 5344 | For a list of the form `(:propertize ELT PROPS...)', ELT is displayed | 5357 | of the list elements recursively, as separate mode line constructs, |
| 5345 | with the specified properties PROPS applied. | 5358 | and concatenating the results. |
| 5346 | For a list whose car is a symbol, the symbol's value is taken, | 5359 | |
| 5347 | and if that is non-nil, the cadr of the list is processed recursively. | 5360 | A list of the form `(:eval FORM)' is processed by evaluating FORM and |
| 5348 | Otherwise, the caddr of the list (if there is one) is processed. | 5361 | using the result as a mode line construct. Be careful--FORM should |
| 5349 | For a list whose car is a string or list, each element is processed | 5362 | not load any files, because that can cause an infinite recursion. |
| 5350 | recursively and the results are effectively concatenated. | 5363 | |
| 5351 | For a list whose car is an integer, the cdr of the list is processed | 5364 | A list of the form `(:propertize ELT PROPS...)' is processed by |
| 5352 | and padded (if the number is positive) or truncated (if negative) | 5365 | processing ELT as the mode line construct, and adding the text |
| 5353 | to the width specified by that number. | 5366 | properties PROPS to the result. |
| 5367 | |||
| 5368 | A list whose car is a symbol is processed by examining the symbol's | ||
| 5369 | value, and, if that value is non-nil, processing the cadr of the list | ||
| 5370 | recursively; and if that value is nil, processing the caddr of the | ||
| 5371 | list recursively. | ||
| 5372 | |||
| 5373 | A list whose car is an integer is processed by processing the cadr of | ||
| 5374 | the list, and padding (if the number is positive) or truncating (if | ||
| 5375 | negative) to the width specified by that number. | ||
| 5376 | |||
| 5354 | A string is printed verbatim in the mode line except for %-constructs: | 5377 | A string is printed verbatim in the mode line except for %-constructs: |
| 5355 | (%-constructs are allowed when the string is the entire mode-line-format | ||
| 5356 | or when it is found in a cons-cell or a list) | ||
| 5357 | %b -- print buffer name. %f -- print visited file name. | 5378 | %b -- print buffer name. %f -- print visited file name. |
| 5358 | %F -- print frame name. | 5379 | %F -- print frame name. |
| 5359 | %* -- print %, * or hyphen. %+ -- print *, % or hyphen. | 5380 | %* -- print %, * or hyphen. %+ -- print *, % or hyphen. |
diff --git a/src/buffer.h b/src/buffer.h index 97d891f044b..3aa4b11c450 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -912,6 +912,7 @@ extern void validate_region (Lisp_Object *, Lisp_Object *); | |||
| 912 | extern void set_buffer_internal (struct buffer *); | 912 | extern void set_buffer_internal (struct buffer *); |
| 913 | extern void set_buffer_internal_1 (struct buffer *); | 913 | extern void set_buffer_internal_1 (struct buffer *); |
| 914 | extern void set_buffer_temp (struct buffer *); | 914 | extern void set_buffer_temp (struct buffer *); |
| 915 | extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); | ||
| 915 | extern void record_buffer (Lisp_Object); | 916 | extern void record_buffer (Lisp_Object); |
| 916 | extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; | 917 | extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; |
| 917 | extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); | 918 | extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); |
diff --git a/src/xdisp.c b/src/xdisp.c index 0763fc19c73..6eb7f50c6fc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -751,6 +751,7 @@ static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 }; | |||
| 751 | int redisplaying_p; | 751 | int redisplaying_p; |
| 752 | 752 | ||
| 753 | static Lisp_Object Qinhibit_free_realized_faces; | 753 | static Lisp_Object Qinhibit_free_realized_faces; |
| 754 | static Lisp_Object Qmode_line_default_help_echo; | ||
| 754 | 755 | ||
| 755 | /* If a string, XTread_socket generates an event to display that string. | 756 | /* If a string, XTread_socket generates an event to display that string. |
| 756 | (The display is done in read_char.) */ | 757 | (The display is done in read_char.) */ |
| @@ -22091,7 +22092,9 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, | |||
| 22091 | return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); | 22092 | return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); |
| 22092 | } | 22093 | } |
| 22093 | 22094 | ||
| 22094 | prop = Fbuffer_local_value (prop, it->w->buffer); | 22095 | prop = buffer_local_value_1 (prop, it->w->buffer); |
| 22096 | if (EQ (prop, Qunbound)) | ||
| 22097 | prop = Qnil; | ||
| 22095 | } | 22098 | } |
| 22096 | 22099 | ||
| 22097 | if (INTEGERP (prop) || FLOATP (prop)) | 22100 | if (INTEGERP (prop) || FLOATP (prop)) |
| @@ -22141,7 +22144,9 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, | |||
| 22141 | return OK_PIXELS (pixels); | 22144 | return OK_PIXELS (pixels); |
| 22142 | } | 22145 | } |
| 22143 | 22146 | ||
| 22144 | car = Fbuffer_local_value (car, it->w->buffer); | 22147 | car = buffer_local_value_1 (car, it->w->buffer); |
| 22148 | if (EQ (car, Qunbound)) | ||
| 22149 | car = Qnil; | ||
| 22145 | } | 22150 | } |
| 22146 | 22151 | ||
| 22147 | if (INTEGERP (car) || FLOATP (car)) | 22152 | if (INTEGERP (car) || FLOATP (car)) |
| @@ -27035,7 +27040,6 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, | |||
| 27035 | if (!NILP (help)) | 27040 | if (!NILP (help)) |
| 27036 | { | 27041 | { |
| 27037 | help_echo_string = help; | 27042 | help_echo_string = help; |
| 27038 | /* Is this correct? ++kfs */ | ||
| 27039 | XSETWINDOW (help_echo_window, w); | 27043 | XSETWINDOW (help_echo_window, w); |
| 27040 | help_echo_object = w->buffer; | 27044 | help_echo_object = w->buffer; |
| 27041 | help_echo_pos = charpos; | 27045 | help_echo_pos = charpos; |
| @@ -27048,46 +27052,77 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, | |||
| 27048 | #endif /* HAVE_WINDOW_SYSTEM */ | 27052 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 27049 | 27053 | ||
| 27050 | if (STRINGP (string)) | 27054 | if (STRINGP (string)) |
| 27055 | pos = make_number (charpos); | ||
| 27056 | |||
| 27057 | /* Set the help text and mouse pointer. If the mouse is on a part | ||
| 27058 | of the mode line without any text (e.g. past the right edge of | ||
| 27059 | the mode line text), use the default help text and pointer. */ | ||
| 27060 | if (STRINGP (string) || area == ON_MODE_LINE) | ||
| 27051 | { | 27061 | { |
| 27052 | pos = make_number (charpos); | 27062 | /* Arrange to display the help by setting the global variables |
| 27053 | /* If we're on a string with `help-echo' text property, arrange | 27063 | help_echo_string, help_echo_object, and help_echo_pos. */ |
| 27054 | for the help to be displayed. This is done by setting the | ||
| 27055 | global variable help_echo_string to the help string. */ | ||
| 27056 | if (NILP (help)) | 27064 | if (NILP (help)) |
| 27057 | { | 27065 | { |
| 27058 | help = Fget_text_property (pos, Qhelp_echo, string); | 27066 | if (STRINGP (string)) |
| 27059 | if (!NILP (help)) | 27067 | help = Fget_text_property (pos, Qhelp_echo, string); |
| 27068 | |||
| 27069 | if (STRINGP (help)) | ||
| 27060 | { | 27070 | { |
| 27061 | help_echo_string = help; | 27071 | help_echo_string = help; |
| 27062 | XSETWINDOW (help_echo_window, w); | 27072 | XSETWINDOW (help_echo_window, w); |
| 27063 | help_echo_object = string; | 27073 | help_echo_object = string; |
| 27064 | help_echo_pos = charpos; | 27074 | help_echo_pos = charpos; |
| 27065 | } | 27075 | } |
| 27076 | else if (area == ON_MODE_LINE) | ||
| 27077 | { | ||
| 27078 | Lisp_Object default_help | ||
| 27079 | = buffer_local_value_1 (Qmode_line_default_help_echo, | ||
| 27080 | w->buffer); | ||
| 27081 | |||
| 27082 | if (STRINGP (default_help)) | ||
| 27083 | { | ||
| 27084 | help_echo_string = default_help; | ||
| 27085 | XSETWINDOW (help_echo_window, w); | ||
| 27086 | help_echo_object = Qnil; | ||
| 27087 | help_echo_pos = -1; | ||
| 27088 | } | ||
| 27089 | } | ||
| 27066 | } | 27090 | } |
| 27067 | 27091 | ||
| 27068 | #ifdef HAVE_WINDOW_SYSTEM | 27092 | #ifdef HAVE_WINDOW_SYSTEM |
| 27093 | /* Change the mouse pointer according to what is under it. */ | ||
| 27069 | if (FRAME_WINDOW_P (f)) | 27094 | if (FRAME_WINDOW_P (f)) |
| 27070 | { | 27095 | { |
| 27071 | dpyinfo = FRAME_X_DISPLAY_INFO (f); | 27096 | dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 27072 | cursor = FRAME_X_OUTPUT (f)->nontext_cursor; | 27097 | if (STRINGP (string)) |
| 27073 | if (NILP (pointer)) | ||
| 27074 | pointer = Fget_text_property (pos, Qpointer, string); | ||
| 27075 | |||
| 27076 | /* Change the mouse pointer according to what is under X/Y. */ | ||
| 27077 | if (NILP (pointer) | ||
| 27078 | && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE))) | ||
| 27079 | { | 27098 | { |
| 27080 | Lisp_Object map; | 27099 | cursor = FRAME_X_OUTPUT (f)->nontext_cursor; |
| 27081 | map = Fget_text_property (pos, Qlocal_map, string); | 27100 | |
| 27082 | if (!KEYMAPP (map)) | 27101 | if (NILP (pointer)) |
| 27083 | map = Fget_text_property (pos, Qkeymap, string); | 27102 | pointer = Fget_text_property (pos, Qpointer, string); |
| 27084 | if (!KEYMAPP (map)) | 27103 | |
| 27085 | cursor = dpyinfo->vertical_scroll_bar_cursor; | 27104 | /* Change the mouse pointer according to what is under X/Y. */ |
| 27105 | if (NILP (pointer) | ||
| 27106 | && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE))) | ||
| 27107 | { | ||
| 27108 | Lisp_Object map; | ||
| 27109 | map = Fget_text_property (pos, Qlocal_map, string); | ||
| 27110 | if (!KEYMAPP (map)) | ||
| 27111 | map = Fget_text_property (pos, Qkeymap, string); | ||
| 27112 | if (!KEYMAPP (map)) | ||
| 27113 | cursor = dpyinfo->vertical_scroll_bar_cursor; | ||
| 27114 | } | ||
| 27086 | } | 27115 | } |
| 27116 | else | ||
| 27117 | /* Default mode-line pointer. */ | ||
| 27118 | cursor = FRAME_X_DISPLAY_INFO (f)->vertical_scroll_bar_cursor; | ||
| 27087 | } | 27119 | } |
| 27088 | #endif | 27120 | #endif |
| 27121 | } | ||
| 27089 | 27122 | ||
| 27090 | /* Change the mouse face according to what is under X/Y. */ | 27123 | /* Change the mouse face according to what is under X/Y. */ |
| 27124 | if (STRINGP (string)) | ||
| 27125 | { | ||
| 27091 | mouse_face = Fget_text_property (pos, Qmouse_face, string); | 27126 | mouse_face = Fget_text_property (pos, Qmouse_face, string); |
| 27092 | if (!NILP (mouse_face) | 27127 | if (!NILP (mouse_face) |
| 27093 | && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)) | 27128 | && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)) |
| @@ -28428,6 +28463,8 @@ syms_of_xdisp (void) | |||
| 28428 | Vmode_line_unwind_vector = Qnil; | 28463 | Vmode_line_unwind_vector = Qnil; |
| 28429 | staticpro (&Vmode_line_unwind_vector); | 28464 | staticpro (&Vmode_line_unwind_vector); |
| 28430 | 28465 | ||
| 28466 | DEFSYM (Qmode_line_default_help_echo, "mode-line-default-help-echo"); | ||
| 28467 | |||
| 28431 | help_echo_string = Qnil; | 28468 | help_echo_string = Qnil; |
| 28432 | staticpro (&help_echo_string); | 28469 | staticpro (&help_echo_string); |
| 28433 | help_echo_object = Qnil; | 28470 | help_echo_object = Qnil; |