comparison lisp/bindings.el @ 43267:a98ecf783878

(mode-line-minor-mode-keymap): Definition moved up. Initialization moved up too. (mode-line-modes): Use :propertize. (mode-line-mode-menu-keymap): Var deleted. (mode-line-copied-mode-name): Var deleted. (mode-line-mode-name): Function deleted. (mode-line-mode-menu): Each item now shows its mode line lighter. (minor-mode-alist): Don't call propertize here.
author Richard M. Stallman <rms@gnu.org>
date Wed, 13 Feb 2002 15:57:15 +0000
parents 4e96369656bc
children fc8561532c81 df1051e0b79f
comparison
equal deleted inserted replaced
43266:56b68a777e75 43267:a98ecf783878
225 "Mode-line control for displaying line number, column number and fraction.") 225 "Mode-line control for displaying line number, column number and fraction.")
226 226
227 (defvar mode-line-modes nil 227 (defvar mode-line-modes nil
228 "Mode-line control for displaying major and minor modes.") 228 "Mode-line control for displaying major and minor modes.")
229 229
230 (defvar mode-line-minor-mode-keymap nil "\
231 Keymap to display on major and minor modes.")
232
233 ;; Menu of minor modes.
234 (let ((map (make-sparse-keymap)))
235 (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
236 (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1)
237 (setq mode-line-minor-mode-keymap map))
238
230 (let* ((help-echo 239 (let* ((help-echo
231 ;; The multi-line message doesn't work terribly well on the 240 ;; The multi-line message doesn't work terribly well on the
232 ;; bottom mode line... Better ideas? 241 ;; bottom mode line... Better ideas?
233 ;; "\ 242 ;; "\
234 ;; mouse-1: select window, mouse-2: delete others, mouse-3: delete, 243 ;; mouse-1: select window, mouse-2: delete others, mouse-3: delete,
250 (propertize "-%-" 'help-echo help-echo))) 259 (propertize "-%-" 'help-echo help-echo)))
251 260
252 (setq-default mode-line-modes 261 (setq-default mode-line-modes
253 (list 262 (list
254 (propertize " %[(" 'help-echo help-echo) 263 (propertize " %[(" 'help-echo help-echo)
255 '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist 264 `(:propertize ("" mode-name mode-line-process minor-mode-alist)
265 help-echo "mouse-3: minor mode menu"
266 local-map ,mode-line-minor-mode-keymap)
256 (propertize "%n" 'help-echo "mouse-2: widen" 267 (propertize "%n" 'help-echo "mouse-2: widen"
257 'local-map (make-mode-line-mouse-map 268 'local-map (make-mode-line-mouse-map
258 'mouse-2 #'mode-line-widen)) 269 'mouse-2 #'mode-line-widen))
259 (propertize ")%]--" 'help-echo help-echo))) 270 (propertize ")%]--" 'help-echo help-echo)))
260 271
263 (column-number-mode (,(propertize "C%c" 'help-echo help-echo) ,dashes)) 274 (column-number-mode (,(propertize "C%c" 'help-echo help-echo) ,dashes))
264 (-3 . ,(propertize "%p" 'help-echo help-echo))))) 275 (-3 . ,(propertize "%p" 'help-echo help-echo)))))
265 276
266 (defvar mode-line-buffer-identification-keymap nil "\ 277 (defvar mode-line-buffer-identification-keymap nil "\
267 Keymap for what is displayed by `mode-line-buffer-identification'.") 278 Keymap for what is displayed by `mode-line-buffer-identification'.")
268
269 (defvar mode-line-minor-mode-keymap nil "\
270 Keymap for what is displayed by `mode-line-mode-name'.")
271
272 (defvar mode-line-mode-menu-keymap nil "\
273 Keymap for mode operations menu in the mode line.")
274 279
275 (defun last-buffer () "\ 280 (defun last-buffer () "\
276 Return the last non-hidden buffer in the buffer list." 281 Return the last non-hidden buffer in the buffer list."
277 (let ((list (reverse (buffer-list)))) 282 (let ((list (reverse (buffer-list))))
278 (while (eq (aref (buffer-name (car list)) 0) ? ) 283 (while (eq (aref (buffer-name (car list)) 0) ? )
314 (binding (and selection (lookup-key mode-line-mode-menu 319 (binding (and selection (lookup-key mode-line-mode-menu
315 (vector (car selection)))))) 320 (vector (car selection))))))
316 (if binding 321 (if binding
317 (call-interactively binding))))) 322 (call-interactively binding)))))
318 323
319 (defvar mode-line-copied-mode-name nil
320 "A copy of `mode-name', with `help-echo' and `local-map' properties added.")
321
322 (defun mode-line-mode-name () "\
323 Return a string to display in the mode line for the current mode name."
324 (when (stringp mode-name)
325 (if (equal mode-name mode-line-copied-mode-name)
326 mode-line-copied-mode-name
327 (setq mode-line-copied-mode-name
328 (propertize mode-name
329 'local-map mode-line-minor-mode-keymap
330 'help-echo "mouse-3: minor mode menu"))))
331 mode-line-copied-mode-name)
332
333 (defmacro bound-and-true-p (var) 324 (defmacro bound-and-true-p (var)
334 "Return the value of symbol VAR if it is bound, else nil." 325 "Return the value of symbol VAR if it is bound, else nil."
335 `(and (boundp (quote ,var)) ,var)) 326 `(and (boundp (quote ,var)) ,var))
336 327
337 (define-key mode-line-mode-menu [overwrite-mode] 328 (define-key mode-line-mode-menu [overwrite-mode]
338 `(menu-item ,(purecopy "Overwrite") overwrite-mode 329 `(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode
339 :button (:toggle . overwrite-mode))) 330 :button (:toggle . overwrite-mode)))
340 (define-key mode-line-mode-menu [outline-minor-mode] 331 (define-key mode-line-mode-menu [outline-minor-mode]
341 `(menu-item ,(purecopy "Outline") outline-minor-mode 332 `(menu-item ,(purecopy "Outline (Outl)") outline-minor-mode
342 :button (:toggle . (bound-and-true-p outline-minor-mode)))) 333 :button (:toggle . (bound-and-true-p outline-minor-mode))))
343 (define-key mode-line-mode-menu [line-number-mode] 334 (define-key mode-line-mode-menu [line-number-mode]
344 `(menu-item ,(purecopy "Line number") line-number-mode 335 `(menu-item ,(purecopy "Line number") line-number-mode
345 :button (:toggle . line-number-mode))) 336 :button (:toggle . line-number-mode)))
346 (define-key mode-line-mode-menu [highlight-changes-mode] 337 (define-key mode-line-mode-menu [highlight-changes-mode]
347 `(menu-item ,(purecopy "Highlight changes") highlight-changes-mode 338 `(menu-item ,(purecopy "Highlight changes (Chg)") highlight-changes-mode
348 :button (:toggle . highlight-changes-mode))) 339 :button (:toggle . highlight-changes-mode)))
349 (define-key mode-line-mode-menu [glasses-mode] 340 (define-key mode-line-mode-menu [glasses-mode]
350 `(menu-item ,(purecopy "Glasses") glasses-mode 341 `(menu-item ,(purecopy "Glasses (o^o)") glasses-mode
351 :button (:toggle . (bound-and-true-p glasses-mode)))) 342 :button (:toggle . (bound-and-true-p glasses-mode))))
352 (define-key mode-line-mode-menu [hide-ifdef-mode] 343 (define-key mode-line-mode-menu [hide-ifdef-mode]
353 `(menu-item ,(purecopy "Hide ifdef") hide-ifdef-mode 344 `(menu-item ,(purecopy "Hide ifdef (Ifdef)") hide-ifdef-mode
354 :button (:toggle . (bound-and-true-p hide-ifdef-mode)))) 345 :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
355 (define-key mode-line-mode-menu [font-lock-mode] 346 (define-key mode-line-mode-menu [font-lock-mode]
356 `(menu-item ,(purecopy "Font-lock") font-lock-mode 347 `(menu-item ,(purecopy "Font-lock") font-lock-mode
357 :button (:toggle . font-lock-mode))) 348 :button (:toggle . font-lock-mode)))
358 (define-key mode-line-mode-menu [flyspell-mode] 349 (define-key mode-line-mode-menu [flyspell-mode]
359 `(menu-item ,(purecopy "Flyspell") flyspell-mode 350 `(menu-item ,(purecopy "Flyspell (Fly)") flyspell-mode
360 :button (:toggle . (bound-and-true-p flyspell-mode)))) 351 :button (:toggle . (bound-and-true-p flyspell-mode))))
361 (define-key mode-line-mode-menu [column-number-mode] 352 (define-key mode-line-mode-menu [column-number-mode]
362 `(menu-item ,(purecopy "Column number") column-number-mode 353 `(menu-item ,(purecopy "Column number") column-number-mode
363 :button (:toggle . column-number-mode))) 354 :button (:toggle . column-number-mode)))
364 (define-key mode-line-mode-menu [auto-fill-mode] 355 (define-key mode-line-mode-menu [auto-fill-mode]
365 `(menu-item ,(purecopy "Auto-fill") auto-fill-mode 356 `(menu-item ,(purecopy "Auto-fill (Fill)") auto-fill-mode
366 :button (:toggle . auto-fill-function))) 357 :button (:toggle . auto-fill-function)))
367 (define-key mode-line-mode-menu [auto-revert-mode] 358 (define-key mode-line-mode-menu [auto-revert-mode]
368 `(menu-item ,(purecopy "Auto revert") auto-revert-mode 359 `(menu-item ,(purecopy "Auto revert (ARev)") auto-revert-mode
369 :button (:toggle . auto-revert-mode))) 360 :button (:toggle . auto-revert-mode)))
370 (define-key mode-line-mode-menu [abbrev-mode] 361 (define-key mode-line-mode-menu [abbrev-mode]
371 `(menu-item ,(purecopy "Abbrev") abbrev-mode 362 `(menu-item ,(purecopy "Abbrev (Abbrev)") abbrev-mode
372 :button (:toggle . abbrev-mode))) 363 :button (:toggle . abbrev-mode)))
373 364
374 (defun mode-line-mode-menu (event) 365 (defun mode-line-mode-menu (event)
375 (interactive "@e") 366 (interactive "@e")
376 (x-popup-menu event mode-line-mode-menu)) 367 (x-popup-menu event mode-line-mode-menu))
402 'local-map mode-line-buffer-identification-keymap))) 393 'local-map mode-line-buffer-identification-keymap)))
403 394
404 (setq-default mode-line-buffer-identification 395 (setq-default mode-line-buffer-identification
405 (propertized-buffer-identification "%12b")) 396 (propertized-buffer-identification "%12b"))
406 397
407 ;; Menu of minor modes.
408 (let ((map (make-sparse-keymap)))
409 (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1)
410 (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1)
411 (setq mode-line-minor-mode-keymap map))
412
413 (defvar minor-mode-alist nil "\ 398 (defvar minor-mode-alist nil "\
414 Alist saying how to show minor modes in the mode line. 399 Alist saying how to show minor modes in the mode line.
415 Each element looks like (VARIABLE STRING); 400 Each element looks like (VARIABLE STRING);
416 STRING is included in the mode line iff VARIABLE's value is non-nil. 401 STRING is included in the mode line iff VARIABLE's value is non-nil.
417 402
418 Actually, STRING need not be a string; any possible mode-line element 403 Actually, STRING need not be a string; any possible mode-line element
419 is okay. See `mode-line-format'.") 404 is okay. See `mode-line-format'.")
420 ;; Don't use purecopy here--some people want to change these strings. 405 ;; Don't use purecopy here--some people want to change these strings.
421 (setq minor-mode-alist 406 (setq minor-mode-alist
422 (list 407 (list
423 (list 'abbrev-mode 408 (list 'abbrev-mode " Abbrev")
424 (propertize " Abbrev"
425 'help-echo (purecopy "mouse-3: minor mode menu")
426 'local-map mode-line-minor-mode-keymap))
427 '(overwrite-mode overwrite-mode) 409 '(overwrite-mode overwrite-mode)
428 (list 'auto-fill-function 410 (list 'auto-fill-function " Fill")
429 (propertize " Fill"
430 'help-echo (purecopy "mouse-3: minor mode menu")
431 'local-map mode-line-minor-mode-keymap))
432 ;; not really a minor mode... 411 ;; not really a minor mode...
433 '(defining-kbd-macro " Def"))) 412 '(defining-kbd-macro " Def")))
434 413
435 ;; These variables are used by autoloadable packages. 414 ;; These variables are used by autoloadable packages.
436 ;; They are defined here so that they do not get overridden 415 ;; They are defined here so that they do not get overridden