Commit 92752c3a authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

(menu-bar-menu-frame-live-and-visible-p)

(menu-bar-non-minibuffer-window-p): New functions.
("Split Window", "Save As..."): Use them.
("Postscript Print Buffer (B+W)", "Postscript Print Buffer")
("Print Buffer", "Truncate Long Lines in this Buffer"):  Use
menu-bar-menu-frame-live-and-visible-p.
("Save Buffer", "Insert File", "Open Directory...")
("Open File...", "Visit New File..."): Use
menu-bar-non-minibuffer-window-p.
(kill-this-buffer-enabled-p, dired <menu-enable>): Use
menu-bar-non-minibuffer-window-p.
parent b948abc8
......@@ -105,12 +105,8 @@ A large number or nil slows down menu responsiveness."
(define-key menu-bar-file-menu [split-window]
'(menu-item "Split Window" split-window-vertically
:enable (or (not (display-multi-frame-p))
(and (frame-live-p menu-updating-frame)
(frame-visible-p menu-updating-frame )
(not (window-minibuffer-p
(frame-selected-window
menu-updating-frame)))))
:enable (and (menu-bar-menu-frame-live-and-visible-p)
(menu-bar-non-minibuffer-window-p))
:help "Split selected window in two windows"))
(define-key menu-bar-file-menu [separator-window]
......@@ -122,9 +118,7 @@ A large number or nil slows down menu responsiveness."
:help "Pretty-print marked region in black and white to PostScript printer"))
(define-key menu-bar-file-menu [ps-print-buffer]
'(menu-item "Postscript Print Buffer (B+W)" ps-print-buffer
:enable (or (not (display-multi-frame-p))
(and (frame-live-p menu-updating-frame)
(frame-visible-p menu-updating-frame)))
:enable (menu-bar-menu-frame-live-and-visible-p)
:help "Pretty-print current buffer in black and white to PostScript printer"))
(define-key menu-bar-file-menu [ps-print-region-faces]
'(menu-item "Postscript Print Region" ps-print-region-with-faces
......@@ -132,9 +126,7 @@ A large number or nil slows down menu responsiveness."
:help "Pretty-print marked region to PostScript printer"))
(define-key menu-bar-file-menu [ps-print-buffer-faces]
'(menu-item "Postscript Print Buffer" ps-print-buffer-with-faces
:enable (or (not (display-multi-frame-p))
(and (frame-live-p menu-updating-frame)
(frame-visible-p menu-updating-frame)))
:enable (menu-bar-menu-frame-live-and-visible-p)
:help "Pretty-print current buffer to PostScript printer"))
(define-key menu-bar-file-menu [print-region]
'(menu-item "Print Region" print-region
......@@ -142,9 +134,7 @@ A large number or nil slows down menu responsiveness."
:help "Print region between mark and current position"))
(define-key menu-bar-file-menu [print-buffer]
'(menu-item "Print Buffer" print-buffer
:enable (or (not (display-multi-frame-p))
(and (frame-live-p menu-updating-frame)
(frame-visible-p menu-updating-frame)))
:enable (menu-bar-menu-frame-live-and-visible-p)
:help "Print current buffer with page headings"))
(define-key menu-bar-file-menu [separator-print]
......@@ -175,21 +165,14 @@ A large number or nil slows down menu responsiveness."
:help "Re-read current buffer from its file"))
(define-key menu-bar-file-menu [write-file]
'(menu-item "Save As..." write-file
:enable (or (not (display-multi-frame-p))
(and (frame-live-p menu-updating-frame)
(frame-visible-p menu-updating-frame )
(not (window-minibuffer-p
(frame-selected-window
menu-updating-frame)))))
:enable (and (menu-bar-menu-frame-live-and-visible-p)
(menu-bar-non-minibuffer-window-p))
:help "Write current buffer to another file"))
(define-key menu-bar-file-menu [save-buffer]
'(menu-item "Save" save-buffer
:enable (and (buffer-modified-p)
(buffer-file-name)
(or (not (display-multi-frame-p))
(not (window-minibuffer-p
(frame-selected-window
menu-updating-frame)))))
(menu-bar-non-minibuffer-window-p))
:help "Save current buffer to its file"))
(define-key menu-bar-file-menu [separator-save]
......@@ -201,28 +184,19 @@ A large number or nil slows down menu responsiveness."
:help "Discard (kill) current buffer"))
(define-key menu-bar-file-menu [insert-file]
'(menu-item "Insert File..." insert-file
:enable (or (not (display-multi-frame-p))
(and (not (window-minibuffer-p
(frame-selected-window
menu-updating-frame)))))
:enable (menu-bar-non-minibuffer-window-p)
:help "Insert another file into current buffer"))
(define-key menu-bar-file-menu [dired]
'(menu-item "Open Directory..." dired
:enable (or (not (display-multi-frame-p))
(not (window-minibuffer-p
(frame-selected-window menu-updating-frame))))
:enable (menu-bar-non-minibuffer-window-p)
:help "Read a directory, operate on its files"))
(define-key menu-bar-file-menu [open-file]
'(menu-item "Open File..." find-file-existing
:enable (or (not (display-multi-frame-p))
(not (window-minibuffer-p
(frame-selected-window menu-updating-frame))))
:enable (menu-bar-non-minibuffer-window-p)
:help "Read an existing file into an Emacs buffer"))
(define-key menu-bar-file-menu [new-file]
'(menu-item "Visit New File..." find-file
:enable (or (not (display-multi-frame-p))
(not (window-minibuffer-p
(frame-selected-window menu-updating-frame))))
:enable (menu-bar-non-minibuffer-window-p)
:help "Read or create a file and edit it"))
......@@ -1057,9 +1031,7 @@ mail status in mode line"))
toggle-truncate-lines
:help "Truncate long lines on the screen"
:button (:toggle . truncate-lines)
:enable (or (not (display-multi-frame-p))
(and (frame-live-p menu-updating-frame)
(frame-visible-p menu-updating-frame)))))
:enable (menu-bar-menu-frame-live-and-visible-p)))
(define-key menu-bar-options-menu [highlight-separator]
'("--"))
......@@ -1440,6 +1412,23 @@ key, a click, or a menu-item"))
'(menu-item "Emacs Tutorial" help-with-tutorial
:help "Learn how to use Emacs"))
(defun menu-bar-menu-frame-live-and-visible-p ()
"Return non-nil if the menu frame is alive and visible.
The menu frame is the frame for which we are updating the menu."
(let ((menu-frame (if (display-multi-frame-p) menu-updating-frame
(selected-frame))))
(and (frame-live-p menu-frame)
(frame-visible-p menu-frame))))
(defun menu-bar-non-minibuffer-window-p ()
"Return non-nil if selected window of the menu frame is not a minibuf window.
See the documentation of `menu-bar-menu-frame-live-and-visible-p'
for the definition of the menu frame."
(let ((menu-frame (if (display-multi-frame-p) menu-updating-frame
(selected-frame))))
(not (window-minibuffer-p (frame-selected-window menu-frame)))))
(defun kill-this-buffer () ; for the menubar
"Kill the current buffer."
(interactive)
......@@ -1452,11 +1441,10 @@ key, a click, or a menu-item"))
(or (string-match "^ " (buffer-name (car buffers)))
(setq count (1+ count)))
(setq buffers (cdr buffers)))
(and (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
(and (menu-bar-non-minibuffer-window-p)
(> count 1))))
(put 'dired 'menu-enable
'(not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
(put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))
;; Permit deleting frame if it would leave a visible or iconified frame.
(defun delete-frame-enabled-p ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment