1993-04-08 16:17:43 +00:00
|
|
|
|
;;; menu-bar.el --- define a default menu bar.
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
|
|
|
|
1993-04-08 16:17:43 +00:00
|
|
|
|
;; Author: RMS
|
1997-05-27 15:32:03 +00:00
|
|
|
|
;; Maintainer: FSF
|
1993-11-23 20:12:25 +00:00
|
|
|
|
;; Keywords: internal
|
1993-04-08 16:17:43 +00:00
|
|
|
|
|
1993-04-08 07:10:13 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; 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 2, 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
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; 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.
|
1993-04-08 07:10:13 +00:00
|
|
|
|
|
1995-07-17 22:51:17 +00:00
|
|
|
|
;; Avishai Yacobi suggested some menu rearrangements.
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
1995-12-26 19:11:18 +00:00
|
|
|
|
;;; User options:
|
|
|
|
|
|
1997-05-05 15:06:25 +00:00
|
|
|
|
(defcustom buffers-menu-max-size 10
|
1995-12-26 19:11:18 +00:00
|
|
|
|
"*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.
|
1997-05-05 15:06:25 +00:00
|
|
|
|
A large number or nil slows down menu responsiveness."
|
|
|
|
|
:type '(choice integer
|
|
|
|
|
(const :tag "All" nil))
|
|
|
|
|
:group 'mouse)
|
1995-12-26 19:11:18 +00:00
|
|
|
|
|
1993-09-06 22:48:00 +00:00
|
|
|
|
;; 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])
|
|
|
|
|
(define-key global-map [menu-bar] (make-sparse-keymap "menu-bar")))
|
1993-06-05 19:13:03 +00:00
|
|
|
|
(defvar menu-bar-help-menu (make-sparse-keymap "Help"))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
|
|
|
|
|
;; Force Help item to come last, after the major mode's own items.
|
1995-06-13 03:29:47 +00:00
|
|
|
|
;; The symbol used to be called `help', but that gets confused with the
|
|
|
|
|
;; help key.
|
|
|
|
|
(setq menu-bar-final-items '(help-menu))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
|
1995-06-13 03:29:47 +00:00
|
|
|
|
(define-key global-map [menu-bar help-menu] (cons "Help" menu-bar-help-menu))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(defvar menu-bar-search-menu (make-sparse-keymap "Search"))
|
|
|
|
|
(define-key global-map [menu-bar search] (cons "Search" menu-bar-search-menu))
|
1993-06-05 19:13:03 +00:00
|
|
|
|
(defvar menu-bar-edit-menu (make-sparse-keymap "Edit"))
|
1993-03-15 02:00:20 +00:00
|
|
|
|
(define-key global-map [menu-bar edit] (cons "Edit" menu-bar-edit-menu))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(defvar menu-bar-tools-menu (make-sparse-keymap "Tools"))
|
|
|
|
|
(define-key global-map [menu-bar tools] (cons "Tools" menu-bar-tools-menu))
|
|
|
|
|
(defvar menu-bar-files-menu (make-sparse-keymap "Files"))
|
|
|
|
|
(define-key global-map [menu-bar files] (cons "Files" menu-bar-files-menu))
|
1995-04-08 05:01:03 +00:00
|
|
|
|
|
|
|
|
|
;; This alias is for compatibility with 19.28 and before.
|
|
|
|
|
(defvar menu-bar-file-menu menu-bar-files-menu)
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
1994-09-21 20:48:00 +00:00
|
|
|
|
(defvar vc-menu-map (make-sparse-keymap "Version Control"))
|
|
|
|
|
|
1996-12-14 22:23:58 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [gdb] '("Debugger..." . gdb))
|
|
|
|
|
(define-key menu-bar-tools-menu [compile] '("Compile..." . compile))
|
|
|
|
|
(define-key menu-bar-tools-menu [grep] '("Search Files..." . grep))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-tools-menu [separator-1]
|
|
|
|
|
'("--"))
|
|
|
|
|
|
1995-04-02 05:46:12 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [calendar] '("Display Calendar" . calendar))
|
1998-10-05 09:21:03 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [speedbar]
|
|
|
|
|
'("Display Speedbar" . speedbar-frame-mode))
|
1997-02-27 00:11:29 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [compose-mail] '("Send Mail" . compose-mail))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [rmail] '("Read Mail" . rmail))
|
1995-11-10 17:18:23 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [gnus] '("Read Net News" . gnus))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
|
|
|
|
|
(define-key menu-bar-tools-menu [separator-vc]
|
|
|
|
|
'("--"))
|
|
|
|
|
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [vc]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(cons "Version Control" vc-menu-map))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [separator-compare]
|
1994-06-22 20:37:41 +00:00
|
|
|
|
'("--"))
|
|
|
|
|
|
1997-06-18 00:26:54 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [ediff-misc]
|
|
|
|
|
'("Ediff Miscellanea" . menu-bar-ediff-misc-menu))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [epatch]
|
1994-05-09 20:46:58 +00:00
|
|
|
|
'("Apply Patch" . menu-bar-epatch-menu))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [ediff-merge]
|
1995-03-16 23:04:55 +00:00
|
|
|
|
'("Merge" . menu-bar-ediff-merge-menu))
|
1995-05-08 15:22:30 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [compare]
|
1994-08-11 21:50:39 +00:00
|
|
|
|
'("Compare" . menu-bar-ediff-menu))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-tools-menu [separator-print]
|
1994-06-22 20:37:41 +00:00
|
|
|
|
'("--"))
|
|
|
|
|
|
1998-01-15 16:17:36 +00:00
|
|
|
|
(defvar menu-bar-print-menu (make-sparse-keymap "Print"))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
|
1998-01-15 16:17:36 +00:00
|
|
|
|
(define-key menu-bar-print-menu [ps-print-region]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Postscript Print Region" . ps-print-region-with-faces))
|
1998-01-15 16:17:36 +00:00
|
|
|
|
(define-key menu-bar-print-menu [ps-print-buffer]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Postscript Print Buffer" . ps-print-buffer-with-faces))
|
1998-01-15 16:17:36 +00:00
|
|
|
|
(define-key menu-bar-print-menu [separator-ps-print]
|
|
|
|
|
'("--"))
|
|
|
|
|
(define-key menu-bar-print-menu [print-region]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Print Region" . print-region))
|
1998-01-15 16:17:36 +00:00
|
|
|
|
(define-key menu-bar-print-menu [print-buffer]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Print Buffer" . print-buffer))
|
1998-01-15 16:17:36 +00:00
|
|
|
|
|
|
|
|
|
(define-key menu-bar-tools-menu [print]
|
|
|
|
|
(cons "Print" menu-bar-print-menu))
|
|
|
|
|
|
|
|
|
|
(put 'print-region 'menu-enable 'mark-active)
|
|
|
|
|
(put 'ps-print-region-with-faces 'menu-enable 'mark-active)
|
1995-03-19 21:11:13 +00:00
|
|
|
|
|
|
|
|
|
(define-key menu-bar-files-menu [exit-emacs]
|
|
|
|
|
'("Exit Emacs" . save-buffers-kill-emacs))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-files-menu [separator-exit]
|
|
|
|
|
'("--"))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-files-menu [one-window]
|
|
|
|
|
'("One Window" . delete-other-windows))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-files-menu [split-window]
|
|
|
|
|
'("Split Window" . split-window-vertically))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
1994-10-10 21:47:33 +00:00
|
|
|
|
(if (fboundp 'delete-frame)
|
|
|
|
|
(progn
|
1995-11-11 07:06:05 +00:00
|
|
|
|
;; Don't use delete-frame as event name
|
|
|
|
|
;; because that is a special event.
|
|
|
|
|
(define-key menu-bar-files-menu [delete-this-frame]
|
1994-10-10 21:47:33 +00:00
|
|
|
|
'("Delete Frame" . delete-frame))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-files-menu [make-frame-on-display]
|
|
|
|
|
'("Open New Display..." . make-frame-on-display))
|
|
|
|
|
(define-key menu-bar-files-menu [make-frame]
|
1997-07-05 21:33:06 +00:00
|
|
|
|
'("Make New Frame" . make-frame-command))))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-files-menu [separator-buffers]
|
1994-06-22 20:37:41 +00:00
|
|
|
|
'("--"))
|
|
|
|
|
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-files-menu [kill-buffer]
|
|
|
|
|
'("Kill Current Buffer" . kill-this-buffer))
|
|
|
|
|
(define-key menu-bar-files-menu [insert-file]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Insert File..." . insert-file))
|
1998-01-24 02:23:15 +00:00
|
|
|
|
(define-key menu-bar-files-menu [recover-session]
|
|
|
|
|
'("Recover Session..." . recover-session))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-files-menu [revert-buffer]
|
1993-03-15 01:05:11 +00:00
|
|
|
|
'("Revert Buffer" . revert-buffer))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-files-menu [write-file]
|
1993-03-15 01:05:11 +00:00
|
|
|
|
'("Save Buffer As..." . write-file))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-files-menu [save-buffer] '("Save Buffer" . save-buffer))
|
|
|
|
|
(define-key menu-bar-files-menu [dired] '("Open Directory..." . dired))
|
|
|
|
|
(define-key menu-bar-files-menu [open-file] '("Open File..." . find-file))
|
1994-08-11 21:50:39 +00:00
|
|
|
|
|
1998-01-24 02:23:15 +00:00
|
|
|
|
(put 'recover-session 'menu-enable
|
|
|
|
|
'(and auto-save-list-file-prefix
|
|
|
|
|
(directory-files
|
|
|
|
|
(file-name-directory auto-save-list-file-prefix)
|
|
|
|
|
nil
|
|
|
|
|
(concat "\\`"
|
|
|
|
|
(regexp-quote (file-name-nondirectory
|
|
|
|
|
auto-save-list-file-prefix)))
|
|
|
|
|
t)))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(defun nonincremental-search-forward (string)
|
|
|
|
|
"Read a string and search for it nonincrementally."
|
|
|
|
|
(interactive "sSearch for string: ")
|
|
|
|
|
(if (equal string "")
|
|
|
|
|
(search-forward (car search-ring))
|
|
|
|
|
(isearch-update-ring string nil)
|
|
|
|
|
(search-forward string)))
|
|
|
|
|
|
|
|
|
|
(defun nonincremental-search-backward (string)
|
|
|
|
|
"Read a string and search backward for it nonincrementally."
|
|
|
|
|
(interactive "sSearch for string: ")
|
|
|
|
|
(if (equal string "")
|
|
|
|
|
(search-backward (car search-ring))
|
|
|
|
|
(isearch-update-ring string nil)
|
|
|
|
|
(search-backward string)))
|
|
|
|
|
|
|
|
|
|
(defun nonincremental-re-search-forward (string)
|
|
|
|
|
"Read a regular expression and search for it nonincrementally."
|
|
|
|
|
(interactive "sSearch for regexp: ")
|
|
|
|
|
(if (equal string "")
|
|
|
|
|
(re-search-forward (car regexp-search-ring))
|
|
|
|
|
(isearch-update-ring string t)
|
|
|
|
|
(re-search-forward string)))
|
|
|
|
|
|
|
|
|
|
(defun nonincremental-re-search-backward (string)
|
|
|
|
|
"Read a regular expression and search backward for it nonincrementally."
|
|
|
|
|
(interactive "sSearch for regexp: ")
|
|
|
|
|
(if (equal string "")
|
|
|
|
|
(re-search-backward (car regexp-search-ring))
|
|
|
|
|
(isearch-update-ring string t)
|
|
|
|
|
(re-search-backward string)))
|
|
|
|
|
|
1995-04-24 15:26:19 +00:00
|
|
|
|
(defun nonincremental-repeat-search-forward ()
|
1995-03-19 21:11:13 +00:00
|
|
|
|
"Search forward for the previous search string."
|
|
|
|
|
(interactive)
|
1997-06-28 03:15:16 +00:00
|
|
|
|
(if (null search-ring)
|
|
|
|
|
(error "No previous search"))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(search-forward (car search-ring)))
|
|
|
|
|
|
1995-04-24 15:26:19 +00:00
|
|
|
|
(defun nonincremental-repeat-search-backward ()
|
1995-03-19 21:11:13 +00:00
|
|
|
|
"Search backward for the previous search string."
|
|
|
|
|
(interactive)
|
1997-06-28 03:15:16 +00:00
|
|
|
|
(if (null search-ring)
|
|
|
|
|
(error "No previous search"))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(search-backward (car search-ring)))
|
|
|
|
|
|
1995-04-24 15:26:19 +00:00
|
|
|
|
(defun nonincremental-repeat-re-search-forward ()
|
1995-03-19 21:11:13 +00:00
|
|
|
|
"Search forward for the previous regular expression."
|
|
|
|
|
(interactive)
|
1997-06-28 03:17:03 +00:00
|
|
|
|
(if (null regexp-search-ring)
|
1997-06-28 03:15:16 +00:00
|
|
|
|
(error "No previous search"))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(re-search-forward (car regexp-search-ring)))
|
|
|
|
|
|
1995-04-24 15:26:19 +00:00
|
|
|
|
(defun nonincremental-repeat-re-search-backward ()
|
1995-03-19 21:11:13 +00:00
|
|
|
|
"Search backward for the previous regular expression."
|
|
|
|
|
(interactive)
|
1997-06-28 03:17:03 +00:00
|
|
|
|
(if (null regexp-search-ring)
|
1997-06-28 03:15:16 +00:00
|
|
|
|
(error "No previous search"))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(re-search-backward (car regexp-search-ring)))
|
|
|
|
|
|
1995-04-24 15:26:19 +00:00
|
|
|
|
(define-key menu-bar-search-menu [query-replace-regexp]
|
|
|
|
|
'("Query Replace Regexp..." . query-replace-regexp))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-search-menu [query-replace]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Query Replace..." . query-replace))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-search-menu [find-tag]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Find Tag..." . find-tag))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
(define-key menu-bar-search-menu [bookmark]
|
|
|
|
|
'("Bookmarks" . menu-bar-bookmark-map))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-search-menu [separator-search]
|
|
|
|
|
'("--"))
|
|
|
|
|
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [repeat-regexp-back]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Repeat Regexp Backwards" . nonincremental-repeat-re-search-backward))
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [repeat-search-back]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Repeat Backwards" . nonincremental-repeat-search-backward))
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [repeat-regexp-fwd]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Repeat Regexp" . nonincremental-repeat-re-search-forward))
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [repeat-search-fwd]
|
1995-03-19 21:11:13 +00:00
|
|
|
|
'("Repeat Search" . nonincremental-repeat-search-forward))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-search-menu [separator-repeat]
|
1994-06-22 20:37:41 +00:00
|
|
|
|
'("--"))
|
|
|
|
|
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [re-search-backward]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Regexp Search Backwards..." . nonincremental-re-search-backward))
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [search-backward]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Search Backwards..." . nonincremental-search-backward))
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [re-search-forward]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Regexp Search..." . nonincremental-re-search-forward))
|
1996-01-24 23:29:01 +00:00
|
|
|
|
(define-key menu-bar-search-menu [search-forward]
|
1995-04-24 15:26:19 +00:00
|
|
|
|
'("Search..." . nonincremental-search-forward))
|
1995-03-19 21:11:13 +00:00
|
|
|
|
|
1995-04-08 20:40:33 +00:00
|
|
|
|
(if (fboundp 'start-process)
|
|
|
|
|
(define-key menu-bar-edit-menu [spell] '("Spell" . ispell-menu-map)))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
(define-key menu-bar-edit-menu [fill] '("Fill" . fill-region))
|
1995-03-25 16:02:43 +00:00
|
|
|
|
(define-key menu-bar-edit-menu [props] '("Text Properties" . facemenu-menu))
|
1994-06-22 20:37:41 +00:00
|
|
|
|
|
|
|
|
|
(define-key menu-bar-edit-menu [separator-edit]
|
|
|
|
|
'("--"))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-edit-menu [clear] '("Clear" . delete-region))
|
1994-09-15 22:16:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar yank-menu (cons "Select Yank" nil))
|
|
|
|
|
(fset 'yank-menu (cons 'keymap yank-menu))
|
|
|
|
|
(define-key menu-bar-edit-menu [select-paste] '("Select and Paste" . yank-menu))
|
1998-06-30 17:15:32 +00:00
|
|
|
|
(define-key menu-bar-edit-menu [paste] '("Paste" . yank))
|
1995-02-12 04:54:34 +00:00
|
|
|
|
(define-key menu-bar-edit-menu [copy] '("Copy" . menu-bar-kill-ring-save))
|
1993-05-17 04:45:03 +00:00
|
|
|
|
(define-key menu-bar-edit-menu [cut] '("Cut" . kill-region))
|
|
|
|
|
(define-key menu-bar-edit-menu [undo] '("Undo" . undo))
|
|
|
|
|
|
1995-02-12 04:54:34 +00:00
|
|
|
|
(defun menu-bar-kill-ring-save (beg end)
|
|
|
|
|
(interactive "r")
|
|
|
|
|
(if (mouse-region-match)
|
1998-07-02 06:52:52 +00:00
|
|
|
|
(message "Selecting a region with the mouse does `copy' automatically")
|
1995-02-12 04:54:34 +00:00
|
|
|
|
(kill-ring-save beg end)))
|
|
|
|
|
|
1995-06-29 03:11:37 +00:00
|
|
|
|
(put 'fill-region 'menu-enable '(and mark-active (not buffer-read-only)))
|
|
|
|
|
(put 'kill-region 'menu-enable '(and mark-active (not buffer-read-only)))
|
1995-02-12 04:54:34 +00:00
|
|
|
|
(put 'menu-bar-kill-ring-save 'menu-enable 'mark-active)
|
1995-06-29 03:11:37 +00:00
|
|
|
|
(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)))
|
1995-02-12 04:54:34 +00:00
|
|
|
|
(put 'delete-region 'menu-enable '(and mark-active
|
1995-06-29 03:11:37 +00:00
|
|
|
|
(not buffer-read-only)
|
1995-02-12 04:54:34 +00:00
|
|
|
|
(not (mouse-region-match))))
|
1995-06-29 03:11:37 +00:00
|
|
|
|
(put 'undo 'menu-enable '(and (not buffer-read-only)
|
|
|
|
|
(if (eq last-command 'undo)
|
|
|
|
|
pending-undo-list
|
|
|
|
|
(consp buffer-undo-list))))
|
1994-10-06 20:56:24 +00:00
|
|
|
|
(put 'query-replace 'menu-enable '(not buffer-read-only))
|
1995-06-29 03:11:37 +00:00
|
|
|
|
(put 'query-replace-regexp 'menu-enable '(not buffer-read-only))
|
1993-03-14 23:39:34 +00:00
|
|
|
|
|
1993-07-12 20:29:28 +00:00
|
|
|
|
(autoload 'ispell-menu-map "ispell" nil t 'keymap)
|
|
|
|
|
|
1994-04-06 04:54:35 +00:00
|
|
|
|
;; These are alternative definitions for the cut, paste and copy
|
1995-02-12 04:54:34 +00:00
|
|
|
|
;; menu items. Use them if your system expects these to use the clipboard.
|
1994-04-06 04:54:35 +00:00
|
|
|
|
|
|
|
|
|
(put 'clipboard-kill-region 'menu-enable 'mark-active)
|
|
|
|
|
(put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
|
|
|
|
|
(put 'clipboard-yank 'menu-enable
|
|
|
|
|
'(or (x-selection-exists-p) (x-selection-exists-p 'CLIPBOARD)))
|
|
|
|
|
|
|
|
|
|
(defun clipboard-yank ()
|
1999-01-03 02:05:10 +00:00
|
|
|
|
"Insert the clipboard contents, or the last stretch of killed text."
|
1994-04-06 04:54:35 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((x-select-enable-clipboard t))
|
|
|
|
|
(yank)))
|
|
|
|
|
|
|
|
|
|
(defun clipboard-kill-ring-save (beg end)
|
|
|
|
|
"Copy region to kill ring, and save in the X clipboard."
|
|
|
|
|
(interactive "r")
|
|
|
|
|
(let ((x-select-enable-clipboard t))
|
|
|
|
|
(kill-ring-save beg end)))
|
|
|
|
|
|
|
|
|
|
(defun clipboard-kill-region (beg end)
|
|
|
|
|
"Kill the region, and save it in the X clipboard."
|
|
|
|
|
(interactive "r")
|
|
|
|
|
(let ((x-select-enable-clipboard t))
|
|
|
|
|
(kill-region beg end)))
|
|
|
|
|
|
|
|
|
|
(defun menu-bar-enable-clipboard ()
|
1994-07-31 03:01:00 +00:00
|
|
|
|
"Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
|
|
|
|
|
Do the same for the keys of the same name."
|
1994-04-06 04:54:35 +00:00
|
|
|
|
(interactive)
|
1994-04-18 21:33:57 +00:00
|
|
|
|
;; We can't use constant list structure here because it becomes pure,
|
|
|
|
|
;; and because it gets modified with cache data.
|
|
|
|
|
(define-key menu-bar-edit-menu [paste]
|
|
|
|
|
(cons "Paste" 'clipboard-yank))
|
|
|
|
|
(define-key menu-bar-edit-menu [copy]
|
|
|
|
|
(cons "Copy" 'clipboard-kill-ring-save))
|
|
|
|
|
(define-key menu-bar-edit-menu [cut]
|
1994-07-31 03:01:00 +00:00
|
|
|
|
(cons "Cut" 'clipboard-kill-region))
|
|
|
|
|
|
|
|
|
|
(define-key global-map [f20] 'clipboard-kill-region)
|
|
|
|
|
(define-key global-map [f16] 'clipboard-kill-ring-save)
|
|
|
|
|
(define-key global-map [f18] 'clipboard-yank)
|
|
|
|
|
;; X11R6 versions
|
|
|
|
|
(define-key global-map [cut] 'clipboard-kill-region)
|
|
|
|
|
(define-key global-map [copy] 'clipboard-kill-ring-save)
|
|
|
|
|
(define-key global-map [paste] 'clipboard-yank))
|
1994-04-06 04:54:35 +00:00
|
|
|
|
|
1997-04-08 22:20:30 +00:00
|
|
|
|
|
|
|
|
|
;;; Menu support
|
|
|
|
|
|
|
|
|
|
(defvar menu-bar-custom-menu (make-sparse-keymap "Customize"))
|
|
|
|
|
|
1997-07-09 19:03:09 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-apropos-groups]
|
|
|
|
|
'("Apropos Groups..." . customize-apropos-groups))
|
|
|
|
|
(define-key menu-bar-custom-menu [customize-apropos-faces]
|
|
|
|
|
'("Apropos Faces..." . customize-apropos-faces))
|
|
|
|
|
(define-key menu-bar-custom-menu [customize-apropos-options]
|
|
|
|
|
'("Apropos Options..." . customize-apropos-options))
|
1997-04-08 22:20:30 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-apropos]
|
|
|
|
|
'("Apropos..." . customize-apropos))
|
1997-07-09 19:03:09 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [separator-2]
|
|
|
|
|
'("--"))
|
1997-05-01 22:21:19 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-group]
|
|
|
|
|
'("Specific Group..." . customize-group))
|
1997-04-08 22:20:30 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-face]
|
1997-05-01 22:21:19 +00:00
|
|
|
|
'("Specific Face..." . customize-face))
|
1997-07-09 19:03:09 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-option]
|
|
|
|
|
'("Specific Option..." . customize-option))
|
1998-05-03 00:53:50 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-changed-options]
|
|
|
|
|
'("Changed Options..." . customize-changed-options))
|
1997-07-09 19:03:09 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [separator-3]
|
|
|
|
|
'("--"))
|
1997-07-04 13:25:17 +00:00
|
|
|
|
(define-key menu-bar-custom-menu [customize-browse]
|
1997-07-09 19:03:09 +00:00
|
|
|
|
'("Browse Customization Groups" . customize-browse))
|
|
|
|
|
(define-key menu-bar-custom-menu [customize]
|
|
|
|
|
'("Top-level Customization Group" . customize))
|
1997-04-08 22:20:30 +00:00
|
|
|
|
|
1997-08-29 02:12:38 +00:00
|
|
|
|
;; Options menu
|
1997-09-03 20:52:13 +00:00
|
|
|
|
(defvar menu-bar-options-menu (make-sparse-keymap "Global Options"))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
|
|
|
|
|
(defmacro menu-bar-make-toggle (name variable doc message &rest body)
|
|
|
|
|
`(progn
|
|
|
|
|
(defun ,name ()
|
|
|
|
|
,(concat doc ".")
|
|
|
|
|
(interactive)
|
|
|
|
|
(if ,(if body `(progn . ,body)
|
|
|
|
|
`(setq ,variable (not ,variable)))
|
|
|
|
|
(message ,message "enabled")
|
|
|
|
|
(message ,message "disabled")))
|
1998-03-28 05:43:01 +00:00
|
|
|
|
'(menu-item ,doc ,name .
|
|
|
|
|
(:button (:toggle . (and (boundp ',variable) ,variable))))))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
|
|
|
|
|
(define-key menu-bar-options-menu [debug-on-quit]
|
|
|
|
|
(menu-bar-make-toggle toggle-debug-on-quit debug-on-quit
|
1998-03-28 05:43:01 +00:00
|
|
|
|
"Debug on Quit" "Debug on Quit %s"))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
(define-key menu-bar-options-menu [debug-on-error]
|
|
|
|
|
(menu-bar-make-toggle toggle-debug-on-error debug-on-error
|
1998-03-28 05:43:01 +00:00
|
|
|
|
"Debug on Error" "Debug on Error %s"))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
(define-key menu-bar-options-menu [options-separator]
|
|
|
|
|
'("--"))
|
|
|
|
|
(define-key menu-bar-options-menu [save-place]
|
|
|
|
|
(menu-bar-make-toggle toggle-save-place-globally save-place
|
1998-03-28 05:43:01 +00:00
|
|
|
|
"Save Place in Files between Sessions"
|
1997-08-29 02:12:38 +00:00
|
|
|
|
"Saving place in files %s"
|
1998-03-28 05:43:01 +00:00
|
|
|
|
(require 'saveplace)
|
1997-08-29 02:12:38 +00:00
|
|
|
|
(setq-default save-place (not (default-value save-place)))))
|
|
|
|
|
(define-key menu-bar-options-menu [uniquify]
|
|
|
|
|
(menu-bar-make-toggle toggle-uniquify-buffer-names uniquify-buffer-name-style
|
1998-03-28 05:43:01 +00:00
|
|
|
|
"Use Directory Names in Buffer Names"
|
1997-08-29 02:12:38 +00:00
|
|
|
|
"Directory name in buffer names (uniquify) %s"
|
|
|
|
|
(require 'uniquify)
|
|
|
|
|
(setq uniquify-buffer-name-style
|
|
|
|
|
(if (not uniquify-buffer-name-style)
|
|
|
|
|
'forward))))
|
1998-05-24 01:00:03 +00:00
|
|
|
|
(define-key menu-bar-options-menu [case-fold-search]
|
|
|
|
|
(menu-bar-make-toggle toggle-case-fold-search case-fold-search
|
|
|
|
|
"Case folding in searches"
|
|
|
|
|
"Case folding in searches %s"))
|
1998-10-21 20:24:41 +00:00
|
|
|
|
(define-key menu-bar-options-menu [truncate-lines]
|
|
|
|
|
(menu-bar-make-toggle
|
|
|
|
|
toggle-truncate-lines truncate-lines
|
|
|
|
|
"Line Truncation" "Line Truncation %s"
|
|
|
|
|
(prog1 (setq truncate-lines (not truncate-lines))
|
|
|
|
|
(set-buffer-modified-p (buffer-modified-p)))))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
(define-key menu-bar-options-menu [transient-mark-mode]
|
|
|
|
|
(menu-bar-make-toggle toggle-transient-mark-mode transient-mark-mode
|
1998-03-28 05:43:01 +00:00
|
|
|
|
"Transient Mark Mode (highlights region)"
|
1997-08-29 02:12:38 +00:00
|
|
|
|
"Transient Mark mode %s"))
|
|
|
|
|
(define-key menu-bar-options-menu [toggle-auto-compression]
|
1998-03-28 05:43:01 +00:00
|
|
|
|
'(menu-item "Automatic File De/compression"
|
|
|
|
|
auto-compression-mode .
|
|
|
|
|
(:button (:toggle . (rassq 'jka-compr-handler
|
|
|
|
|
file-name-handler-alist)))))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
(define-key menu-bar-options-menu [auto-fill-mode]
|
1998-03-28 05:43:01 +00:00
|
|
|
|
'(menu-item "Auto Fill (word wrap) in Text modes"
|
|
|
|
|
toggle-text-mode-auto-fill .
|
|
|
|
|
(:button (:toggle . (member 'turn-on-auto-fill text-mode-hook)))))
|
1997-09-07 04:43:10 +00:00
|
|
|
|
(define-key menu-bar-options-menu [toggle-global-lazy-font-lock-mode]
|
1998-03-28 05:43:01 +00:00
|
|
|
|
(menu-bar-make-toggle toggle-global-lazy-font-lock-mode global-font-lock-mode
|
|
|
|
|
"Global Font Lock (highlights syntax)"
|
1997-09-07 04:43:10 +00:00
|
|
|
|
"Global Font Lock mode %s"
|
|
|
|
|
;; Make sure a support mode is used;
|
|
|
|
|
;; otherwise Font Lock will be too slow.
|
1997-09-03 20:52:13 +00:00
|
|
|
|
(require 'font-lock)
|
1997-09-07 04:43:10 +00:00
|
|
|
|
(if (not global-font-lock-mode)
|
|
|
|
|
(or font-lock-support-mode
|
|
|
|
|
(setq font-lock-support-mode 'lazy-lock-mode)))
|
|
|
|
|
(global-font-lock-mode)))
|
1997-11-24 04:59:24 +00:00
|
|
|
|
|
|
|
|
|
(defvar menu-bar-describe-menu (make-sparse-keymap "Describe"))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-describe-menu [describe-variable]
|
|
|
|
|
'("Describe Variable..." . describe-variable))
|
|
|
|
|
(define-key menu-bar-describe-menu [describe-function]
|
|
|
|
|
'("Describe Function..." . describe-function))
|
|
|
|
|
(define-key menu-bar-describe-menu [describe-key]
|
|
|
|
|
'("Describe Key..." . describe-key))
|
|
|
|
|
(define-key menu-bar-describe-menu [list-keybindings]
|
|
|
|
|
'("List Key Bindings" . describe-bindings))
|
1997-11-24 20:16:20 +00:00
|
|
|
|
(define-key menu-bar-describe-menu [apropos-variables]
|
1997-11-24 04:59:24 +00:00
|
|
|
|
'("Apropos Variables..." . apropos-variable))
|
1997-11-24 20:16:20 +00:00
|
|
|
|
(define-key menu-bar-describe-menu [apropos-commands]
|
|
|
|
|
'("Apropos Commands..." . apropos-command))
|
1997-11-24 04:59:24 +00:00
|
|
|
|
(define-key menu-bar-describe-menu [describe-mode]
|
|
|
|
|
'("Describe Buffer Modes" . describe-mode))
|
|
|
|
|
|
|
|
|
|
(defvar menu-bar-manuals-menu (make-sparse-keymap "Manuals"))
|
|
|
|
|
|
|
|
|
|
(define-key menu-bar-manuals-menu [man]
|
|
|
|
|
'("Read Man Page..." . manual-entry))
|
|
|
|
|
(define-key menu-bar-manuals-menu [sep2]
|
|
|
|
|
'("--"))
|
|
|
|
|
(define-key menu-bar-manuals-menu [key]
|
|
|
|
|
'("Find Key in Manual" . Info-goto-emacs-key-command-node))
|
|
|
|
|
(define-key menu-bar-manuals-menu [command]
|
|
|
|
|
'("Find Command in Manual" . Info-goto-emacs-command-node))
|
|
|
|
|
(define-key menu-bar-manuals-menu [info]
|
|
|
|
|
'("Browse Manuals with Info" . info))
|
|
|
|
|
(define-key menu-bar-manuals-menu [sep1]
|
|
|
|
|
'("--"))
|
|
|
|
|
(define-key menu-bar-manuals-menu [emacs-faq]
|
|
|
|
|
'("Emacs FAQ" . view-emacs-FAQ))
|
|
|
|
|
(define-key menu-bar-manuals-menu [emacs-news]
|
|
|
|
|
'("Emacs News" . view-emacs-news))
|
1997-08-29 02:12:38 +00:00
|
|
|
|
|
1998-01-24 02:23:15 +00:00
|
|
|
|
(define-key menu-bar-help-menu [describe-no-warranty]
|
|
|
|
|
'("(Non)Warranty" . describe-no-warranty))
|
|
|
|
|
(define-key menu-bar-help-menu [describe-copying]
|
|
|
|
|
'("Copying Conditions" . describe-copying))
|
|
|
|
|
(define-key menu-bar-help-menu [describe-distribution]
|
|
|
|
|
'("Getting New Versions" . describe-distribution))
|
1994-04-28 04:15:32 +00:00
|
|
|
|
(define-key menu-bar-help-menu [emacs-version]
|
|
|
|
|
'("Show Version" . emacs-version))
|
1994-04-28 04:17:42 +00:00
|
|
|
|
(define-key menu-bar-help-menu [report-emacs-bug]
|
1995-05-31 19:41:49 +00:00
|
|
|
|
'("Send Bug Report..." . report-emacs-bug))
|
1997-11-24 04:59:24 +00:00
|
|
|
|
(define-key menu-bar-help-menu [sep2]
|
|
|
|
|
'("--"))
|
1995-07-17 22:51:17 +00:00
|
|
|
|
(define-key menu-bar-help-menu [finder-by-keyword]
|
1997-11-24 04:59:24 +00:00
|
|
|
|
'("Find Emacs Packages..." . finder-by-keyword))
|
|
|
|
|
(define-key menu-bar-help-menu [describe]
|
|
|
|
|
(cons "Describe" menu-bar-describe-menu))
|
|
|
|
|
(define-key menu-bar-help-menu [manuals]
|
|
|
|
|
(cons "Manuals" menu-bar-manuals-menu))
|
1993-03-15 00:46:58 +00:00
|
|
|
|
(define-key menu-bar-help-menu [emacs-tutorial]
|
1993-03-14 23:39:34 +00:00
|
|
|
|
'("Emacs Tutorial" . help-with-tutorial))
|
1997-11-24 04:59:24 +00:00
|
|
|
|
(define-key menu-bar-help-menu [sep1]
|
|
|
|
|
'("--"))
|
|
|
|
|
(define-key menu-bar-help-menu [options]
|
1997-08-29 02:12:38 +00:00
|
|
|
|
(cons "Options" menu-bar-options-menu))
|
1997-11-24 04:59:24 +00:00
|
|
|
|
(define-key menu-bar-help-menu [customize]
|
1997-05-07 20:54:04 +00:00
|
|
|
|
(cons "Customize" menu-bar-custom-menu))
|
1995-03-06 05:19:05 +00:00
|
|
|
|
|
1993-03-14 23:39:34 +00:00
|
|
|
|
(defun kill-this-buffer () ; for the menubar
|
|
|
|
|
"Kills the current buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(kill-buffer (current-buffer)))
|
|
|
|
|
|
1993-03-15 01:05:11 +00:00
|
|
|
|
(defun kill-this-buffer-enabled-p ()
|
|
|
|
|
(let ((count 0)
|
|
|
|
|
(buffers (buffer-list)))
|
|
|
|
|
(while buffers
|
|
|
|
|
(or (string-match "^ " (buffer-name (car buffers)))
|
|
|
|
|
(setq count (1+ count)))
|
|
|
|
|
(setq buffers (cdr buffers)))
|
1996-12-07 20:30:18 +00:00
|
|
|
|
(and (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
|
1995-04-24 15:26:19 +00:00
|
|
|
|
(> count 1))))
|
|
|
|
|
|
|
|
|
|
(put 'kill-this-buffer 'menu-enable '(kill-this-buffer-enabled-p))
|
|
|
|
|
|
|
|
|
|
(put 'save-buffer 'menu-enable
|
|
|
|
|
'(and (buffer-modified-p)
|
1996-12-07 20:30:18 +00:00
|
|
|
|
(not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))
|
1995-04-24 15:26:19 +00:00
|
|
|
|
|
|
|
|
|
(put 'write-file 'menu-enable
|
1996-12-07 20:30:18 +00:00
|
|
|
|
'(not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
|
1995-04-24 15:26:19 +00:00
|
|
|
|
|
|
|
|
|
(put 'find-file 'menu-enable
|
1996-12-07 20:30:18 +00:00
|
|
|
|
'(not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
|
1995-04-24 15:26:19 +00:00
|
|
|
|
|
|
|
|
|
(put 'dired 'menu-enable
|
1996-12-07 20:30:18 +00:00
|
|
|
|
'(not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
|
1995-04-24 15:26:19 +00:00
|
|
|
|
|
|
|
|
|
(put 'insert-file 'menu-enable
|
1996-12-07 20:30:18 +00:00
|
|
|
|
'(not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
|
1993-03-15 01:05:11 +00:00
|
|
|
|
|
1993-07-17 01:43:00 +00:00
|
|
|
|
(put 'revert-buffer 'menu-enable
|
|
|
|
|
'(or revert-buffer-function revert-buffer-insert-file-contents-function
|
|
|
|
|
(and (buffer-file-name)
|
1993-09-19 02:05:38 +00:00
|
|
|
|
(or (buffer-modified-p)
|
|
|
|
|
(not (verify-visited-file-modtime (current-buffer)))))))
|
1995-05-24 01:02:08 +00:00
|
|
|
|
|
1993-07-29 04:50:27 +00:00
|
|
|
|
;; Permit deleting frame if it would leave a visible or iconified frame.
|
|
|
|
|
(put 'delete-frame 'menu-enable
|
1995-05-24 01:02:08 +00:00
|
|
|
|
'(delete-frame-enabled-p))
|
|
|
|
|
|
|
|
|
|
(defun delete-frame-enabled-p ()
|
|
|
|
|
"Return non-nil if `delete-frame' should be enabled in the menu bar."
|
|
|
|
|
(let ((frames (frame-list))
|
1996-06-21 05:54:19 +00:00
|
|
|
|
(count 0))
|
|
|
|
|
(while frames
|
|
|
|
|
(if (frame-visible-p (car frames))
|
|
|
|
|
(setq count (1+ count)))
|
|
|
|
|
(setq frames (cdr frames)))
|
|
|
|
|
(> count 1)))
|
1993-03-15 01:05:11 +00:00
|
|
|
|
|
1993-03-14 23:39:34 +00:00
|
|
|
|
(put 'advertised-undo 'menu-enable
|
|
|
|
|
'(and (not (eq t buffer-undo-list))
|
|
|
|
|
(if (eq last-command 'undo)
|
1993-03-15 01:05:11 +00:00
|
|
|
|
(and (boundp 'pending-undo-list)
|
|
|
|
|
pending-undo-list)
|
|
|
|
|
buffer-undo-list)))
|
1993-06-17 04:17:21 +00:00
|
|
|
|
|
1997-05-05 15:06:25 +00:00
|
|
|
|
(defcustom yank-menu-length 20
|
|
|
|
|
"*Maximum length to display in the yank-menu."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'mouse)
|
1994-09-15 22:16:49 +00:00
|
|
|
|
|
|
|
|
|
(defun menu-bar-update-yank-menu (string old)
|
|
|
|
|
(let ((front (car (cdr yank-menu)))
|
|
|
|
|
(menu-string (if (<= (length string) yank-menu-length)
|
|
|
|
|
string
|
1995-01-30 00:37:22 +00:00
|
|
|
|
(concat
|
|
|
|
|
(substring string 0 (/ yank-menu-length 2))
|
|
|
|
|
"..."
|
|
|
|
|
(substring string (- (/ yank-menu-length 2)))))))
|
1995-07-20 06:14:12 +00:00
|
|
|
|
;; 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 " ")))
|
1994-09-15 22:16:49 +00:00
|
|
|
|
;; 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))
|
|
|
|
|
(string= old (car front))))
|
1993-07-01 03:31:58 +00:00
|
|
|
|
(progn
|
1994-09-15 22:16:49 +00:00
|
|
|
|
(setcar front string)
|
|
|
|
|
(setcar (cdr front) menu-string))
|
|
|
|
|
(setcdr yank-menu
|
|
|
|
|
(cons
|
|
|
|
|
(cons string (cons menu-string 'menu-bar-select-yank))
|
|
|
|
|
(cdr yank-menu)))))
|
|
|
|
|
(if (> (length (cdr yank-menu)) kill-ring-max)
|
|
|
|
|
(setcdr (nthcdr kill-ring-max yank-menu) nil)))
|
|
|
|
|
|
1997-12-21 01:46:29 +00:00
|
|
|
|
(put 'menu-bar-select-yank 'apropos-inhibit t)
|
1994-09-15 22:16:49 +00:00
|
|
|
|
(defun menu-bar-select-yank ()
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(push-mark (point))
|
|
|
|
|
(insert last-command-event))
|
1993-03-15 02:00:20 +00:00
|
|
|
|
|
1995-07-21 08:30:54 +00:00
|
|
|
|
;; 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")))
|
1993-03-15 02:00:20 +00:00
|
|
|
|
|
1993-08-14 10:32:54 +00:00
|
|
|
|
(defvar list-buffers-directory nil)
|
|
|
|
|
|
1994-10-23 07:45:25 +00:00
|
|
|
|
(defvar menu-bar-update-buffers-maxbuf)
|
|
|
|
|
|
1994-04-28 03:44:48 +00:00
|
|
|
|
(defun menu-bar-select-buffer ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(switch-to-buffer last-command-event))
|
|
|
|
|
|
|
|
|
|
(defun menu-bar-select-frame ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(make-frame-visible last-command-event)
|
|
|
|
|
(raise-frame last-command-event)
|
|
|
|
|
(select-frame last-command-event))
|
|
|
|
|
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(defun menu-bar-update-buffers-1 (elt)
|
|
|
|
|
(cons (format
|
1994-10-23 07:45:25 +00:00
|
|
|
|
(format "%%%ds %%s%%s %%s" menu-bar-update-buffers-maxbuf)
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(cdr elt)
|
|
|
|
|
(if (buffer-modified-p (car elt))
|
|
|
|
|
"*" " ")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(set-buffer (car elt))
|
|
|
|
|
(if buffer-read-only "%" " "))
|
|
|
|
|
(let ((file
|
|
|
|
|
(or (buffer-file-name (car elt))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(set-buffer (car elt))
|
|
|
|
|
list-buffers-directory)
|
|
|
|
|
"")))
|
|
|
|
|
(setq file (or (file-name-directory file)
|
|
|
|
|
""))
|
|
|
|
|
(if (> (length file) 20)
|
|
|
|
|
(setq file (concat "..." (substring file -17))))
|
|
|
|
|
file))
|
|
|
|
|
(car elt)))
|
|
|
|
|
|
1995-04-09 07:32:17 +00:00
|
|
|
|
(defvar menu-bar-buffers-menu-list-buffers-entry nil)
|
|
|
|
|
|
1994-04-28 03:44:48 +00:00
|
|
|
|
(defun menu-bar-update-buffers ()
|
1994-07-24 05:34:16 +00:00
|
|
|
|
;; If user discards the Buffers item, play along.
|
1994-07-26 19:57:59 +00:00
|
|
|
|
(and (lookup-key (current-global-map) [menu-bar buffer])
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(frame-or-buffer-changed-p)
|
|
|
|
|
(let ((buffers (buffer-list))
|
|
|
|
|
(frames (frame-list))
|
1996-08-31 16:25:51 +00:00
|
|
|
|
(maxlen 0)
|
1994-07-24 05:34:16 +00:00
|
|
|
|
buffers-menu frames-menu)
|
|
|
|
|
;; If requested, list only the N most recently selected buffers.
|
|
|
|
|
(if (and (integerp buffers-menu-max-size)
|
|
|
|
|
(> buffers-menu-max-size 1))
|
|
|
|
|
(if (> (length buffers) buffers-menu-max-size)
|
|
|
|
|
(setcdr (nthcdr buffers-menu-max-size buffers) nil)))
|
|
|
|
|
|
|
|
|
|
;; Make the menu of buffers proper.
|
|
|
|
|
(setq buffers-menu
|
|
|
|
|
(cons "Select Buffer"
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(let* ((buffer-list
|
|
|
|
|
(mapcar 'list buffers))
|
|
|
|
|
tail
|
1994-10-23 07:45:25 +00:00
|
|
|
|
(menu-bar-update-buffers-maxbuf 0)
|
1994-10-13 18:20:15 +00:00
|
|
|
|
alist
|
|
|
|
|
head)
|
|
|
|
|
;; Put into each element of buffer-list
|
|
|
|
|
;; the name for actual display,
|
|
|
|
|
;; perhaps truncated in the middle.
|
|
|
|
|
(setq tail buffer-list)
|
|
|
|
|
(while tail
|
|
|
|
|
(let ((name (buffer-name (car (car tail)))))
|
|
|
|
|
(setcdr (car tail)
|
|
|
|
|
(if (> (length name) 27)
|
|
|
|
|
(concat (substring name 0 12)
|
|
|
|
|
"..."
|
|
|
|
|
(substring name -12))
|
|
|
|
|
name)))
|
|
|
|
|
(setq tail (cdr tail)))
|
|
|
|
|
;; Compute the maximum length of any name.
|
|
|
|
|
(setq tail buffer-list)
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(while tail
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(or (eq ?\ (aref (cdr (car tail)) 0))
|
1994-10-23 07:45:25 +00:00
|
|
|
|
(setq menu-bar-update-buffers-maxbuf
|
|
|
|
|
(max menu-bar-update-buffers-maxbuf
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(length (cdr (car tail))))))
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(setq tail (cdr tail)))
|
1994-10-13 18:20:15 +00:00
|
|
|
|
;; Set ALIST to an alist of the form
|
|
|
|
|
;; ITEM-STRING . BUFFER
|
|
|
|
|
(setq tail buffer-list)
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(while tail
|
|
|
|
|
(let ((elt (car tail)))
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(or (eq ?\ (aref (cdr elt) 0))
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(setq alist (cons
|
1994-10-13 18:20:15 +00:00
|
|
|
|
(menu-bar-update-buffers-1 elt)
|
1994-07-24 05:34:16 +00:00
|
|
|
|
alist)))
|
|
|
|
|
(and alist (> (length (car (car alist))) maxlen)
|
|
|
|
|
(setq maxlen (length (car (car alist))))))
|
|
|
|
|
(setq tail (cdr tail)))
|
|
|
|
|
(setq alist (nreverse alist))
|
1995-04-09 07:32:17 +00:00
|
|
|
|
;; Make the menu item for list-buffers
|
|
|
|
|
;; or reuse the one we already have.
|
|
|
|
|
;; The advantage in reusing one
|
|
|
|
|
;; is that it already has the keyboard equivalent
|
|
|
|
|
;; cached, so we save the time to look that up again.
|
|
|
|
|
(or menu-bar-buffers-menu-list-buffers-entry
|
|
|
|
|
(setq menu-bar-buffers-menu-list-buffers-entry
|
|
|
|
|
(cons
|
|
|
|
|
'list-buffers
|
|
|
|
|
(cons
|
|
|
|
|
""
|
|
|
|
|
'list-buffers))))
|
|
|
|
|
;; Update the item string for menu's new width.
|
|
|
|
|
(setcar (cdr menu-bar-buffers-menu-list-buffers-entry)
|
|
|
|
|
(concat (make-string (max (- (/ maxlen 2) 8) 0)
|
|
|
|
|
?\ )
|
|
|
|
|
"List All Buffers"))
|
|
|
|
|
;; Now make the actual list of items,
|
|
|
|
|
;; ending with the list-buffers item.
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(nconc (mapcar '(lambda (pair)
|
|
|
|
|
;; This is somewhat risque, to use
|
|
|
|
|
;; the buffer name itself as the event
|
|
|
|
|
;; type to define, but it works.
|
|
|
|
|
;; It would not work to use the buffer
|
|
|
|
|
;; since a buffer as an event has its
|
|
|
|
|
;; own meaning.
|
|
|
|
|
(nconc (list (buffer-name (cdr pair))
|
|
|
|
|
(car pair)
|
|
|
|
|
(cons nil nil))
|
|
|
|
|
'menu-bar-select-buffer))
|
|
|
|
|
alist)
|
1995-04-09 07:32:17 +00:00
|
|
|
|
(list menu-bar-buffers-menu-list-buffers-entry)))))
|
1994-07-24 05:34:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Make a Frames menu if we have more than one frame.
|
|
|
|
|
(if (cdr frames)
|
1996-08-31 16:25:51 +00:00
|
|
|
|
(let ((name (concat (make-string (max (- (/ maxlen 2) 3) 0)
|
|
|
|
|
?\ )
|
|
|
|
|
"Frames"))
|
|
|
|
|
(frames-menu
|
|
|
|
|
(cons 'keymap
|
|
|
|
|
(cons "Select Frame"
|
|
|
|
|
(mapcar '(lambda (frame)
|
|
|
|
|
(nconc (list frame
|
|
|
|
|
(cdr (assq 'name
|
|
|
|
|
(frame-parameters frame)))
|
|
|
|
|
(cons nil nil))
|
|
|
|
|
'menu-bar-select-frame))
|
|
|
|
|
frames)))))
|
|
|
|
|
;; Put it underneath the Buffers menu.
|
|
|
|
|
(setq buffers-menu (cons (cons 'frames (cons name frames-menu))
|
|
|
|
|
buffers-menu))))
|
1994-07-24 05:34:16 +00:00
|
|
|
|
(if buffers-menu
|
|
|
|
|
(setq buffers-menu (cons 'keymap buffers-menu)))
|
1994-07-26 19:57:59 +00:00
|
|
|
|
(define-key (current-global-map) [menu-bar buffer]
|
1996-08-31 16:25:51 +00:00
|
|
|
|
(cons "Buffers" buffers-menu)))))
|
1994-04-28 03:44:48 +00:00
|
|
|
|
|
|
|
|
|
(add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
|
1993-03-15 01:05:11 +00:00
|
|
|
|
|
1995-07-21 08:30:54 +00:00
|
|
|
|
(menu-bar-update-buffers)
|
|
|
|
|
|
1993-03-15 02:00:20 +00:00
|
|
|
|
;; this version is too slow
|
|
|
|
|
;;;(defun format-buffers-menu-line (buffer)
|
|
|
|
|
;;; "Returns a string to represent the given buffer in the Buffer menu.
|
|
|
|
|
;;;nil means the buffer shouldn't be listed. You can redefine this."
|
|
|
|
|
;;; (if (string-match "\\` " (buffer-name buffer))
|
|
|
|
|
;;; nil
|
|
|
|
|
;;; (save-excursion
|
|
|
|
|
;;; (set-buffer buffer)
|
|
|
|
|
;;; (let ((size (buffer-size)))
|
|
|
|
|
;;; (format "%s%s %-19s %6s %-15s %s"
|
|
|
|
|
;;; (if (buffer-modified-p) "*" " ")
|
|
|
|
|
;;; (if buffer-read-only "%" " ")
|
|
|
|
|
;;; (buffer-name)
|
|
|
|
|
;;; size
|
|
|
|
|
;;; mode-name
|
|
|
|
|
;;; (or (buffer-file-name) ""))))))
|
|
|
|
|
|
1995-06-29 03:11:37 +00:00
|
|
|
|
;;; 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]
|
1995-11-16 17:16:12 +00:00
|
|
|
|
'("Complete" . minibuffer-complete))
|
1995-06-29 03:11:37 +00:00
|
|
|
|
))
|
|
|
|
|
(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))
|
|
|
|
|
|
1994-06-25 18:20:30 +00:00
|
|
|
|
(defvar menu-bar-mode nil)
|
|
|
|
|
|
1993-05-17 04:45:03 +00:00
|
|
|
|
(defun menu-bar-mode (flag)
|
1993-05-24 05:06:35 +00:00
|
|
|
|
"Toggle display of a menu bar on each frame.
|
1993-05-17 04:45:03 +00:00
|
|
|
|
This command applies to all frames that exist and frames to be
|
|
|
|
|
created in the future.
|
1998-07-02 22:09:29 +00:00
|
|
|
|
With a numeric argument, if the argument is positive,
|
|
|
|
|
turn on menu bars; otherwise, turn off menu bars."
|
1993-08-06 21:06:10 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
|
1994-06-25 18:20:30 +00:00
|
|
|
|
;; Make menu-bar-mode and default-frame-alist consistent.
|
|
|
|
|
(let ((default (assq 'menu-bar-lines default-frame-alist)))
|
|
|
|
|
(if default
|
|
|
|
|
(setq menu-bar-mode (not (eq (cdr default) 0)))
|
|
|
|
|
(setq default-frame-alist
|
|
|
|
|
(cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
|
|
|
|
|
default-frame-alist))))
|
|
|
|
|
|
|
|
|
|
;; Toggle or set the mode, according to FLAG.
|
|
|
|
|
(setq menu-bar-mode (if (null flag) (not menu-bar-mode)
|
|
|
|
|
(> (prefix-numeric-value flag) 0)))
|
|
|
|
|
|
|
|
|
|
;; Apply it to default-frame-alist.
|
|
|
|
|
(let ((parameter (assq 'menu-bar-lines default-frame-alist)))
|
|
|
|
|
(if (consp parameter)
|
|
|
|
|
(setcdr parameter (if menu-bar-mode 1 0))
|
|
|
|
|
(setq default-frame-alist
|
|
|
|
|
(cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
|
|
|
|
|
default-frame-alist))))
|
|
|
|
|
|
|
|
|
|
;; Apply it to existing frames.
|
|
|
|
|
(let ((frames (frame-list)))
|
|
|
|
|
(while frames
|
|
|
|
|
(let ((height (cdr (assq 'height (frame-parameters (car frames))))))
|
|
|
|
|
(modify-frame-parameters (car frames)
|
|
|
|
|
(list (cons 'menu-bar-lines
|
|
|
|
|
(if menu-bar-mode 1 0))))
|
|
|
|
|
(modify-frame-parameters (car frames)
|
|
|
|
|
(list (cons 'height height))))
|
|
|
|
|
(setq frames (cdr frames)))))
|
1993-04-08 07:10:13 +00:00
|
|
|
|
|
1993-05-13 03:34:18 +00:00
|
|
|
|
(provide 'menu-bar)
|
|
|
|
|
|
1993-04-08 16:17:43 +00:00
|
|
|
|
;;; menu-bar.el ends here
|