From 7921811726b878c21df99208cbfcfdb9634378b9 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 28 Nov 2019 00:35:53 +0200 Subject: [PATCH] Menu bar rearrangements, move Print menu items to submenu, etc. (bug#37594) * lisp/menu-bar.el (menu-bar-print-menu): New defvar. (menu-bar-file-menu): Move print entries to submenu. Add menu entries for tab-new, tab-close, make-frame-on-monitor. (menu-bar-showhide-menu): Add menu entry for global-tab-line-mode. Don't add toggle-tab-bar-mode-from-frame on ns where it's unavailable. (menu-bar-tools-menu): Add rgrep. * lisp/bindings.el (next-buffer, previous-buffer): Advertise bindings 'C-x right' and 'C-x left' instead of 'XF86Forward' and 'XF86Back'. --- etc/NEWS | 4 ++ lisp/bindings.el | 2 + lisp/menu-bar.el | 107 +++++++++++++++++++++++++++++++---------------- 3 files changed, 76 insertions(+), 37 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index f3f9f2f2c65..cb73e46358a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -508,6 +508,10 @@ RGB triplets with a single hexadecimal digit per component. --- ** The toolbar now shows the equivalent key binding in its tooltips. +--- +** The File menu-bar menu was re-arranged: Print menu items moved to +submenu, and also added the new entries for tabs. + --- ** 'scroll-lock-mode' is now bound to the 'Scroll_Lock' key globally. Note that this key binding will not work on MS-Windows systems if diff --git a/lisp/bindings.el b/lisp/bindings.el index 16da2bdf9a6..738928b478e 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -933,9 +933,11 @@ if `inhibit-field-text-motion' is non-nil." (define-key ctl-x-map [right] 'next-buffer) (define-key ctl-x-map [C-right] 'next-buffer) (define-key global-map [XF86Forward] 'next-buffer) +(put 'next-buffer :advertised-binding [?\C-x right]) (define-key ctl-x-map [left] 'previous-buffer) (define-key ctl-x-map [C-left] 'previous-buffer) (define-key global-map [XF86Back] 'previous-buffer) +(put 'previous-buffer :advertised-binding [?\C-x left]) (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index c404145dff4..b6e7d06aa64 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -49,6 +49,36 @@ ;; It gets modified in place when menu-bar-update-buffers is called. (defvar global-buffers-menu-map (make-sparse-keymap "Buffers")) +(defvar menu-bar-print-menu + (let ((menu (make-sparse-keymap "Print"))) + (bindings--define-key menu [ps-print-region] + '(menu-item "PostScript Print Region (B+W)" ps-print-region + :enable mark-active + :help "Pretty-print marked region in black and white to PostScript printer")) + (bindings--define-key menu [ps-print-buffer] + '(menu-item "PostScript Print Buffer (B+W)" ps-print-buffer + :enable (menu-bar-menu-frame-live-and-visible-p) + :help "Pretty-print current buffer in black and white to PostScript printer")) + (bindings--define-key menu [ps-print-region-faces] + '(menu-item "PostScript Print Region" + ps-print-region-with-faces + :enable mark-active + :help "Pretty-print marked region to PostScript printer")) + (bindings--define-key menu [ps-print-buffer-faces] + '(menu-item "PostScript Print Buffer" + ps-print-buffer-with-faces + :enable (menu-bar-menu-frame-live-and-visible-p) + :help "Pretty-print current buffer to PostScript printer")) + (bindings--define-key menu [print-region] + '(menu-item "Print Region" print-region + :enable mark-active + :help "Print region between mark and current position")) + (bindings--define-key menu [print-buffer] + '(menu-item "Print Buffer" print-buffer + :enable (menu-bar-menu-frame-live-and-visible-p) + :help "Print current buffer with page headings")) + menu)) + ;; Only declared obsolete (and only made a proper alias) in 23.3. (define-obsolete-variable-alias 'menu-bar-files-menu 'menu-bar-file-menu "22.1") @@ -63,6 +93,25 @@ (bindings--define-key menu [separator-exit] menu-bar-separator) + (bindings--define-key menu [print] + `(menu-item "Print" ,menu-bar-print-menu)) + + (bindings--define-key menu [separator-print] + menu-bar-separator) + + (unless (featurep 'ns) + (bindings--define-key menu [close-tab] + '(menu-item "Close Tab" tab-close + :visible (fboundp 'tab-close) + :help "Close currently selected tab")) + (bindings--define-key menu [make-tab] + '(menu-item "New Tab" tab-new + :visible (fboundp 'tab-new) + :help "Open a new tab")) + + (bindings--define-key menu [separator-tab] + menu-bar-separator)) + ;; Don't use delete-frame as event name because that is a special ;; event. (bindings--define-key menu [delete-this-frame] @@ -70,6 +119,10 @@ :visible (fboundp 'delete-frame) :enable (delete-frame-enabled-p) :help "Delete currently selected frame")) + (bindings--define-key menu [make-frame-on-monitor] + '(menu-item "New Frame on Monitor..." make-frame-on-monitor + :visible (fboundp 'make-frame-on-monitor) + :help "Open a new frame on another monitor")) (bindings--define-key menu [make-frame-on-display] '(menu-item "New Frame on Display..." make-frame-on-display :visible (fboundp 'make-frame-on-display) @@ -102,36 +155,6 @@ (bindings--define-key menu [separator-window] menu-bar-separator) - (bindings--define-key menu [ps-print-region] - '(menu-item "PostScript Print Region (B+W)" ps-print-region - :enable mark-active - :help "Pretty-print marked region in black and white to PostScript printer")) - (bindings--define-key menu [ps-print-buffer] - '(menu-item "PostScript Print Buffer (B+W)" ps-print-buffer - :enable (menu-bar-menu-frame-live-and-visible-p) - :help "Pretty-print current buffer in black and white to PostScript printer")) - (bindings--define-key menu [ps-print-region-faces] - '(menu-item "PostScript Print Region" - ps-print-region-with-faces - :enable mark-active - :help "Pretty-print marked region to PostScript printer")) - (bindings--define-key menu [ps-print-buffer-faces] - '(menu-item "PostScript Print Buffer" - ps-print-buffer-with-faces - :enable (menu-bar-menu-frame-live-and-visible-p) - :help "Pretty-print current buffer to PostScript printer")) - (bindings--define-key menu [print-region] - '(menu-item "Print Region" print-region - :enable mark-active - :help "Print region between mark and current position")) - (bindings--define-key menu [print-buffer] - '(menu-item "Print Buffer" print-buffer - :enable (menu-bar-menu-frame-live-and-visible-p) - :help "Print current buffer with page headings")) - - (bindings--define-key menu [separator-print] - menu-bar-separator) - (bindings--define-key menu [recover-session] '(menu-item "Recover Crashed Session" recover-session :enable @@ -1228,6 +1251,12 @@ mail status in mode line")) (frame-visible-p (symbol-value 'speedbar-frame)))))) + (bindings--define-key menu [showhide-tab-line-mode] + '(menu-item "Window Tab Line" global-tab-line-mode + :help "Turn window-local tab-lines on/off" + :visible (fboundp 'global-tab-line-mode) + :button (:toggle . global-tab-line-mode))) + (bindings--define-key menu [showhide-window-divider] `(menu-item "Window Divider" ,menu-bar-showhide-window-divider-menu :visible (memq (window-system) '(x w32)))) @@ -1254,13 +1283,14 @@ mail status in mode line")) (frame-parameter (menu-bar-frame-for-menubar) 'menu-bar-lines))))) - (bindings--define-key menu [showhide-tab-bar] - '(menu-item "Tab Bar" toggle-tab-bar-mode-from-frame - :help "Turn tab bar on/off" - :button - (:toggle . (menu-bar-positive-p - (frame-parameter (menu-bar-frame-for-menubar) - 'tab-bar-lines))))) + (unless (featurep 'ns) + (bindings--define-key menu [showhide-tab-bar] + '(menu-item "Tab Bar" toggle-tab-bar-mode-from-frame + :help "Turn tab bar on/off" + :button + (:toggle . (menu-bar-positive-p + (frame-parameter (menu-bar-frame-for-menubar) + 'tab-bar-lines)))))) (if (and (boundp 'menu-bar-showhide-tool-bar-menu) (keymapp menu-bar-showhide-tool-bar-menu)) @@ -1720,6 +1750,9 @@ mail status in mode line")) (bindings--define-key menu [compile] '(menu-item "Compile..." compile :help "Invoke compiler or Make, view compilation errors")) + (bindings--define-key menu [rgrep] + '(menu-item "Recursive Grep..." rgrep + :help "Interactively ask for parameters and search recursively")) (bindings--define-key menu [grep] '(menu-item "Search Files (Grep)..." grep :help "Search files for strings or regexps (with Grep)")) -- 2.39.5