Mercurial > emacs
comparison lisp/bindings.el @ 42911:4e96369656bc
(mode-line-copied-mode-name): New variable.
(mode-line-mode-name): Don't modify mode-name itself!
Instead, make a copy and reuse it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 22 Jan 2002 22:46:51 +0000 |
parents | 955a445b9717 |
children | a98ecf783878 |
comparison
equal
deleted
inserted
replaced
42910:82930a88c1dd | 42911:4e96369656bc |
---|---|
314 (binding (and selection (lookup-key mode-line-mode-menu | 314 (binding (and selection (lookup-key mode-line-mode-menu |
315 (vector (car selection)))))) | 315 (vector (car selection)))))) |
316 (if binding | 316 (if binding |
317 (call-interactively binding))))) | 317 (call-interactively binding))))) |
318 | 318 |
319 (defvar mode-line-copied-mode-name nil | |
320 "A copy of `mode-name', with `help-echo' and `local-map' properties added.") | |
321 | |
319 (defun mode-line-mode-name () "\ | 322 (defun mode-line-mode-name () "\ |
320 Return a string to display in the mode line for the current mode name." | 323 Return a string to display in the mode line for the current mode name." |
321 (when (stringp mode-name) | 324 (when (stringp mode-name) |
322 (let ((local-map (get-text-property 0 'local-map mode-name)) | 325 (if (equal mode-name mode-line-copied-mode-name) |
323 (help-echo (get-text-property 0 'help-echo mode-name))) | 326 mode-line-copied-mode-name |
324 ;; For correctness, we shouldn't modify mode-name. But adding some | 327 (setq mode-line-copied-mode-name |
325 ;; text-properties to those mode-name strings can't hurt, really, and | 328 (propertize mode-name |
326 ;; furthermore, by doing it in-place, we make sure that we don't need to | 329 'local-map mode-line-minor-mode-keymap |
327 ;; do the work over and over and over and .... -stef | 330 'help-echo "mouse-3: minor mode menu")))) |
328 (unless (and local-map help-echo) | 331 mode-line-copied-mode-name) |
329 (setq mode-name (copy-sequence mode-name))) | |
330 ;; Add `local-map' property if there isn't already one. | |
331 (unless (or local-map | |
332 (next-single-property-change 0 'local-map mode-name)) | |
333 (put-text-property 0 (length mode-name) | |
334 'local-map mode-line-minor-mode-keymap mode-name) | |
335 ;; Add `help-echo' property if there isn't already one. | |
336 (unless (or help-echo | |
337 (next-single-property-change 0 'help-echo mode-name)) | |
338 (put-text-property 0 (length mode-name) 'help-echo | |
339 "mouse-3: minor mode menu" mode-name))))) | |
340 mode-name) | |
341 | 332 |
342 (defmacro bound-and-true-p (var) | 333 (defmacro bound-and-true-p (var) |
343 "Return the value of symbol VAR if it is bound, else nil." | 334 "Return the value of symbol VAR if it is bound, else nil." |
344 `(and (boundp (quote ,var)) ,var)) | 335 `(and (boundp (quote ,var)) ,var)) |
345 | 336 |