1611 |
(list 'menu-item "Enter" 'exit-minibuffer |
(list 'menu-item "Enter" 'exit-minibuffer |
1612 |
:help "Terminate input and exit minibuffer"))) |
:help "Terminate input and exit minibuffer"))) |
1613 |
|
|
1614 |
(defcustom menu-bar-mode t |
;;;###autoload |
1615 |
"Toggle display of a menu bar on each frame. |
;; This comment is taken from toolbar/tool-bar.el near |
1616 |
Setting this variable directly does not take effect; |
;; (put 'tool-bar-mode ...) |
1617 |
use either \\[customize] or the function `menu-bar-mode'." |
;; We want to pretend the menu bar by standard is on, as this will make |
1618 |
:set (lambda (symbol value) |
;; customize consider disabling the menu bar a customization, and save |
1619 |
(menu-bar-mode (or value 0))) |
;; that. We could do this for real by setting :init-value below, but |
1620 |
:initialize 'custom-initialize-default |
;; that would overwrite disabling the tool bar from X resources. |
1621 |
:type 'boolean |
(put 'menu-bar-mode 'standard-value '(t)) |
|
:group 'frames) |
|
1622 |
|
|
1623 |
(defun menu-bar-mode (&optional flag) |
;;;###autoload |
1624 |
|
(define-minor-mode menu-bar-mode |
1625 |
"Toggle display of a menu bar on each frame. |
"Toggle display of a menu bar on each frame. |
1626 |
This command applies to all frames that exist and frames to be |
This command applies to all frames that exist and frames to be |
1627 |
created in the future. |
created in the future. |
1628 |
With a numeric argument, if the argument is positive, |
With a numeric argument, if the argument is positive, |
1629 |
turn on menu bars; otherwise, turn off menu bars." |
turn on menu bars; otherwise, turn off menu bars." |
1630 |
(interactive "P") |
:init-value nil |
1631 |
|
:global t |
1632 |
|
:group 'frames |
1633 |
;; Make menu-bar-mode and default-frame-alist consistent. |
;; Make menu-bar-mode and default-frame-alist consistent. |
1634 |
(let ((default (assq 'menu-bar-lines default-frame-alist))) |
(let ((lines (if menu-bar-mode 1 0))) |
1635 |
(if default |
;; Alter existing frames... |
1636 |
(setq menu-bar-mode (not (eq (cdr default) 0))) |
(mapc (lambda (frame) |
1637 |
(setq default-frame-alist |
(modify-frame-parameters frame |
1638 |
(cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) |
(list (cons 'menu-bar-lines lines)))) |
1639 |
default-frame-alist)))) |
(frame-list)) |
1640 |
|
;; ...and future ones. |
1641 |
;; Toggle or set the mode, according to FLAG. |
(let ((elt (assq 'menu-bar-lines default-frame-alist))) |
1642 |
(setq menu-bar-mode (if (null flag) (not menu-bar-mode) |
(if elt |
1643 |
(> (prefix-numeric-value flag) 0))) |
(setcdr elt lines) |
1644 |
|
(add-to-list 'default-frame-alist (cons 'menu-bar-lines lines))))) |
1645 |
;; Apply it to default-frame-alist. |
|
1646 |
(let ((parameter (assq 'menu-bar-lines default-frame-alist))) |
;; Make the message appear when Emacs is idle. We can not call message |
1647 |
(if (consp parameter) |
;; directly. The minor-mode message "Menu-bar mode disabled" comes |
1648 |
(setcdr parameter (if menu-bar-mode 1 0)) |
;; after this function returns, overwriting any message we do here. |
1649 |
(setq default-frame-alist |
(when (and (interactive-p) (not menu-bar-mode)) |
1650 |
(cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) |
(run-with-idle-timer 0 nil 'message |
1651 |
default-frame-alist)))) |
"Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")) |
|
|
|
|
;; Apply it to existing frames. |
|
|
(let ((frames (frame-list))) |
|
|
(while frames |
|
|
(let ((height (cdr (assq 'height (frame-parameters (car frames)))))) |
|
|
(modify-frame-parameters (car frames) |
|
|
(list (cons 'menu-bar-lines |
|
|
(if menu-bar-mode 1 0)))) |
|
|
(modify-frame-parameters (car frames) |
|
|
(list (cons 'height height)))) |
|
|
(setq frames (cdr frames)))) |
|
|
|
|
|
(when (interactive-p) |
|
|
(if menu-bar-mode |
|
|
(message "Menu-bar mode enabled.") |
|
|
(message "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")) |
|
|
(customize-mark-as-set 'menu-bar-mode)) |
|
|
|
|
1652 |
menu-bar-mode) |
menu-bar-mode) |
1653 |
|
|
1654 |
(provide 'menu-bar) |
(provide 'menu-bar) |