]> code.delx.au - gnu-emacs/blobdiff - lisp/menu-bar.el
(mouse-show-mark): Use temporary highlighting if possible instead of a pause.
[gnu-emacs] / lisp / menu-bar.el
index 56903cd6c27680a42bfe4e00d6c64cf52f2159d7..29047d18a1ca7a5abea846d9bffeca3dbc7c13d4 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])
@@ -58,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."
 (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)
@@ -397,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))
@@ -416,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)
 
@@ -580,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.
@@ -618,7 +627,7 @@ A large number or nil slows down menu responsiveness.")
     (define-key map [menu-bar minibuf space]
       '("Complete Word" . minibuffer-complete-word))
     (define-key map [menu-bar minibuf tab]
-      '("Complete" . 'minibuffer-complete))
+      '("Complete" . minibuffer-complete))
     ))
  (list minibuffer-local-must-match-map
        minibuffer-local-completion-map))