(vc-diff): Make NOT-URGENT default to t.
[bpt/emacs.git] / lisp / menu-bar.el
index a49370f..29047d1 100644 (file)
@@ -1,10 +1,10 @@
 ;;; menu-bar.el --- define a default menu bar.
 
+;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+
 ;; Author: RMS
 ;; Keywords: internal
 
-;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Avishai Yacobi suggested some menu rearrangements.
 
 ;;; Code:
 
+;;; User options:
+
+(defvar buffers-menu-max-size 10
+  "*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.")
+
 ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key
 ;; definitions made in loaddefs.el.
 (or (lookup-key global-map [menu-bar])
 (defvar menu-bar-help-menu (make-sparse-keymap "Help"))
 
 ;; Force Help item to come last, after the major mode's own items.
-(setq menu-bar-final-items '(help))
+;; The symbol used to be called `help', but that gets confused with the
+;; help key.
+(setq menu-bar-final-items '(help-menu))
 
-(define-key global-map [menu-bar help] (cons "Help" menu-bar-help-menu))
+(define-key global-map [menu-bar help-menu] (cons "Help" menu-bar-help-menu))
 (defvar menu-bar-search-menu (make-sparse-keymap "Search"))
 (define-key global-map [menu-bar search] (cons "Search" menu-bar-search-menu))
 (defvar menu-bar-edit-menu (make-sparse-keymap "Edit"))
@@ -54,7 +67,7 @@
 (define-key menu-bar-tools-menu [separator-vc]
   '("--"))
 
-(define-key menu-bar-tools-menu [vc-menu]
+(define-key menu-bar-tools-menu [vc]
   (cons "Version Control" vc-menu-map))
 
 (define-key menu-bar-tools-menu [separator-compare]
 
 (if (fboundp 'delete-frame)
     (progn
-      (define-key menu-bar-files-menu [delete-frame]
+      ;; Don't use delete-frame as event name
+      ;; because that is a special event.
+      (define-key menu-bar-files-menu [delete-this-frame]
        '("Delete Frame" . delete-frame))
       (define-key menu-bar-files-menu [make-frame-on-display]
        '("Open New Display..." . make-frame-on-display))
 (define-key menu-bar-files-menu [dired] '("Open Directory..." . dired))
 (define-key menu-bar-files-menu [open-file] '("Open File..." . find-file))
 
-;; This is just one element of the ediff menu--the first.
-(define-key menu-bar-ediff-menu [window]
-  '("This Window And Next Window" . compare-windows))
 \f
 (defun nonincremental-search-forward (string)
   "Read a string and search for it nonincrementally."
   '("Query Replace..." . query-replace))
 (define-key menu-bar-search-menu [find-tag]
   '("Find Tag..." . find-tag))
-(put 'find-tag 'menu-enable 'tags-table-list)
 (define-key menu-bar-search-menu [bookmark]
   '("Bookmarks" . menu-bar-bookmark-map))
 
 (define-key menu-bar-search-menu [separator-search]
   '("--"))
 
-(define-key menu-bar-search-menu [nonincremental-repeat-re-search-back]
+(define-key menu-bar-search-menu [repeat-regexp-back]
   '("Repeat Regexp Backwards" . nonincremental-repeat-re-search-backward))
-(define-key menu-bar-search-menu [nonincremental-repeat-search-back]
+(define-key menu-bar-search-menu [repeat-search-back]
   '("Repeat Backwards" . nonincremental-repeat-search-backward))
-(define-key menu-bar-search-menu [nonincremental-repeat-re-search-fwd]
+(define-key menu-bar-search-menu [repeat-regexp-fwd]
   '("Repeat Regexp" . nonincremental-repeat-re-search-forward))
-(define-key menu-bar-search-menu [nonincremental-repeat-search-fwd]
+(define-key menu-bar-search-menu [repeat-search-fwd]
   '("Repeat Search" . nonincremental-repeat-search-forward))
 
 (define-key menu-bar-search-menu [separator-repeat]
   '("--"))
 
-(define-key menu-bar-search-menu [re-search-back]
+(define-key menu-bar-search-menu [re-search-backward]
   '("Regexp Search Backwards..." . nonincremental-re-search-backward))
-(define-key menu-bar-search-menu [search-back]
+(define-key menu-bar-search-menu [search-backward]
   '("Search Backwards..." . nonincremental-search-backward))
-(define-key menu-bar-search-menu [re-search-fwd]
+(define-key menu-bar-search-menu [re-search-forward]
   '("Regexp Search..." . nonincremental-re-search-forward))
-(define-key menu-bar-search-menu [search-fwd]
+(define-key menu-bar-search-menu [search-forward]
   '("Search..." . nonincremental-search-forward))
 \f
 (if (fboundp 'start-process)
       (message "Select a region with the mouse does `copy' automatically")
     (kill-ring-save beg end)))
 
-(put 'fill-region 'menu-enable 'mark-active)
-(put 'kill-region 'menu-enable 'mark-active)
+(put 'fill-region 'menu-enable '(and mark-active (not buffer-read-only)))
+(put 'kill-region 'menu-enable '(and mark-active (not buffer-read-only)))
 (put 'menu-bar-kill-ring-save 'menu-enable 'mark-active)
-(put 'yank 'menu-enable '(x-selection-exists-p))
-(put 'yank-menu 'menu-enable '(cdr yank-menu))
+(put 'yank 'menu-enable '(and (x-selection-exists-p) (not buffer-read-only)))
+(put 'yank-menu 'menu-enable '(and (cdr yank-menu) (not buffer-read-only)))
 (put 'delete-region 'menu-enable '(and mark-active
+                                      (not buffer-read-only)
                                       (not (mouse-region-match))))
-(put 'undo 'menu-enable '(if (eq last-command 'undo)
-                            pending-undo-list
-                          (consp buffer-undo-list)))
+(put 'undo 'menu-enable '(and (not buffer-read-only)
+                             (if (eq last-command 'undo)
+                                 pending-undo-list
+                               (consp buffer-undo-list))))
 (put 'query-replace 'menu-enable '(not buffer-read-only))
+(put 'query-replace-regexp 'menu-enable '(not buffer-read-only))
 
 (autoload 'ispell-menu-map "ispell" nil t 'keymap)
 
@@ -297,10 +311,13 @@ Do the same for the keys of the same name."
 (define-key menu-bar-help-menu [emacs-version]
   '("Show Version" . emacs-version))
 (define-key menu-bar-help-menu [report-emacs-bug]
-  '("Send Bug Report" . report-emacs-bug))
+  '("Send Bug Report..." . report-emacs-bug))
+(define-key menu-bar-help-menu [finder-by-keyword]
+  '("Find Lisp Packages..." . finder-by-keyword))
 (define-key menu-bar-help-menu [emacs-tutorial]
   '("Emacs Tutorial" . help-with-tutorial))
-(define-key menu-bar-help-menu [man] '("Man..." . manual-entry))
+(define-key menu-bar-help-menu [man]
+  '("Man..." . manual-entry))
 (define-key menu-bar-help-menu [describe-variable]
   '("Describe Variable..." . describe-variable))
 (define-key menu-bar-help-menu [describe-function]
@@ -388,6 +405,10 @@ Do the same for the keys of the same name."
                        (substring string 0 (/ yank-menu-length 2))
                        "..."
                        (substring string (- (/ yank-menu-length 2)))))))
+    ;; Don't let the menu string be all dashes
+    ;; because that has a special meaning in a menu.
+    (if (string-match "\\`-+\\'" menu-string)
+       (setq menu-string (concat menu-string " ")))
     ;; If we're supposed to be extending an existing string, and that
     ;; string really is at the front of the menu, then update it in place.
     (if (and old (or (eq old (car front))
@@ -407,15 +428,10 @@ Do the same for the keys of the same name."
   (push-mark (point))
   (insert last-command-event))
 \f
-(define-key global-map [menu-bar buffer] '("Buffers" . menu-bar-buffers))
-
-(defalias 'menu-bar-buffers (make-sparse-keymap "Buffers"))
-
-(defvar buffers-menu-max-size 10
-  "*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.")
+;; This definition is just to show what this looks like.
+;; It gets overridden below when menu-bar-update-buffers is called.
+(define-key global-map [menu-bar buffer]
+  (cons "Buffers" (make-sparse-keymap "Buffers")))
 
 (defvar list-buffers-directory nil)
 
@@ -571,6 +587,8 @@ A large number or nil slows down menu responsiveness.")
 
 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
 
+(menu-bar-update-buffers)
+
 ;; this version is too slow
 ;;;(defun format-buffers-menu-line (buffer)
 ;;;  "Returns a string to represent the given buffer in the Buffer menu.
@@ -588,6 +606,46 @@ A large number or nil slows down menu responsiveness.")
 ;;;           mode-name
 ;;;           (or (buffer-file-name) ""))))))
 \f
+;;; Set up a menu bar menu for the minibuffer.
+
+(mapcar
+ (function
+  (lambda (map)
+    (define-key map [menu-bar minibuf]
+      (cons "Minibuf" (make-sparse-keymap "Minibuf")))))
+ (list minibuffer-local-ns-map
+       minibuffer-local-must-match-map
+       minibuffer-local-isearch-map
+       minibuffer-local-map
+       minibuffer-local-completion-map))
+
+(mapcar
+ (function
+  (lambda (map)
+    (define-key map [menu-bar minibuf ?\?]
+      '("List Completions" . minibuffer-completion-help))
+    (define-key map [menu-bar minibuf space]
+      '("Complete Word" . minibuffer-complete-word))
+    (define-key map [menu-bar minibuf tab]
+      '("Complete" . minibuffer-complete))
+    ))
+ (list minibuffer-local-must-match-map
+       minibuffer-local-completion-map))
+
+(mapcar
+ (function
+  (lambda (map)
+    (define-key map [menu-bar minibuf quit]
+      '("Quit" . keyboard-escape-quit))
+    (define-key map [menu-bar minibuf return]
+      '("Enter" . exit-minibuffer))
+    ))
+ (list minibuffer-local-ns-map
+       minibuffer-local-must-match-map
+       minibuffer-local-isearch-map
+       minibuffer-local-map
+       minibuffer-local-completion-map))
+\f
 (defvar menu-bar-mode nil)
 
 (defun menu-bar-mode (flag)