'frame-visible-p' returns nil or 'icon' for it. This can happen, for
example, as part of preview for iconified frames.
+---
+** New user option 'menu-bar-close-window'.
+When non-nil, selecting Close from the File menu or clicking Close in
+the tool bar will result in the current window being closed, if
+possible.
+
+++
** 'write-region-inhibit-fsync' now defaults to t in interactive mode,
as it has in batch mode since Emacs 24.
:help "Print current buffer with page headings"))
menu))
+(defcustom menu-bar-close-window nil
+ "Whether or not to close the current window from the menu bar.
+If non-nil, selecting Close from the File menu or clicking Close
+in the tool bar will close the current window where possible."
+ :type 'boolean
+ :group 'menu
+ :version "30.1")
+
(defvar menu-bar-file-menu
(let ((menu (make-sparse-keymap "File")))
;; (Bug#8184).
((not (menu-bar-menu-frame-live-and-visible-p)))
((menu-bar-non-minibuffer-window-p)
- (kill-buffer (current-buffer)))
+ (kill-buffer (current-buffer))
+ ;; Also close the current window if `menu-bar-close-windows' is
+ ;; set.
+ (when menu-bar-close-window
+ (ignore-errors (delete-window))))
(t
(abort-recursive-edit))))
(defun kill-this-buffer-enabled-p ()
- "Return non-nil if the `kill-this-buffer' menu item should be enabled."
+ "Return non-nil if the `kill-this-buffer' menu item should be enabled.
+It should be enabled there is at least one non-hidden buffer, or if
+`menu-bar-close-window' is non-nil and there is more than one window on
+this frame."
(or (not (menu-bar-non-minibuffer-window-p))
(let (found-1)
;; Instead of looping over entire buffer list, stop once we've
(unless (string-match-p "^ " (buffer-name buffer))
(if (not found-1)
(setq found-1 t)
- (throw 'found-2 t))))))))
+ (throw 'found-2 t))))))
+ (and menu-bar-close-window
+ (window-parent (selected-window)))))
(put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))
function keys that Emacs recognizes. */
[111] = "escape",
[112] = "delete",
- [121] = "break",
[120] = "sysrq",
+ [121] = "break",
[122] = "home",
[123] = "end",
[124] = "insert",
+ [126] = "media-play",
+ [127] = "media-pause",
+ [130] = "media-record",
[131] = "f1",
[132] = "f2",
[133] = "f3",
[19] = "up",
[20] = "down",
[213] = "muhenkan",
+ [213] = "muhenkan",
+ [214] = "henkan",
[214] = "henkan",
[215] = "hiragana-katakana",
[218] = "kana",
[21] = "left",
[22] = "right",
[24] = "volume-up",
- [25] = "volume-down",
[259] = "help",
+ [25] = "volume-down",
[268] = "kp-up-left",
[269] = "kp-down-left",
[270] = "kp-up-right",
[271] = "kp-down-right",
+ [272] = "media-skip-forward",
+ [273] = "media-skip-backward",
[277] = "cut",
[278] = "copy",
[279] = "paste",
[67] = "backspace",
[82] = "menu",
[84] = "find",
+ [85] = "media-play-pause",
+ [86] = "media-stop",
+ [87] = "media-next",
+ [88] = "media-previous",
+ [89] = "media-rewind",
[92] = "prior",
[93] = "next",
};