aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-06-03 17:03:23 +0800
committerChong Yidong2012-06-03 17:03:23 +0800
commit5f2c76c6cee2b5d2d84ffd409839fd58d2ad16fa (patch)
treeccab5d66cbd6666671d529849c174c5701508d1e
parent773d47f6b23a2294baaf577f5cb783338232008c (diff)
downloademacs-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.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/modes.texi4
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/bindings.el313
-rw-r--r--src/ChangeLog12
-rw-r--r--src/buffer.c75
-rw-r--r--src/buffer.h1
-rw-r--r--src/xdisp.c83
8 files changed, 293 insertions, 210 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 850b3f9cf54..b774809feb9 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12012-06-03 Chong Yidong <cyd@gnu.org>
2
3 * modes.texi (Mode Line Data): Use "mode line construct"
4 terminology for consistency.
5
12012-05-27 Glenn Morris <rgm@gnu.org> 62012-05-27 Glenn Morris <rgm@gnu.org>
2 7
3 * abbrevs.texi, advice.texi, anti.texi, backups.texi: 8 * abbrevs.texi, advice.texi, anti.texi, backups.texi:
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 8dca250ce10..96e9b78f871 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1843,9 +1843,9 @@ properties specified by @var{props} to the result. The argument
1843A list whose first element is a symbol that is not a keyword specifies 1843A list whose first element is a symbol that is not a keyword specifies
1844a conditional. Its meaning depends on the value of @var{symbol}. If 1844a conditional. Its meaning depends on the value of @var{symbol}. If
1845@var{symbol} has a non-@code{nil} value, the second element, 1845@var{symbol} has a non-@code{nil} value, the second element,
1846@var{then}, is processed recursively as a mode line element. 1846@var{then}, is processed recursively as a mode line construct.
1847Otherwise, the third element, @var{else}, is processed recursively. 1847Otherwise, the third element, @var{else}, is processed recursively.
1848You may omit @var{else}; then the mode line element displays nothing 1848You may omit @var{else}; then the mode line construct displays nothing
1849if the value of @var{symbol} is @code{nil} or void. 1849if the value of @var{symbol} is @code{nil} or void.
1850 1850
1851@item (@var{width} @var{rest}@dots{}) 1851@item (@var{width} @var{rest}@dots{})
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e39b8a64205..5a3b1d3926d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12012-06-03 Chong Yidong <cyd@gnu.org>
2
3 * bindings.el: Remove explicit help text from format-mode-line.
4 It is now supplied by mode-line-default-help-echo.
5 (mode-line-front-space, mode-line-end-spaces)
6 (mode-line-misc-info): New variables.
7 (mode-line-modes, mode-line-position): Move the default value to
8 the variable definition.
9 (mode-line-default-help-echo): New defcustom.
10
12012-06-02 Stefan Monnier <monnier@iro.umontreal.ca> 112012-06-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 12
3 * simple.el (execute-extended-command): Set real-this-command 13 * simple.el (execute-extended-command): Set real-this-command
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 69d96ab6889..65dd68a4447 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -43,7 +43,6 @@ corresponding to the mode line clicked."
43 (with-no-warnings (toggle-read-only)) 43 (with-no-warnings (toggle-read-only))
44 (force-mode-line-update))) 44 (force-mode-line-update)))
45 45
46
47(defun mode-line-toggle-modified (event) 46(defun mode-line-toggle-modified (event)
48 "Toggle the buffer-modified flag from the mode-line." 47 "Toggle the buffer-modified flag from the mode-line."
49 (interactive "e") 48 (interactive "e")
@@ -52,7 +51,6 @@ corresponding to the mode line clicked."
52 (set-buffer-modified-p (not (buffer-modified-p))) 51 (set-buffer-modified-p (not (buffer-modified-p)))
53 (force-mode-line-update))) 52 (force-mode-line-update)))
54 53
55
56(defun mode-line-widen (event) 54(defun mode-line-widen (event)
57 "Widen a buffer from the mode-line." 55 "Widen a buffer from the mode-line."
58 (interactive "e") 56 (interactive "e")
@@ -61,7 +59,6 @@ corresponding to the mode line clicked."
61 (widen) 59 (widen)
62 (force-mode-line-update))) 60 (force-mode-line-update)))
63 61
64
65(defvar mode-line-input-method-map 62(defvar mode-line-input-method-map
66 (let ((map (make-sparse-keymap))) 63 (let ((map (make-sparse-keymap)))
67 (define-key map [mode-line mouse-2] 64 (define-key map [mode-line mouse-2]
@@ -81,7 +78,6 @@ corresponding to the mode line clicked."
81 (describe-current-input-method)))) 78 (describe-current-input-method))))
82 (purecopy map))) 79 (purecopy map)))
83 80
84
85(defvar mode-line-coding-system-map 81(defvar mode-line-coding-system-map
86 (let ((map (make-sparse-keymap))) 82 (let ((map (make-sparse-keymap)))
87 (define-key map [mode-line mouse-1] 83 (define-key map [mode-line mouse-1]
@@ -95,7 +91,6 @@ corresponding to the mode line clicked."
95 (purecopy map)) 91 (purecopy map))
96 "Local keymap for the coding-system part of the mode line.") 92 "Local keymap for the coding-system part of the mode line.")
97 93
98
99(defun mode-line-change-eol (event) 94(defun mode-line-change-eol (event)
100 "Cycle through the various possible kinds of end-of-line styles." 95 "Cycle through the various possible kinds of end-of-line styles."
101 (interactive "e") 96 (interactive "e")
@@ -130,13 +125,28 @@ corresponding to the mode line clicked."
130 (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) 125 (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache)
131 desc))) 126 desc)))
132 127
133(defvar mode-line-client 128
134 `("" 129;;; Mode line contents
135 (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" ""))) 130
136 help-echo ,(purecopy "emacsclient frame"))) 131(defcustom mode-line-default-help-echo
137 "Mode-line control for identifying emacsclient frames.") 132 "mouse-1: Select (drag to resize)\n\
138;;;###autoload 133mouse-2: Make current window occupy the whole frame\n\
139(put 'mode-line-client 'risky-local-variable t) 134mouse-3: Remove current window from display"
135 "Default help text for the mode line.
136If the value is a string, it specifies the tooltip or echo area
137message to display when the mouse is moved over the mode line.
138If the text at the mouse position has a `help-echo' text
139property, that overrides this variable."
140 :type '(choice (const :tag "No help" :value nil) string)
141 :version "24.2"
142 :group 'mode-line)
143
144(defvar mode-line-front-space '(:eval (if (display-graphic-p) " " "-"))
145 "Mode line construct to put at the front of the mode line.
146By default, this construct is displayed right at the beginning of
147the mode line, except that if there is a memory-full message, it
148is displayed first.")
149(put 'mode-line-front-space 'risky-local-variable t)
140 150
141(defvar mode-line-mule-info 151(defvar mode-line-mule-info
142 `("" 152 `(""
@@ -167,7 +177,7 @@ mouse-3: Describe current input method"))
167 'mouse-face 'mode-line-highlight 177 'mouse-face 'mode-line-highlight
168 'local-map mode-line-coding-system-map) 178 'local-map mode-line-coding-system-map)
169 (:eval (mode-line-eol-desc))) 179 (:eval (mode-line-eol-desc)))
170 "Mode-line control for displaying information of multilingual environment. 180 "Mode line construct for displaying information of multilingual environment.
171Normally it displays current input method (if any activated) and 181Normally it displays current input method (if any activated) and
172mnemonics of the following coding systems: 182mnemonics of the following coding systems:
173 coding system for saving or writing the current buffer 183 coding system for saving or writing the current buffer
@@ -177,34 +187,17 @@ mnemonics of the following coding systems:
177 ;; coding system for decoding output of buffer process (if any) 187 ;; coding system for decoding output of buffer process (if any)
178 ;; coding system for encoding text to send to buffer process (if any)." 188 ;; coding system for encoding text to send to buffer process (if any)."
179) 189)
180
181;;;###autoload 190;;;###autoload
182(put 'mode-line-mule-info 'risky-local-variable t) 191(put 'mode-line-mule-info 'risky-local-variable t)
183(make-variable-buffer-local 'mode-line-mule-info) 192(make-variable-buffer-local 'mode-line-mule-info)
184 193
185;; MSDOS frames have window-system, but want the Fn identification. 194(defvar mode-line-client
186(defun mode-line-frame-control () 195 `(""
187 "Compute mode-line control for frame identification. 196 (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" "")))
188Value is used for `mode-line-frame-identification', which see." 197 help-echo ,(purecopy "emacsclient frame")))
189 (if (or (null window-system) 198 "Mode line construct for identifying emacsclient frames.")
190 (eq window-system 'pc))
191 "-%F "
192 " "))
193
194;; We need to defer the call to mode-line-frame-control to the time
195;; the mode line is actually displayed.
196(defvar mode-line-frame-identification '(:eval (mode-line-frame-control))
197 "Mode-line control to describe the current frame.")
198;;;###autoload
199(put 'mode-line-frame-identification 'risky-local-variable t)
200
201(defvar mode-line-process nil "\
202Mode-line control for displaying info on process status.
203Normally nil in most modes, since there is no process to display.")
204
205;;;###autoload 199;;;###autoload
206(put 'mode-line-process 'risky-local-variable t) 200(put 'mode-line-client 'risky-local-variable t)
207(make-variable-buffer-local 'mode-line-process)
208 201
209(defvar mode-line-modified 202(defvar mode-line-modified
210 (list (propertize 203 (list (propertize
@@ -232,8 +225,7 @@ Normally nil in most modes, since there is no process to display.")
232 'local-map (purecopy (make-mode-line-mouse-map 225 'local-map (purecopy (make-mode-line-mouse-map
233 'mouse-1 #'mode-line-toggle-modified)) 226 'mouse-1 #'mode-line-toggle-modified))
234 'mouse-face 'mode-line-highlight)) 227 'mouse-face 'mode-line-highlight))
235 "Mode-line control for displaying whether current buffer is modified.") 228 "Mode line construct for displaying whether current buffer is modified.")
236
237;;;###autoload 229;;;###autoload
238(put 'mode-line-modified 'risky-local-variable t) 230(put 'mode-line-modified 'risky-local-variable t)
239(make-variable-buffer-local 'mode-line-modified) 231(make-variable-buffer-local 'mode-line-modified)
@@ -251,24 +243,33 @@ Normally nil in most modes, since there is no process to display.")
251 "Current directory is remote: " 243 "Current directory is remote: "
252 "Current directory is local: ") 244 "Current directory is local: ")
253 default-directory))))))) 245 default-directory)))))))
254 "Mode-line flag to show if default-directory for current buffer is remote.") 246 "Mode line construct to indicate a remote buffer.")
255;;;###autoload 247;;;###autoload
256(put 'mode-line-remote 'risky-local-variable t) 248(put 'mode-line-remote 'risky-local-variable t)
257
258(make-variable-buffer-local 'mode-line-remote) 249(make-variable-buffer-local 'mode-line-remote)
259 250
260;; Actual initialization is below. 251;; MSDOS frames have window-system, but want the Fn identification.
261(defvar mode-line-position nil 252(defun mode-line-frame-control ()
262 "Mode-line control for displaying the position in the buffer. 253 "Compute mode line construct for frame identification.
263Normally displays the buffer percentage and, optionally, the 254Value is used for `mode-line-frame-identification', which see."
264buffer size, the line number and the column number.") 255 (if (or (null window-system)
256 (eq window-system 'pc))
257 "-%F "
258 " "))
259
260;; We need to defer the call to mode-line-frame-control to the time
261;; the mode line is actually displayed.
262(defvar mode-line-frame-identification '(:eval (mode-line-frame-control))
263 "Mode line construct to describe the current frame.")
265;;;###autoload 264;;;###autoload
266(put 'mode-line-position 'risky-local-variable t) 265(put 'mode-line-frame-identification 'risky-local-variable t)
267 266
268(defvar mode-line-modes nil 267(defvar mode-line-process nil
269 "Mode-line control for displaying major and minor modes.") 268 "Mode line construct for displaying info on process status.
269Normally nil in most modes, since there is no process to display.")
270;;;###autoload 270;;;###autoload
271(put 'mode-line-modes 'risky-local-variable t) 271(put 'mode-line-process 'risky-local-variable t)
272(make-variable-buffer-local 'mode-line-process)
272 273
273(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\ 274(defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
274Menu of mode operations in the mode line.") 275Menu of mode operations in the mode line.")
@@ -292,6 +293,35 @@ Keymap to display on major mode.")
292 map) "\ 293 map) "\
293Keymap to display on minor modes.") 294Keymap to display on minor modes.")
294 295
296(defvar mode-line-modes
297 (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out"))
298 (list (propertize "%[" 'help-echo recursive-edit-help-echo)
299 "("
300 `(:propertize ("" mode-name)
301 help-echo "Major mode\n\
302mouse-1: Display major mode menu\n\
303mouse-2: Show help for major mode\n\
304mouse-3: Toggle minor modes"
305 mouse-face mode-line-highlight
306 local-map ,mode-line-major-mode-keymap)
307 '("" mode-line-process)
308 `(:propertize ("" minor-mode-alist)
309 mouse-face mode-line-highlight
310 help-echo "Minor mode\n\
311mouse-1: Display minor mode menu\n\
312mouse-2: Show help for minor mode\n\
313mouse-3: Toggle minor modes"
314 local-map ,mode-line-minor-mode-keymap)
315 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from the current buffer"
316 'mouse-face 'mode-line-highlight
317 'local-map (make-mode-line-mouse-map
318 'mouse-2 #'mode-line-widen))
319 ")"
320 (propertize "%]" 'help-echo recursive-edit-help-echo)
321 " "))
322 "Mode line construct for displaying major and minor modes.")
323(put 'mode-line-modes 'risky-local-variable t)
324
295(defvar mode-line-column-line-number-mode-map 325(defvar mode-line-column-line-number-mode-map
296 (let ((map (make-sparse-keymap)) 326 (let ((map (make-sparse-keymap))
297 (menu-map (make-sparse-keymap "Toggle Line and Column Number Display"))) 327 (menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
@@ -307,114 +337,47 @@ Keymap to display on minor modes.")
307 map) "\ 337 map) "\
308Keymap to display on column and line numbers.") 338Keymap to display on column and line numbers.")
309 339
310(let* ((help-echo 340(defvar mode-line-position
311 ;; The multi-line message doesn't work terribly well on the 341 `((-3 ,(propertize
312 ;; bottom mode line... Better ideas? 342 "%p"
313 ;; "\ 343 'local-map mode-line-column-line-number-mode-map
314 ;; mouse-1: select window, mouse-2: delete others, mouse-3: delete, 344 'mouse-face 'mode-line-highlight
315 ;; drag-mouse-1: resize, C-mouse-2: split horizontally" 345 ;; XXX needs better description
316 "mouse-1: Select (drag to resize)\n\ 346 'help-echo "Size indication mode\n\
317mouse-2: Make current window occupy the whole frame\n\
318mouse-3: Remove current window from display")
319 (recursive-edit-help-echo "Recursive edit, type C-M-c to get out")
320 (spaces (propertize " " 'help-echo help-echo))
321 (standard-mode-line-format
322 (list
323 "%e"
324 `(:eval (if (display-graphic-p)
325 ,(propertize " " 'help-echo help-echo)
326 ,(propertize "-" 'help-echo help-echo)))
327 'mode-line-mule-info
328 'mode-line-client
329 'mode-line-modified
330 'mode-line-remote
331 'mode-line-frame-identification
332 'mode-line-buffer-identification
333 (propertize " " 'help-echo help-echo)
334 'mode-line-position
335 '(vc-mode vc-mode)
336 (propertize " " 'help-echo help-echo)
337 'mode-line-modes
338 `(which-func-mode ("" which-func-format ,spaces))
339 `(global-mode-string ("" global-mode-string ,spaces))
340 `(:eval (unless (display-graphic-p)
341 ,(propertize "-%-" 'help-echo help-echo)))))
342 (standard-mode-line-modes
343 (list
344 (propertize "%[" 'help-echo recursive-edit-help-echo)
345 (propertize "(" 'help-echo help-echo)
346 `(:propertize ("" mode-name)
347 help-echo "Major mode\n\
348mouse-1: Display major mode menu\n\
349mouse-2: Show help for major mode\n\
350mouse-3: Toggle minor modes"
351 mouse-face mode-line-highlight
352 local-map ,mode-line-major-mode-keymap)
353 '("" mode-line-process)
354 `(:propertize ("" minor-mode-alist)
355 mouse-face mode-line-highlight
356 help-echo "Minor mode\n\
357mouse-1: Display minor mode menu\n\
358mouse-2: Show help for minor mode\n\
359mouse-3: Toggle minor modes"
360 local-map ,mode-line-minor-mode-keymap)
361 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from the current buffer"
362 'mouse-face 'mode-line-highlight
363 'local-map (make-mode-line-mouse-map
364 'mouse-2 #'mode-line-widen))
365 (propertize ")" 'help-echo help-echo)
366 (propertize "%]" 'help-echo recursive-edit-help-echo)
367 spaces))
368
369 (standard-mode-line-position
370 `((-3 ,(propertize
371 "%p"
372 'local-map mode-line-column-line-number-mode-map
373 'mouse-face 'mode-line-highlight
374 ;; XXX needs better description
375 'help-echo "Size indication mode\n\
376mouse-1: Display Line and Column Mode Menu")) 347mouse-1: Display Line and Column Mode Menu"))
377 (size-indication-mode 348 (size-indication-mode
378 (8 ,(propertize 349 (8 ,(propertize
379 " of %I" 350 " of %I"
380 'local-map mode-line-column-line-number-mode-map 351 'local-map mode-line-column-line-number-mode-map
381 'mouse-face 'mode-line-highlight 352 'mouse-face 'mode-line-highlight
382 ;; XXX needs better description 353 ;; XXX needs better description
383 'help-echo "Size indication mode\n\ 354 'help-echo "Size indication mode\n\
384mouse-1: Display Line and Column Mode Menu"))) 355mouse-1: Display Line and Column Mode Menu")))
385 (line-number-mode 356 (line-number-mode
386 ((column-number-mode 357 ((column-number-mode
387 (10 ,(propertize 358 (10 ,(propertize
388 " (%l,%c)" 359 " (%l,%c)"
389 'local-map mode-line-column-line-number-mode-map 360 'local-map mode-line-column-line-number-mode-map
390 'mouse-face 'mode-line-highlight 361 'mouse-face 'mode-line-highlight
391 'help-echo "Line number and Column number\n\ 362 'help-echo "Line number and Column number\n\
392mouse-1: Display Line and Column Mode Menu")) 363mouse-1: Display Line and Column Mode Menu"))
393 (6 ,(propertize 364 (6 ,(propertize
394 " L%l" 365 " L%l"
395 'local-map mode-line-column-line-number-mode-map 366 'local-map mode-line-column-line-number-mode-map
396 'mouse-face 'mode-line-highlight 367 'mouse-face 'mode-line-highlight
397 'help-echo "Line Number\n\ 368 'help-echo "Line Number\n\
398mouse-1: Display Line and Column Mode Menu")))) 369mouse-1: Display Line and Column Mode Menu"))))
399 ((column-number-mode 370 ((column-number-mode
400 (5 ,(propertize 371 (5 ,(propertize
401 " C%c" 372 " C%c"
402 'local-map mode-line-column-line-number-mode-map 373 'local-map mode-line-column-line-number-mode-map
403 'mouse-face 'mode-line-highlight 374 'mouse-face 'mode-line-highlight
404 'help-echo "Column number\n\ 375 'help-echo "Column number\n\
405mouse-1: Display Line and Column Mode Menu")))))))) 376mouse-1: Display Line and Column Mode Menu"))))))
406 377 "Mode line construct for displaying the position in the buffer.
407 (setq-default mode-line-format standard-mode-line-format) 378Normally displays the buffer percentage and, optionally, the
408 (put 'mode-line-format 'standard-value 379buffer size, the line number and the column number.")
409 (list `(quote ,standard-mode-line-format))) 380(put 'mode-line-position 'risky-local-variable t)
410
411 (setq-default mode-line-modes standard-mode-line-modes)
412 (put 'mode-line-modes 'standard-value
413 (list `(quote ,standard-mode-line-modes)))
414
415 (setq-default mode-line-position standard-mode-line-position)
416 (put 'mode-line-position 'standard-value
417 (list `(quote ,standard-mode-line-position))))
418 381
419(defvar mode-line-buffer-identification-keymap 382(defvar mode-line-buffer-identification-keymap
420 ;; Add menu of buffer operations to the buffer identification part 383 ;; Add menu of buffer operations to the buffer identification part
@@ -444,16 +407,50 @@ mouse-3: next buffer")
444 'mouse-face 'mode-line-highlight 407 'mouse-face 'mode-line-highlight
445 'local-map mode-line-buffer-identification-keymap))) 408 'local-map mode-line-buffer-identification-keymap)))
446 409
447(defvar mode-line-buffer-identification (propertized-buffer-identification "%12b") "\ 410(defvar mode-line-buffer-identification
448Mode-line control for identifying the buffer being displayed. 411 (propertized-buffer-identification "%12b")
412 "Mode line construct for identifying the buffer being displayed.
449Its default value is (\"%12b\") with some text properties added. 413Its default value is (\"%12b\") with some text properties added.
450Major modes that edit things other than ordinary files may change this 414Major modes that edit things other than ordinary files may change this
451\(e.g. Info, Dired,...)") 415\(e.g. Info, Dired,...)")
452
453;;;###autoload 416;;;###autoload
454(put 'mode-line-buffer-identification 'risky-local-variable t) 417(put 'mode-line-buffer-identification 'risky-local-variable t)
455(make-variable-buffer-local 'mode-line-buffer-identification) 418(make-variable-buffer-local 'mode-line-buffer-identification)
456 419
420(defvar mode-line-misc-info
421 '((which-func-mode ("" which-func-format " "))
422 (global-mode-string ("" global-mode-string " ")))
423 "Mode line construct for miscellaneous information.
424By default, this shows the information specified by
425`which-func-mode' and `global-mode-string'.")
426(put 'mode-line-misc-info 'risky-local-variable t)
427
428(defvar mode-line-end-spaces '(:eval (unless (display-graphic-p) "-%-"))
429 "Mode line construct to put at the end of the mode line.")
430(put 'mode-line-end-spaces 'risky-local-variable t)
431
432;; Default value of the top-level `mode-line-format' variable:
433(let ((standard-mode-line-format
434 (list "%e"
435 'mode-line-front-space
436 'mode-line-mule-info
437 'mode-line-client
438 'mode-line-modified
439 'mode-line-remote
440 'mode-line-frame-identification
441 'mode-line-buffer-identification
442 " "
443 'mode-line-position
444 '(vc-mode vc-mode)
445 " "
446 'mode-line-modes
447 'mode-line-misc-info
448 'mode-line-end-spaces)))
449 (setq-default mode-line-format standard-mode-line-format)
450 (put 'mode-line-format 'standard-value
451 (list `(quote ,standard-mode-line-format))))
452
453
457(defun mode-line-unbury-buffer (event) "\ 454(defun mode-line-unbury-buffer (event) "\
458Call `unbury-buffer' in this window." 455Call `unbury-buffer' in this window."
459 (interactive "e") 456 (interactive "e")
@@ -551,8 +548,8 @@ Alist saying how to show minor modes in the mode line.
551Each element looks like (VARIABLE STRING); 548Each element looks like (VARIABLE STRING);
552STRING is included in the mode line if VARIABLE's value is non-nil. 549STRING is included in the mode line if VARIABLE's value is non-nil.
553 550
554Actually, STRING need not be a string; any possible mode-line element 551Actually, STRING need not be a string; any mode-line construct is
555is okay. See `mode-line-format'.") 552okay. See `mode-line-format'.")
556;;;###autoload 553;;;###autoload
557(put 'minor-mode-alist 'risky-local-variable t) 554(put 'minor-mode-alist 'risky-local-variable t)
558;; Don't use purecopy here--some people want to change these strings. 555;; Don't use purecopy here--some people want to change these strings.
diff --git a/src/ChangeLog b/src/ChangeLog
index b90db0b7fa9..c0098445cb8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12012-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
12012-06-02 Paul Eggert <eggert@cs.ucla.edu> 132012-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
933is the default binding of the variable. */) 933is 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
948Lisp_Object
949buffer_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.
5332Each buffer has its own value of this variable. 5344
5333Value may be nil, a string, a symbol or a list or cons cell. 5345The value may be nil, a string, a symbol or a list.
5346
5334A value of nil means don't display a mode line. 5347A value of nil means don't display a mode line.
5335For 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 5349For 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
5341For 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. 5356A list whose car is a string or list is processed by processing each
5344For 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.
5346For 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. 5360A 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
5349For 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
5351For a list whose car is an integer, the cdr of the list is processed 5364A 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
5368A 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
5373A 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
5354A string is printed verbatim in the mode line except for %-constructs: 5377A 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 *);
912extern void set_buffer_internal (struct buffer *); 912extern void set_buffer_internal (struct buffer *);
913extern void set_buffer_internal_1 (struct buffer *); 913extern void set_buffer_internal_1 (struct buffer *);
914extern void set_buffer_temp (struct buffer *); 914extern void set_buffer_temp (struct buffer *);
915extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object);
915extern void record_buffer (Lisp_Object); 916extern void record_buffer (Lisp_Object);
916extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; 917extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN;
917extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); 918extern 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 };
751int redisplaying_p; 751int redisplaying_p;
752 752
753static Lisp_Object Qinhibit_free_realized_faces; 753static Lisp_Object Qinhibit_free_realized_faces;
754static 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;