comparison lisp/modeline.el @ 286:57709be46d1b r21-0b41

Import from CVS: tag r21-0b41
author cvs
date Mon, 13 Aug 2007 10:35:03 +0200
parents 558f606b08ae
children e11d67e05968
comparison
equal deleted inserted replaced
285:9a3756523c1b 286:57709be46d1b
63 (or (button-press-event-p event) 63 (or (button-press-event-p event)
64 (error "%s must be invoked by a mouse-press" this-command)) 64 (error "%s must be invoked by a mouse-press" this-command))
65 (or (event-over-modeline-p event) 65 (or (event-over-modeline-p event)
66 (error "not over a modeline")) 66 (error "not over a modeline"))
67 ;; Give the modeline a "pressed" look. --hniksic 67 ;; Give the modeline a "pressed" look. --hniksic
68 (letf (((specifier-instance modeline-shadow-thickness 68 (with-specifier-instance modeline-shadow-thickness
69 (event-window event)) 69 (- (specifier-instance modeline-shadow-thickness (event-window event)))
70 (- (specifier-instance modeline-shadow-thickness 70 (event-window event)
71 (event-window event)))))
72 (let ((done nil) 71 (let ((done nil)
73 (depress-line (event-y event)) 72 (depress-line (event-y event))
74 (start-event-frame (event-frame event)) 73 (start-event-frame (event-frame event))
75 (start-event-window (event-window event)) 74 (start-event-window (event-window event))
76 (start-nwindows (count-windows t)) 75 (start-nwindows (count-windows t))
394 (setcdr el keymap) 393 (setcdr el keymap)
395 (funcall add-elt 394 (funcall add-elt
396 (cons toggle keymap) 395 (cons toggle keymap)
397 'minor-mode-map-alist))))) 396 'minor-mode-map-alist)))))
398 397
399 (put 'abbrev-mode :menu-tag "Abbreviation Expansion") 398 ;; #### TODO: Add `:menu-tag' keyword to add-minor-mode. Or create a
399 ;; separate function to manage the minor mode menu.
400
401 ;(put 'abbrev-mode :menu-tag "Abbreviation Expansion")
400 (add-minor-mode 'abbrev-mode " Abbrev") 402 (add-minor-mode 'abbrev-mode " Abbrev")
401 ;; only when visiting a file... 403 ;; only when visiting a file...
402 (add-minor-mode 'overwrite-mode 'overwrite-mode) 404 (add-minor-mode 'overwrite-mode 'overwrite-mode)
403 (put 'auto-fill-function :menu-tag "Auto Fill") 405 ;(put 'auto-fill-function :menu-tag "Auto Fill")
404 (add-minor-mode 'auto-fill-function " Fill" nil nil 'auto-fill-mode) 406 (add-minor-mode 'auto-fill-function " Fill" nil nil 'auto-fill-mode)
405 407
406 (put 'defining-kbd-macro :menu-tag "Keyboard Macro") 408 ;(put 'defining-kbd-macro :menu-tag "Keyboard Macro")
407 (add-minor-mode 'defining-kbd-macro " Def" nil nil 409 (add-minor-mode 'defining-kbd-macro " Def" nil nil
408 (lambda () 410 (lambda ()
409 (interactive) 411 (interactive)
410 (if defining-kbd-macro 412 (if defining-kbd-macro
411 (progn 413 (progn
433 (let* ((toggle-sym (car x)) 435 (let* ((toggle-sym (car x))
434 (toggle-fun (or (get toggle-sym 436 (toggle-fun (or (get toggle-sym
435 'modeline-toggle-function) 437 'modeline-toggle-function)
436 (and (commandp toggle-sym) 438 (and (commandp toggle-sym)
437 toggle-sym))) 439 toggle-sym)))
438 (menu-tag (or (get toggle-sym :menu-tag nil) 440 (menu-tag (symbol-name (if (symbolp toggle-fun)
439 (symbol-name (if (symbolp toggle-fun) 441 toggle-fun
440 toggle-fun 442 toggle-sym))
441 toggle-sym)) 443 ;; Here a function should
442 ;; Here a function should 444 ;; maybe be invoked to
443 ;; maybe be invoked to 445 ;; beautify the symbol's
444 ;; beautify the symbol's 446 ;; menu appearance.
445 ;; menu appearance. 447 ))
446 )))
447 (and toggle-fun 448 (and toggle-fun
448 (vector menu-tag 449 (vector menu-tag
449 toggle-fun 450 toggle-fun
450 ;; The following two are wrong 451 ;; The following two are wrong
451 ;; because of possible name 452 ;; because of possible name
536 "Modeline control for identifying the buffer being displayed. 537 "Modeline control for identifying the buffer being displayed.
537 Its default value is \"XEmacs: %17b\" (NOT!). Major modes that edit things 538 Its default value is \"XEmacs: %17b\" (NOT!). Major modes that edit things
538 other than ordinary files may change this (e.g. Info, Dired,...)") 539 other than ordinary files may change this (e.g. Info, Dired,...)")
539 (make-variable-buffer-local 'modeline-buffer-identification) 540 (make-variable-buffer-local 'modeline-buffer-identification)
540 541
541 (defvar modeline-line-number-map 542 ;; These are for the sake of minor mode menu. #### All of this is
542 (make-sparse-keymap 'modeline-line-number-map) 543 ;; kind of dirty. `add-minor-mode' started out as a simple substitute
543 "Keymap consulted for mouse-clicks on the line number in the modeline.") 544 ;; for (or (assq ...) ...) FSF stuff, but now is used for all kind of
544 545 ;; stuff. There should perhaps be a separate function to add toggles
545 (define-key modeline-line-number-map 'button2 'goto-line) 546 ;; to the minor-mode-menu.
546
547 (defvar modeline-line-number-extent (make-extent nil nil)
548 "Extent covering the modeline-line-number string.")
549 (set-extent-face modeline-line-number-extent 'modeline-mousable)
550 (set-extent-keymap modeline-line-number-extent modeline-line-number-map)
551 (set-extent-property modeline-line-number-extent 'help-echo
552 "button2 to goto a specific line")
553
554 (put 'line-number-mode :menu-tag "Line Number")
555 (add-minor-mode 'line-number-mode "") 547 (add-minor-mode 'line-number-mode "")
556 (put 'column-number-mode :menu-tag "Column Number")
557 (add-minor-mode 'column-number-mode "") 548 (add-minor-mode 'column-number-mode "")
558 549
559 (defconst modeline-process nil 550 (defconst modeline-process nil
560 "Modeline control for displaying info on process status. 551 "Modeline control for displaying info on process status.
561 Normally nil in most modes, since there is no process to display.") 552 Normally nil in most modes, since there is no process to display.")
600 (purecopy " %[(") 591 (purecopy " %[(")
601 (cons modeline-minor-mode-extent (list "" 'mode-name 'minor-mode-alist)) 592 (cons modeline-minor-mode-extent (list "" 'mode-name 'minor-mode-alist))
602 (cons modeline-narrowed-extent "%n") 593 (cons modeline-narrowed-extent "%n")
603 'modeline-process 594 'modeline-process
604 (purecopy ")%]----") 595 (purecopy ")%]----")
605 (cons modeline-line-number-extent (list 'line-number-mode (purecopy "L%l--"))) 596 (purecopy '(line-number-mode "L%l--"))
606 (purecopy '(column-number-mode "C%c--")) 597 (purecopy '(column-number-mode "C%c--"))
607 (purecopy '(-3 . "%p")) 598 (purecopy '(-3 . "%p"))
608 (purecopy "-%-"))) 599 (purecopy "-%-")))
609 600
610 ;;; Added for XEmacs 20.3. Provide wrapper for vc since it may not always be 601 ;;; Added for XEmacs 20.3. Provide wrapper for vc since it may not always be