]> code.delx.au - gnu-emacs/blobdiff - lisp/menu-bar.el
* follow.el (follow-select-if-visible): Improve the check for the
[gnu-emacs] / lisp / menu-bar.el
index 0ba1a0b1717c6cb2e99affbf5985a53ade57f6f7..45cc71753aa051c0bb9fd594a8e7ebe49c9a6e35 100644 (file)
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;; Avishai Yacobi suggested some menu rearrangements.
 
@@ -67,6 +65,7 @@
 ;; The "File" menu items
 (define-key menu-bar-file-menu [exit-emacs]
   '(menu-item "Exit Emacs" save-buffers-kill-emacs
+             :keys "C-x C-c"
              :help "Save unsaved buffers, then exit"))
 
 (define-key menu-bar-file-menu [separator-exit]
 
 (define-key menu-bar-edit-menu [mark-whole-buffer]
   '(menu-item "Select All" mark-whole-buffer
-             :help "Mark the whole buffer for a subsequent cut/copy."))
+             :help "Mark the whole buffer for a subsequent cut/copy"))
 (define-key menu-bar-edit-menu [clear]
   '(menu-item "Clear" delete-region
              :enable (and mark-active
 (defvar yank-menu (cons "Select Yank" nil))
 (fset 'yank-menu (cons 'keymap yank-menu))
 (define-key menu-bar-edit-menu [paste-from-menu]
-  '(menu-item "Paste from kill menu" yank-menu
+  '(menu-item "Paste from Kill Menu" yank-menu
              :enable (and (cdr yank-menu) (not buffer-read-only))
              :help "Choose a string from the kill ring and paste it"))
 (define-key menu-bar-edit-menu [paste]
@@ -629,6 +628,22 @@ by \"Save Options\" in Custom buffers.")
                  :button (:toggle . (and (default-boundp ',variable)
                                         (default-value ',variable))))))
 
+;; Function for setting/saving default font.
+
+(defun menu-set-font ()
+  "Interactively select a font and make it the default."
+  (interactive)
+  (let ((font (if (fboundp 'x-select-font)
+                 (x-select-font)
+               (mouse-select-font)))
+       spec)
+    (when font
+      (set-face-attribute 'default nil :font font)
+      (setq spec (list (list t (face-attr-construct 'default))))
+      (put 'default 'customized-face spec)
+      (custom-push-theme 'theme-face 'default 'user 'set spec)
+      (put 'default 'face-modified nil))))
+
 ;;; Assemble all the top-level items of the "Options" menu
 (define-key menu-bar-options-menu [customize]
   (list 'menu-item "Customize Emacs" menu-bar-custom-menu))
@@ -662,6 +677,10 @@ by \"Save Options\" in Custom buffers.")
       (and (get elt 'customized-value)
           (customize-mark-to-save elt)
           (setq need-save t)))
+    (when (get 'default 'customized-face)
+      (put 'default 'saved-face (get 'default 'customized-face))
+      (put 'default 'customized-face nil)
+      (setq need-save t))
     ;; Save if we changed anything.
     (when need-save
       (custom-save-all))))
@@ -673,10 +692,10 @@ by \"Save Options\" in Custom buffers.")
 (define-key menu-bar-options-menu [custom-separator]
   '("--"))
 
-(define-key menu-bar-options-menu [mouse-set-font]
-  '(menu-item "Set Font/Fontset..." mouse-set-font
-              :visible (display-multi-font-p)
-              :help "Select a font from list of known fonts/fontsets"))
+(define-key menu-bar-options-menu [menu-set-font]
+  '(menu-item "Set Default Font..." menu-set-font
+             :visible (display-multi-font-p)
+             :help "Select a default font"))
 
 ;; The "Show/Hide" submenu of menu "Options"
 
@@ -932,7 +951,7 @@ mail status in mode line"))
 
 (define-key menu-bar-showhide-menu [showhide-tool-bar]
   (list 'menu-item "Tool-bar" 'toggle-tool-bar-mode-from-frame
-       :help "Toggle tool-bar on/off"
+       :help "Turn tool-bar on/off"
        :visible `(display-graphic-p)
        :button `(:toggle . (> (frame-parameter nil 'tool-bar-lines) 0))))
 
@@ -1018,7 +1037,7 @@ mail status in mode line"))
   (menu-bar-make-toggle toggle-case-fold-search case-fold-search
            "Case-Insensitive Search"
            "Case-Insensitive Search %s"
-           "Globally ignore letter-case in search"))
+           "Ignore letter-case in search commands"))
 
 (defun menu-bar-text-mode-auto-fill ()
   (interactive)
@@ -1029,23 +1048,58 @@ mail status in mode line"))
   (customize-mark-as-set 'text-mode-hook))
 
 (define-key menu-bar-options-menu [auto-fill-mode]
-  '(menu-item "Word Wrap in Text Modes"
+  '(menu-item "Auto Fill in Text Modes"
               menu-bar-text-mode-auto-fill
-             :help "Automatically fill text between left and right margins (Auto Fill)"
+             :help "Automatically fill text while typing (Auto Fill mode)"
               :button (:toggle . (if (listp text-mode-hook)
                                     (member 'turn-on-auto-fill text-mode-hook)
                                   (eq 'turn-on-auto-fill text-mode-hook)))))
-(define-key menu-bar-options-menu [truncate-lines]
-  '(menu-item "Truncate Long Lines in this Buffer"
-             toggle-truncate-lines
-             :help "Truncate long lines on the screen"
-             :button (:toggle . (if (or (window-full-width-p)
-                                        (not truncate-partial-width-windows))
-                                    truncate-lines
-                                  truncate-partial-width-windows))
-             :enable (and (menu-bar-menu-frame-live-and-visible-p)
-                          (or (window-full-width-p)
-                              (not truncate-partial-width-windows)))))
+
+
+(defvar menu-bar-line-wrapping-menu (make-sparse-keymap "Line Wrapping"))
+
+(define-key menu-bar-line-wrapping-menu [word-wrap]
+  '(menu-item "Word Wrap (Visual Line mode)"
+             (lambda ()
+               (interactive)
+               (unless visual-line-mode
+                 (visual-line-mode 1))
+               (message "Visual-Line mode enabled"))
+             :help "Wrap long lines at word boundaries"
+             :button (:radio . (and (null truncate-lines)
+                                    (not (truncated-partial-width-window-p))
+                                    word-wrap))
+             :visible (menu-bar-menu-frame-live-and-visible-p)))
+
+(define-key menu-bar-line-wrapping-menu [truncate]
+  '(menu-item "Truncate Long Lines"
+             (lambda ()
+               (interactive)
+               (if visual-line-mode (visual-line-mode 0))
+               (setq word-wrap nil)
+               (toggle-truncate-lines 1))
+             :help "Truncate long lines at window edge"
+             :button (:radio . (or truncate-lines
+                                   (truncated-partial-width-window-p)))
+             :visible (menu-bar-menu-frame-live-and-visible-p)
+             :enable (not (truncated-partial-width-window-p))))
+
+(define-key menu-bar-line-wrapping-menu [window-wrap]
+  '(menu-item "Wrap at Window Edge"
+             (lambda () (interactive)
+               (if visual-line-mode (visual-line-mode 0))
+               (setq word-wrap nil)
+               (if truncate-lines (toggle-truncate-lines -1)))
+             :help "Wrap long lines at window edge"
+             :button (:radio . (and (null truncate-lines)
+                                    (not (truncated-partial-width-window-p))
+                                    (not word-wrap)))
+             :visible (menu-bar-menu-frame-live-and-visible-p)
+             :enable (not (truncated-partial-width-window-p))))
+
+(define-key menu-bar-options-menu [line-wrapping]
+  (list 'menu-item "Line Wrapping in this Buffer" menu-bar-line-wrapping-menu))
+
 
 (define-key menu-bar-options-menu [highlight-separator]
   '("--"))
@@ -1308,7 +1362,7 @@ mail status in mode line"))
 
 (define-key menu-bar-describe-menu [list-keybindings]
   '(menu-item "List Key Bindings" describe-bindings
-             :help "Display all current keybindings (keyboard shortcuts)"))
+             :help "Display all current key bindings (keyboard shortcuts)"))
 (define-key menu-bar-describe-menu [describe-current-display-table]
   '(menu-item "Describe Display Table" describe-current-display-table
              :help "Describe the current display table"))
@@ -1404,7 +1458,7 @@ key, a click, or a menu-item"))
   '(menu-item "Ordering Manuals" view-order-manuals
              :help "How to order manuals from the Free Software Foundation"))
 (define-key menu-bar-manuals-menu [lookup-subject-in-all-manuals]
-  '(menu-item "Lookup Subject in all manuals..." info-apropos
+  '(menu-item "Lookup Subject in all Manuals..." info-apropos
              :help "Find description of a subject in all installed manuals"))
 (define-key menu-bar-manuals-menu [other-manuals]
   '(menu-item "All Other Manuals (Info)" Info-directory
@@ -1432,7 +1486,7 @@ key, a click, or a menu-item"))
              :help "Show the Emacs license (GPL)"))
 (define-key menu-bar-help-menu [getting-new-versions]
   '(menu-item "Getting New Versions" describe-distribution
-             :help "How to get latest versions of Emacs"))
+             :help "How to get the latest version of Emacs"))
 (defun menu-bar-help-extra-packages ()
   "Display help about some additional packages available for Emacs."
   (interactive)
@@ -1536,7 +1590,7 @@ using `abort-recursive-edit'."
     (> count 1)))
 
 (defcustom yank-menu-length 20
-  "*Maximum length to display in the yank-menu."
+  "Maximum length to display in the yank-menu."
   :type 'integer
   :group 'menu)
 
@@ -1578,7 +1632,7 @@ The menu shows all the killed text sequences stored in `kill-ring'."
 ;;; Buffers Menu
 
 (defcustom buffers-menu-max-size 10
-  "*Maximum number of entries which may appear on the Buffers menu.
+  "Maximum number of entries which may appear on the Buffers menu.
 If this is 10, then only the ten most-recently-selected buffers are shown.
 If this is nil, then all buffers are shown.
 A large number or nil slows down menu responsiveness."
@@ -1587,7 +1641,7 @@ A large number or nil slows down menu responsiveness."
   :group 'menu)
 
 (defcustom buffers-menu-buffer-name-length 30
-  "*Maximum length of the buffer name on the Buffers menu.
+  "Maximum length of the buffer name on the Buffers menu.
 If this is a number, then buffer names are truncated to this length.
 If this is nil, then buffer names are shown in full.
 A large number or nil makes the menu too wide."
@@ -1626,6 +1680,10 @@ Buffers menu is regenerated."
 
 (defvar list-buffers-directory nil)
 
+(defun menu-bar-select-buffer ()
+  (interactive)
+  (switch-to-buffer last-command-event))
+
 (defun menu-bar-select-frame (frame)
   (make-frame-visible frame)
   (raise-frame frame)
@@ -1867,20 +1925,24 @@ See `menu-bar-mode' for more information."
     (menu-bar-mode arg)))
 
 (declare-function x-menu-bar-open "term/x-win" (&optional frame))
+(declare-function w32-menu-bar-open "term/w32-win" (&optional frame))
 
 (defun menu-bar-open (&optional frame)
   "Start key navigation of the menu bar in FRAME.
 
 This function decides which method to use to access the menu
 depending on FRAME's terminal device.  On X displays, it calls
-`x-menu-bar-open'; otherwise it calls `tmm-menubar'.
+`x-menu-bar-open'; on Windows, `w32-menu-bar-open' otherwise it
+calls `tmm-menubar'.
 
 If FRAME is nil or not given, use the selected frame."
   (interactive)
-  (if (eq window-system 'x)
-      (x-menu-bar-open frame)
-    (with-selected-frame (or frame (selected-frame))
-      (tmm-menubar))))
+  (let ((type (framep (or frame (selected-frame)))))
+    (cond
+     ((eq type 'x) (x-menu-bar-open frame))
+     ((eq type 'w32) (w32-menu-bar-open frame))
+     (t (with-selected-frame (or frame (selected-frame))
+          (tmm-menubar))))))
 
 (global-set-key [f10] 'menu-bar-open)