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/buffer.c | |
| 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/buffer.c')
| -rw-r--r-- | src/buffer.c | 75 |
1 files changed, 48 insertions, 27 deletions
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. |