| 1 | ;;; menu-bar.el --- define a default menu bar |
| 2 | |
| 3 | ;; Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004, |
| 4 | ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
| 5 | |
| 6 | ;; Author: RMS |
| 7 | ;; Maintainer: FSF |
| 8 | ;; Keywords: internal, mouse |
| 9 | |
| 10 | ;; This file is part of GNU Emacs. |
| 11 | |
| 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 13 | ;; it under the terms of the GNU General Public License as published by |
| 14 | ;; the Free Software Foundation, either version 3 of the License, or |
| 15 | ;; (at your option) any later version. |
| 16 | |
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | ;; GNU General Public License for more details. |
| 21 | |
| 22 | ;; You should have received a copy of the GNU General Public License |
| 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 24 | |
| 25 | ;; Avishai Yacobi suggested some menu rearrangements. |
| 26 | |
| 27 | ;;; Commentary: |
| 28 | |
| 29 | ;;; Code: |
| 30 | |
| 31 | ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key |
| 32 | ;; definitions made in loaddefs.el. |
| 33 | (or (lookup-key global-map [menu-bar]) |
| 34 | (define-key global-map [menu-bar] (make-sparse-keymap "menu-bar"))) |
| 35 | (defvar menu-bar-help-menu (make-sparse-keymap "Help")) |
| 36 | |
| 37 | ;; Force Help item to come last, after the major mode's own items. |
| 38 | ;; The symbol used to be called `help', but that gets confused with the |
| 39 | ;; help key. |
| 40 | (setq menu-bar-final-items '(help-menu)) |
| 41 | |
| 42 | (define-key global-map [menu-bar help-menu] (cons "Help" menu-bar-help-menu)) |
| 43 | (defvar menu-bar-tools-menu (make-sparse-keymap "Tools")) |
| 44 | (define-key global-map [menu-bar tools] (cons "Tools" menu-bar-tools-menu)) |
| 45 | ;; This definition is just to show what this looks like. |
| 46 | ;; It gets modified in place when menu-bar-update-buffers is called. |
| 47 | (defvar global-buffers-menu-map (make-sparse-keymap "Buffers")) |
| 48 | (define-key global-map [menu-bar buffer] |
| 49 | (cons "Buffers" global-buffers-menu-map)) |
| 50 | (defvar menu-bar-options-menu (make-sparse-keymap "Options")) |
| 51 | (define-key global-map [menu-bar options] |
| 52 | (cons "Options" menu-bar-options-menu)) |
| 53 | (defvar menu-bar-edit-menu (make-sparse-keymap "Edit")) |
| 54 | (define-key global-map [menu-bar edit] (cons "Edit" menu-bar-edit-menu)) |
| 55 | (defvar menu-bar-file-menu (make-sparse-keymap "File")) |
| 56 | (define-key global-map [menu-bar file] (cons "File" menu-bar-file-menu)) |
| 57 | |
| 58 | ;; This alias is for compatibility with 19.28 and before. |
| 59 | (defvar menu-bar-files-menu menu-bar-file-menu) |
| 60 | |
| 61 | ;; This is referenced by some code below; it is defined in uniquify.el |
| 62 | (defvar uniquify-buffer-name-style) |
| 63 | |
| 64 | \f |
| 65 | ;; The "File" menu items |
| 66 | (define-key menu-bar-file-menu [exit-emacs] |
| 67 | '(menu-item "Exit Emacs" save-buffers-kill-emacs |
| 68 | :help "Save unsaved buffers, then exit")) |
| 69 | |
| 70 | (define-key menu-bar-file-menu [separator-exit] |
| 71 | '("--")) |
| 72 | |
| 73 | ;; Don't use delete-frame as event name because that is a special |
| 74 | ;; event. |
| 75 | (define-key menu-bar-file-menu [delete-this-frame] |
| 76 | '(menu-item "Delete Frame" delete-frame |
| 77 | :visible (fboundp 'delete-frame) |
| 78 | :enable (delete-frame-enabled-p) |
| 79 | :help "Delete currently selected frame")) |
| 80 | (define-key menu-bar-file-menu [make-frame-on-display] |
| 81 | '(menu-item "New Frame on Display..." make-frame-on-display |
| 82 | :visible (fboundp 'make-frame-on-display) |
| 83 | :help "Open a new frame on another display")) |
| 84 | (define-key menu-bar-file-menu [make-frame] |
| 85 | '(menu-item "New Frame" make-frame-command |
| 86 | :visible (fboundp 'make-frame-command) |
| 87 | :help "Open a new frame")) |
| 88 | |
| 89 | (define-key menu-bar-file-menu [one-window] |
| 90 | '(menu-item "Remove Splits" delete-other-windows |
| 91 | :enable (not (one-window-p t nil)) |
| 92 | :help "Selected window grows to fill the whole frame")) |
| 93 | |
| 94 | (define-key menu-bar-file-menu [split-window] |
| 95 | '(menu-item "Split Window" split-window-vertically |
| 96 | :enable (and (menu-bar-menu-frame-live-and-visible-p) |
| 97 | (menu-bar-non-minibuffer-window-p)) |
| 98 | :help "Split selected window in two windows")) |
| 99 | |
| 100 | (define-key menu-bar-file-menu [separator-window] |
| 101 | '(menu-item "--")) |
| 102 | |
| 103 | (define-key menu-bar-file-menu [ps-print-region] |
| 104 | '(menu-item "Postscript Print Region (B+W)" ps-print-region |
| 105 | :enable mark-active |
| 106 | :help "Pretty-print marked region in black and white to PostScript printer")) |
| 107 | (define-key menu-bar-file-menu [ps-print-buffer] |
| 108 | '(menu-item "Postscript Print Buffer (B+W)" ps-print-buffer |
| 109 | :enable (menu-bar-menu-frame-live-and-visible-p) |
| 110 | :help "Pretty-print current buffer in black and white to PostScript printer")) |
| 111 | (define-key menu-bar-file-menu [ps-print-region-faces] |
| 112 | '(menu-item "Postscript Print Region" ps-print-region-with-faces |
| 113 | :enable mark-active |
| 114 | :help "Pretty-print marked region to PostScript printer")) |
| 115 | (define-key menu-bar-file-menu [ps-print-buffer-faces] |
| 116 | '(menu-item "Postscript Print Buffer" ps-print-buffer-with-faces |
| 117 | :enable (menu-bar-menu-frame-live-and-visible-p) |
| 118 | :help "Pretty-print current buffer to PostScript printer")) |
| 119 | (define-key menu-bar-file-menu [print-region] |
| 120 | '(menu-item "Print Region" print-region |
| 121 | :enable mark-active |
| 122 | :help "Print region between mark and current position")) |
| 123 | (define-key menu-bar-file-menu [print-buffer] |
| 124 | '(menu-item "Print Buffer" print-buffer |
| 125 | :enable (menu-bar-menu-frame-live-and-visible-p) |
| 126 | :help "Print current buffer with page headings")) |
| 127 | |
| 128 | (define-key menu-bar-file-menu [separator-print] |
| 129 | '(menu-item "--")) |
| 130 | |
| 131 | (define-key menu-bar-file-menu [recover-session] |
| 132 | '(menu-item "Recover Crashed Session" recover-session |
| 133 | :enable (and auto-save-list-file-prefix |
| 134 | (file-directory-p |
| 135 | (file-name-directory auto-save-list-file-prefix)) |
| 136 | (directory-files |
| 137 | (file-name-directory auto-save-list-file-prefix) |
| 138 | nil |
| 139 | (concat "\\`" |
| 140 | (regexp-quote |
| 141 | (file-name-nondirectory |
| 142 | auto-save-list-file-prefix))) |
| 143 | t)) |
| 144 | :help "Recover edits from a crashed session")) |
| 145 | (define-key menu-bar-file-menu [revert-buffer] |
| 146 | '(menu-item "Revert Buffer" revert-buffer |
| 147 | :enable (or revert-buffer-function |
| 148 | revert-buffer-insert-file-contents-function |
| 149 | (and buffer-file-number |
| 150 | (or (buffer-modified-p) |
| 151 | (not (verify-visited-file-modtime |
| 152 | (current-buffer)))))) |
| 153 | :help "Re-read current buffer from its file")) |
| 154 | (define-key menu-bar-file-menu [write-file] |
| 155 | '(menu-item "Save As..." write-file |
| 156 | :enable (and (menu-bar-menu-frame-live-and-visible-p) |
| 157 | (menu-bar-non-minibuffer-window-p)) |
| 158 | :help "Write current buffer to another file")) |
| 159 | (define-key menu-bar-file-menu [save-buffer] |
| 160 | '(menu-item "Save" save-buffer |
| 161 | :enable (and (buffer-modified-p) |
| 162 | (buffer-file-name) |
| 163 | (menu-bar-non-minibuffer-window-p)) |
| 164 | :help "Save current buffer to its file")) |
| 165 | |
| 166 | (define-key menu-bar-file-menu [separator-save] |
| 167 | '(menu-item "--")) |
| 168 | |
| 169 | (defun menu-find-file-existing () |
| 170 | "Edit the existing file FILENAME." |
| 171 | (interactive) |
| 172 | (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog) |
| 173 | (x-uses-old-gtk-dialog)))) |
| 174 | (filename (car (find-file-read-args "Find file: " mustmatch)))) |
| 175 | (if mustmatch |
| 176 | (find-file-existing filename) |
| 177 | (find-file filename)))) |
| 178 | |
| 179 | |
| 180 | (define-key menu-bar-file-menu [kill-buffer] |
| 181 | '(menu-item "Close" kill-this-buffer |
| 182 | :enable (kill-this-buffer-enabled-p) |
| 183 | :help "Discard (kill) current buffer")) |
| 184 | (define-key menu-bar-file-menu [insert-file] |
| 185 | '(menu-item "Insert File..." insert-file |
| 186 | :enable (menu-bar-non-minibuffer-window-p) |
| 187 | :help "Insert another file into current buffer")) |
| 188 | (define-key menu-bar-file-menu [dired] |
| 189 | '(menu-item "Open Directory..." dired |
| 190 | :enable (menu-bar-non-minibuffer-window-p) |
| 191 | :help "Read a directory, to operate on its files")) |
| 192 | (define-key menu-bar-file-menu [open-file] |
| 193 | '(menu-item "Open File..." menu-find-file-existing |
| 194 | :enable (menu-bar-non-minibuffer-window-p) |
| 195 | :help "Read an existing file into an Emacs buffer")) |
| 196 | (define-key menu-bar-file-menu [new-file] |
| 197 | '(menu-item "Visit New File..." find-file |
| 198 | :enable (menu-bar-non-minibuffer-window-p) |
| 199 | :help "Specify a new file's name, to edit the file")) |
| 200 | |
| 201 | \f |
| 202 | ;; The "Edit" menu items |
| 203 | |
| 204 | ;; The "Edit->Search" submenu |
| 205 | (defvar menu-bar-last-search-type nil |
| 206 | "Type of last non-incremental search command called from the menu.") |
| 207 | |
| 208 | (defun nonincremental-repeat-search-forward () |
| 209 | "Search forward for the previous search string or regexp." |
| 210 | (interactive) |
| 211 | (cond |
| 212 | ((and (eq menu-bar-last-search-type 'string) |
| 213 | search-ring) |
| 214 | (search-forward (car search-ring))) |
| 215 | ((and (eq menu-bar-last-search-type 'regexp) |
| 216 | regexp-search-ring) |
| 217 | (re-search-forward (car regexp-search-ring))) |
| 218 | (t |
| 219 | (error "No previous search")))) |
| 220 | |
| 221 | (defun nonincremental-repeat-search-backward () |
| 222 | "Search backward for the previous search string or regexp." |
| 223 | (interactive) |
| 224 | (cond |
| 225 | ((and (eq menu-bar-last-search-type 'string) |
| 226 | search-ring) |
| 227 | (search-backward (car search-ring))) |
| 228 | ((and (eq menu-bar-last-search-type 'regexp) |
| 229 | regexp-search-ring) |
| 230 | (re-search-backward (car regexp-search-ring))) |
| 231 | (t |
| 232 | (error "No previous search")))) |
| 233 | |
| 234 | (defun nonincremental-search-forward (string) |
| 235 | "Read a string and search for it nonincrementally." |
| 236 | (interactive "sSearch for string: ") |
| 237 | (setq menu-bar-last-search-type 'string) |
| 238 | (if (equal string "") |
| 239 | (search-forward (car search-ring)) |
| 240 | (isearch-update-ring string nil) |
| 241 | (search-forward string))) |
| 242 | |
| 243 | (defun nonincremental-search-backward (string) |
| 244 | "Read a string and search backward for it nonincrementally." |
| 245 | (interactive "sSearch for string: ") |
| 246 | (setq menu-bar-last-search-type 'string) |
| 247 | (if (equal string "") |
| 248 | (search-backward (car search-ring)) |
| 249 | (isearch-update-ring string nil) |
| 250 | (search-backward string))) |
| 251 | |
| 252 | (defun nonincremental-re-search-forward (string) |
| 253 | "Read a regular expression and search for it nonincrementally." |
| 254 | (interactive "sSearch for regexp: ") |
| 255 | (setq menu-bar-last-search-type 'regexp) |
| 256 | (if (equal string "") |
| 257 | (re-search-forward (car regexp-search-ring)) |
| 258 | (isearch-update-ring string t) |
| 259 | (re-search-forward string))) |
| 260 | |
| 261 | (defun nonincremental-re-search-backward (string) |
| 262 | "Read a regular expression and search backward for it nonincrementally." |
| 263 | (interactive "sSearch for regexp: ") |
| 264 | (setq menu-bar-last-search-type 'regexp) |
| 265 | (if (equal string "") |
| 266 | (re-search-backward (car regexp-search-ring)) |
| 267 | (isearch-update-ring string t) |
| 268 | (re-search-backward string))) |
| 269 | |
| 270 | (defvar menu-bar-search-menu (make-sparse-keymap "Search")) |
| 271 | |
| 272 | ;; The Edit->Search->Incremental Search menu |
| 273 | (defvar menu-bar-i-search-menu |
| 274 | (make-sparse-keymap "Incremental Search")) |
| 275 | |
| 276 | (define-key menu-bar-i-search-menu [isearch-backward-regexp] |
| 277 | '(menu-item "Backward Regexp..." isearch-backward-regexp |
| 278 | :help "Search backwards for a regular expression as you type it")) |
| 279 | (define-key menu-bar-i-search-menu [isearch-forward-regexp] |
| 280 | '(menu-item "Forward Regexp..." isearch-forward-regexp |
| 281 | :help "Search forward for a regular expression as you type it")) |
| 282 | (define-key menu-bar-i-search-menu [isearch-backward] |
| 283 | '(menu-item "Backward String..." isearch-backward |
| 284 | :help "Search backwards for a string as you type it")) |
| 285 | (define-key menu-bar-i-search-menu [isearch-forward] |
| 286 | '(menu-item "Forward String..." isearch-forward |
| 287 | :help "Search forward for a string as you type it")) |
| 288 | |
| 289 | |
| 290 | (define-key menu-bar-search-menu [i-search] |
| 291 | (list 'menu-item "Incremental Search" menu-bar-i-search-menu)) |
| 292 | (define-key menu-bar-search-menu [separator-tag-isearch] |
| 293 | '(menu-item "--")) |
| 294 | |
| 295 | (define-key menu-bar-search-menu [tags-continue] |
| 296 | '(menu-item "Continue Tags Search" tags-loop-continue |
| 297 | :help "Continue last tags search operation")) |
| 298 | (define-key menu-bar-search-menu [tags-srch] |
| 299 | '(menu-item "Search Tagged Files..." tags-search |
| 300 | :help "Search for a regexp in all tagged files")) |
| 301 | (define-key menu-bar-search-menu [separator-tag-search] |
| 302 | '(menu-item "--")) |
| 303 | |
| 304 | (define-key menu-bar-search-menu [repeat-search-back] |
| 305 | '(menu-item "Repeat Backwards" nonincremental-repeat-search-backward |
| 306 | :enable (or (and (eq menu-bar-last-search-type 'string) |
| 307 | search-ring) |
| 308 | (and (eq menu-bar-last-search-type 'regexp) |
| 309 | regexp-search-ring)) |
| 310 | :help "Repeat last search backwards")) |
| 311 | (define-key menu-bar-search-menu [repeat-search-fwd] |
| 312 | '(menu-item "Repeat Forward" nonincremental-repeat-search-forward |
| 313 | :enable (or (and (eq menu-bar-last-search-type 'string) |
| 314 | search-ring) |
| 315 | (and (eq menu-bar-last-search-type 'regexp) |
| 316 | regexp-search-ring)) |
| 317 | :help "Repeat last search forward")) |
| 318 | (define-key menu-bar-search-menu [separator-repeat-search] |
| 319 | '(menu-item "--")) |
| 320 | |
| 321 | (define-key menu-bar-search-menu [re-search-backward] |
| 322 | '(menu-item "Regexp Backwards..." nonincremental-re-search-backward |
| 323 | :help "Search backwards for a regular expression")) |
| 324 | (define-key menu-bar-search-menu [re-search-forward] |
| 325 | '(menu-item "Regexp Forward..." nonincremental-re-search-forward |
| 326 | :help "Search forward for a regular expression")) |
| 327 | |
| 328 | (define-key menu-bar-search-menu [search-backward] |
| 329 | '(menu-item "String Backwards..." nonincremental-search-backward |
| 330 | :help "Search backwards for a string")) |
| 331 | (define-key menu-bar-search-menu [search-forward] |
| 332 | '(menu-item "String Forward..." nonincremental-search-forward |
| 333 | :help "Search forward for a string")) |
| 334 | |
| 335 | ;; The Edit->Replace submenu |
| 336 | |
| 337 | (defvar menu-bar-replace-menu (make-sparse-keymap "Replace")) |
| 338 | |
| 339 | (define-key menu-bar-replace-menu [tags-repl-continue] |
| 340 | '(menu-item "Continue Replace" tags-loop-continue |
| 341 | :help "Continue last tags replace operation")) |
| 342 | (define-key menu-bar-replace-menu [tags-repl] |
| 343 | '(menu-item "Replace in Tagged Files..." tags-query-replace |
| 344 | :help "Interactively replace a regexp in all tagged files")) |
| 345 | (define-key menu-bar-replace-menu [separator-replace-tags] |
| 346 | '(menu-item "--")) |
| 347 | |
| 348 | (define-key menu-bar-replace-menu [query-replace-regexp] |
| 349 | '(menu-item "Replace Regexp..." query-replace-regexp |
| 350 | :enable (not buffer-read-only) |
| 351 | :help "Replace regular expression interactively, ask about each occurrence")) |
| 352 | (define-key menu-bar-replace-menu [query-replace] |
| 353 | '(menu-item "Replace String..." query-replace |
| 354 | :enable (not buffer-read-only) |
| 355 | :help "Replace string interactively, ask about each occurrence")) |
| 356 | |
| 357 | ;;; Assemble the top-level Edit menu items. |
| 358 | (define-key menu-bar-edit-menu [props] |
| 359 | '(menu-item "Text Properties" facemenu-menu)) |
| 360 | |
| 361 | (define-key menu-bar-edit-menu [fill] |
| 362 | '(menu-item "Fill" fill-region |
| 363 | :enable (and mark-active (not buffer-read-only)) |
| 364 | :help |
| 365 | "Fill text in region to fit between left and right margin")) |
| 366 | |
| 367 | (define-key menu-bar-edit-menu [separator-bookmark] |
| 368 | '(menu-item "--")) |
| 369 | |
| 370 | (define-key menu-bar-edit-menu [bookmark] |
| 371 | '(menu-item "Bookmarks" menu-bar-bookmark-map)) |
| 372 | |
| 373 | (defvar menu-bar-goto-menu (make-sparse-keymap "Go To")) |
| 374 | |
| 375 | (define-key menu-bar-goto-menu [set-tags-name] |
| 376 | '(menu-item "Set Tags File Name..." visit-tags-table |
| 377 | :help "Tell Tags commands which tag table file to use")) |
| 378 | |
| 379 | (define-key menu-bar-goto-menu [separator-tag-file] |
| 380 | '(menu-item "--")) |
| 381 | |
| 382 | (define-key menu-bar-goto-menu [apropos-tags] |
| 383 | '(menu-item "Tags Apropos..." tags-apropos |
| 384 | :help "Find function/variables whose names match regexp")) |
| 385 | (define-key menu-bar-goto-menu [next-tag-otherw] |
| 386 | '(menu-item "Next Tag in Other Window" |
| 387 | menu-bar-next-tag-other-window |
| 388 | :enable (and (boundp 'tags-location-ring) |
| 389 | (not (ring-empty-p tags-location-ring))) |
| 390 | :help "Find next function/variable matching last tag name in another window")) |
| 391 | |
| 392 | (defun menu-bar-next-tag-other-window () |
| 393 | "Find the next definition of the tag already specified." |
| 394 | (interactive) |
| 395 | (find-tag-other-window nil t)) |
| 396 | |
| 397 | (defun menu-bar-next-tag () |
| 398 | "Find the next definition of the tag already specified." |
| 399 | (interactive) |
| 400 | (find-tag nil t)) |
| 401 | |
| 402 | (define-key menu-bar-goto-menu [next-tag] |
| 403 | '(menu-item "Find Next Tag" |
| 404 | menu-bar-next-tag |
| 405 | :enable (and (boundp 'tags-location-ring) |
| 406 | (not (ring-empty-p tags-location-ring))) |
| 407 | :help "Find next function/variable matching last tag name")) |
| 408 | (define-key menu-bar-goto-menu [find-tag-otherw] |
| 409 | '(menu-item "Find Tag in Other Window..." find-tag-other-window |
| 410 | :help "Find function/variable definition in another window")) |
| 411 | (define-key menu-bar-goto-menu [find-tag] |
| 412 | '(menu-item "Find Tag..." find-tag |
| 413 | :help "Find definition of function or variable")) |
| 414 | |
| 415 | (define-key menu-bar-goto-menu [separator-tags] |
| 416 | '(menu-item "--")) |
| 417 | |
| 418 | (define-key menu-bar-goto-menu [end-of-buf] |
| 419 | '(menu-item "Goto End of Buffer" end-of-buffer)) |
| 420 | (define-key menu-bar-goto-menu [beg-of-buf] |
| 421 | '(menu-item "Goto Beginning of Buffer" beginning-of-buffer)) |
| 422 | (define-key menu-bar-goto-menu [go-to-pos] |
| 423 | '(menu-item "Goto Buffer Position..." goto-char |
| 424 | :help "Read a number N and go to buffer position N")) |
| 425 | (define-key menu-bar-goto-menu [go-to-line] |
| 426 | '(menu-item "Goto Line..." goto-line |
| 427 | :help "Read a line number and go to that line")) |
| 428 | |
| 429 | (define-key menu-bar-edit-menu [goto] |
| 430 | (list 'menu-item "Go To" menu-bar-goto-menu)) |
| 431 | |
| 432 | (define-key menu-bar-edit-menu [replace] |
| 433 | (list 'menu-item "Replace" menu-bar-replace-menu)) |
| 434 | |
| 435 | (define-key menu-bar-edit-menu [search] |
| 436 | (list 'menu-item "Search" menu-bar-search-menu)) |
| 437 | |
| 438 | (define-key menu-bar-edit-menu [separator-search] |
| 439 | '(menu-item "--")) |
| 440 | |
| 441 | (define-key menu-bar-edit-menu [mark-whole-buffer] |
| 442 | '(menu-item "Select All" mark-whole-buffer |
| 443 | :help "Mark the whole buffer for a subsequent cut/copy.")) |
| 444 | (define-key menu-bar-edit-menu [clear] |
| 445 | '(menu-item "Clear" delete-region |
| 446 | :enable (and mark-active |
| 447 | (not buffer-read-only) |
| 448 | (not (mouse-region-match))) |
| 449 | :help |
| 450 | "Delete the text in region between mark and current position")) |
| 451 | (defvar yank-menu (cons "Select Yank" nil)) |
| 452 | (fset 'yank-menu (cons 'keymap yank-menu)) |
| 453 | (define-key menu-bar-edit-menu [paste-from-menu] |
| 454 | '(menu-item "Paste from kill menu" yank-menu |
| 455 | :enable (and (cdr yank-menu) (not buffer-read-only)) |
| 456 | :help "Choose a string from the kill ring and paste it")) |
| 457 | (define-key menu-bar-edit-menu [paste] |
| 458 | '(menu-item "Paste" yank |
| 459 | :enable (and |
| 460 | ;; Emacs compiled --without-x doesn't have |
| 461 | ;; x-selection-exists-p. |
| 462 | (fboundp 'x-selection-exists-p) |
| 463 | (x-selection-exists-p) (not buffer-read-only)) |
| 464 | :help "Paste (yank) text most recently cut/copied")) |
| 465 | (define-key menu-bar-edit-menu [copy] |
| 466 | '(menu-item "Copy" menu-bar-kill-ring-save |
| 467 | :enable mark-active |
| 468 | :help "Copy text in region between mark and current position" |
| 469 | :keys "\\[kill-ring-save]")) |
| 470 | (define-key menu-bar-edit-menu [cut] |
| 471 | '(menu-item "Cut" kill-region |
| 472 | :enable (and mark-active (not buffer-read-only)) |
| 473 | :help |
| 474 | "Cut (kill) text in region between mark and current position")) |
| 475 | (define-key menu-bar-edit-menu [undo] |
| 476 | '(menu-item "Undo" undo |
| 477 | :enable (and (not buffer-read-only) |
| 478 | (not (eq t buffer-undo-list)) |
| 479 | (if (eq last-command 'undo) |
| 480 | (listp pending-undo-list) |
| 481 | (consp buffer-undo-list))) |
| 482 | :help "Undo last operation")) |
| 483 | |
| 484 | |
| 485 | (defun menu-bar-kill-ring-save (beg end) |
| 486 | (interactive "r") |
| 487 | (if (mouse-region-match) |
| 488 | (message "Selecting a region with the mouse does `copy' automatically") |
| 489 | (kill-ring-save beg end))) |
| 490 | |
| 491 | ;; These are alternative definitions for the cut, paste and copy |
| 492 | ;; menu items. Use them if your system expects these to use the clipboard. |
| 493 | |
| 494 | (put 'clipboard-kill-region 'menu-enable |
| 495 | '(and mark-active (not buffer-read-only))) |
| 496 | (put 'clipboard-kill-ring-save 'menu-enable 'mark-active) |
| 497 | (put 'clipboard-yank 'menu-enable |
| 498 | '(and (or (and (fboundp 'x-selection-exists-p) |
| 499 | (x-selection-exists-p)) |
| 500 | (x-selection-exists-p 'CLIPBOARD)) |
| 501 | (not buffer-read-only))) |
| 502 | |
| 503 | (defun clipboard-yank () |
| 504 | "Insert the clipboard contents, or the last stretch of killed text." |
| 505 | (interactive "*") |
| 506 | (let ((x-select-enable-clipboard t)) |
| 507 | (yank))) |
| 508 | |
| 509 | (defun clipboard-kill-ring-save (beg end) |
| 510 | "Copy region to kill ring, and save in the X clipboard." |
| 511 | (interactive "r") |
| 512 | (let ((x-select-enable-clipboard t)) |
| 513 | (kill-ring-save beg end))) |
| 514 | |
| 515 | (defun clipboard-kill-region (beg end) |
| 516 | "Kill the region, and save it in the X clipboard." |
| 517 | (interactive "r") |
| 518 | (let ((x-select-enable-clipboard t)) |
| 519 | (kill-region beg end))) |
| 520 | |
| 521 | (defun menu-bar-enable-clipboard () |
| 522 | "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard. |
| 523 | Do the same for the keys of the same name." |
| 524 | (interactive) |
| 525 | ;; We can't use constant list structure here because it becomes pure, |
| 526 | ;; and because it gets modified with cache data. |
| 527 | (define-key menu-bar-edit-menu [paste] |
| 528 | (cons "Paste" (cons "Paste text from clipboard" 'clipboard-yank))) |
| 529 | (define-key menu-bar-edit-menu [copy] |
| 530 | (cons "Copy" (cons "Copy text in region to the clipboard" |
| 531 | 'clipboard-kill-ring-save))) |
| 532 | (define-key menu-bar-edit-menu [cut] |
| 533 | (cons "Cut" (cons "Delete text in region and copy it to the clipboard" |
| 534 | 'clipboard-kill-region))) |
| 535 | |
| 536 | ;; These are Sun server keysyms for the Cut, Copy and Paste keys |
| 537 | ;; (also for XFree86 on Sun keyboard): |
| 538 | (define-key global-map [f20] 'clipboard-kill-region) |
| 539 | (define-key global-map [f16] 'clipboard-kill-ring-save) |
| 540 | (define-key global-map [f18] 'clipboard-yank) |
| 541 | ;; X11R6 versions: |
| 542 | (define-key global-map [cut] 'clipboard-kill-region) |
| 543 | (define-key global-map [copy] 'clipboard-kill-ring-save) |
| 544 | (define-key global-map [paste] 'clipboard-yank)) |
| 545 | \f |
| 546 | ;; The "Options" menu items |
| 547 | |
| 548 | (defvar menu-bar-custom-menu (make-sparse-keymap "Customize")) |
| 549 | |
| 550 | (define-key menu-bar-custom-menu [customize-apropos-groups] |
| 551 | '(menu-item "Groups Matching Regexp..." customize-apropos-groups |
| 552 | :help "Browse groups whose names match regexp")) |
| 553 | (define-key menu-bar-custom-menu [customize-apropos-faces] |
| 554 | '(menu-item "Faces Matching Regexp..." customize-apropos-faces |
| 555 | :help "Browse faces whose names match regexp")) |
| 556 | (define-key menu-bar-custom-menu [customize-apropos-options] |
| 557 | '(menu-item "Options Matching Regexp..." customize-apropos-options |
| 558 | :help "Browse options whose names match regexp")) |
| 559 | (define-key menu-bar-custom-menu [customize-apropos] |
| 560 | '(menu-item "Settings Matching Regexp..." customize-apropos |
| 561 | :help "Browse customizable settings whose names match regexp")) |
| 562 | (define-key menu-bar-custom-menu [separator-1] |
| 563 | '("--")) |
| 564 | (define-key menu-bar-custom-menu [customize-group] |
| 565 | '(menu-item "Specific Group..." customize-group |
| 566 | :help "Customize settings of specific group")) |
| 567 | (define-key menu-bar-custom-menu [customize-face] |
| 568 | '(menu-item "Specific Face..." customize-face |
| 569 | :help "Customize attributes of specific face")) |
| 570 | (define-key menu-bar-custom-menu [customize-option] |
| 571 | '(menu-item "Specific Option..." customize-option |
| 572 | :help "Customize value of specific option")) |
| 573 | (define-key menu-bar-custom-menu [separator-2] |
| 574 | '("--")) |
| 575 | (define-key menu-bar-custom-menu [customize-changed-options] |
| 576 | '(menu-item "New Options..." customize-changed-options |
| 577 | :help "Options added or changed in recent Emacs versions")) |
| 578 | (define-key menu-bar-custom-menu [customize-saved] |
| 579 | '(menu-item "Saved Options" customize-saved |
| 580 | :help "Customize previously saved options")) |
| 581 | (define-key menu-bar-custom-menu [separator-3] |
| 582 | '("--")) |
| 583 | (define-key menu-bar-custom-menu [customize-browse] |
| 584 | '(menu-item "Browse Customization Groups" customize-browse |
| 585 | :help "Browse all customization groups")) |
| 586 | (define-key menu-bar-custom-menu [customize] |
| 587 | '(menu-item "Top-level Customization Group" customize |
| 588 | :help "The master group called `Emacs'")) |
| 589 | |
| 590 | ;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences")) |
| 591 | |
| 592 | (defmacro menu-bar-make-mm-toggle (fname doc help &optional props) |
| 593 | "Make a menu-item for a global minor mode toggle. |
| 594 | FNAME is the minor mode's name (variable and function). |
| 595 | DOC is the text to use for the menu entry. |
| 596 | HELP is the text to use for the tooltip. |
| 597 | PROPS are additional properties." |
| 598 | `'(menu-item ,doc ,fname |
| 599 | ,@props |
| 600 | :help ,help |
| 601 | :button (:toggle . (and (default-boundp ',fname) |
| 602 | (default-value ',fname))))) |
| 603 | |
| 604 | (defmacro menu-bar-make-toggle (name variable doc message help &rest body) |
| 605 | `(progn |
| 606 | (defun ,name (&optional interactively) |
| 607 | ,(concat "Toggle whether to " (downcase (substring help 0 1)) |
| 608 | (substring help 1) ". |
| 609 | In an interactive call, record this option as a candidate for saving |
| 610 | by \"Save Options\" in Custom buffers.") |
| 611 | (interactive "p") |
| 612 | (if ,(if body `(progn . ,body) |
| 613 | `(progn |
| 614 | (custom-load-symbol ',variable) |
| 615 | (let ((set (or (get ',variable 'custom-set) 'set-default)) |
| 616 | (get (or (get ',variable 'custom-get) 'default-value))) |
| 617 | (funcall set ',variable (not (funcall get ',variable)))))) |
| 618 | (message ,message "enabled globally") |
| 619 | (message ,message "disabled globally")) |
| 620 | ;; The function `customize-mark-as-set' must only be called when |
| 621 | ;; a variable is set interactively, as the purpose is to mark it as |
| 622 | ;; a candidate for "Save Options", and we do not want to save options |
| 623 | ;; the user have already set explicitly in his init file. |
| 624 | (if interactively (customize-mark-as-set ',variable))) |
| 625 | '(menu-item ,doc ,name |
| 626 | :help ,help |
| 627 | :button (:toggle . (and (default-boundp ',variable) |
| 628 | (default-value ',variable)))))) |
| 629 | |
| 630 | ;; Function for setting/saving default font. |
| 631 | |
| 632 | (defun menu-set-font () |
| 633 | "Interactively select a font and make it the default." |
| 634 | (interactive) |
| 635 | (let ((font (if (functionp 'x-font-dialog) |
| 636 | (x-font-dialog) |
| 637 | (mouse-select-font))) |
| 638 | spec) |
| 639 | (when font |
| 640 | (set-face-attribute 'default nil :font font) |
| 641 | (setq spec (list (list t (face-attr-construct 'default)))) |
| 642 | (put 'default 'customized-face spec) |
| 643 | (custom-push-theme 'theme-face 'default 'user 'set spec) |
| 644 | (put 'default 'face-modified nil)))) |
| 645 | |
| 646 | ;;; Assemble all the top-level items of the "Options" menu |
| 647 | (define-key menu-bar-options-menu [customize] |
| 648 | (list 'menu-item "Customize Emacs" menu-bar-custom-menu)) |
| 649 | |
| 650 | (defun menu-bar-options-save () |
| 651 | "Save current values of Options menu items using Custom." |
| 652 | (interactive) |
| 653 | (let ((need-save nil)) |
| 654 | ;; These are set with menu-bar-make-mm-toggle, which does not |
| 655 | ;; put on a customized-value property. |
| 656 | (dolist (elt '(line-number-mode column-number-mode size-indication-mode |
| 657 | cua-mode show-paren-mode transient-mark-mode |
| 658 | blink-cursor-mode display-time-mode display-battery-mode)) |
| 659 | (and (customize-mark-to-save elt) |
| 660 | (setq need-save t))) |
| 661 | ;; These are set with `customize-set-variable'. |
| 662 | (dolist (elt '(scroll-bar-mode |
| 663 | debug-on-quit debug-on-error |
| 664 | tooltip-mode menu-bar-mode tool-bar-mode |
| 665 | save-place uniquify-buffer-name-style fringe-mode |
| 666 | indicate-empty-lines indicate-buffer-boundaries |
| 667 | case-fold-search |
| 668 | current-language-environment default-input-method |
| 669 | ;; Saving `text-mode-hook' is somewhat questionable, |
| 670 | ;; as we might get more than we bargain for, if |
| 671 | ;; other code may has added hooks as well. |
| 672 | ;; Nonetheless, not saving it would like be confuse |
| 673 | ;; more often. |
| 674 | ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11. |
| 675 | text-mode-hook)) |
| 676 | (and (get elt 'customized-value) |
| 677 | (customize-mark-to-save elt) |
| 678 | (setq need-save t))) |
| 679 | (when (get 'default 'customized-face) |
| 680 | (put 'default 'saved-face (get 'default 'customized-face)) |
| 681 | (put 'default 'customized-face nil) |
| 682 | (setq need-save t)) |
| 683 | ;; Save if we changed anything. |
| 684 | (when need-save |
| 685 | (custom-save-all)))) |
| 686 | |
| 687 | (define-key menu-bar-options-menu [save] |
| 688 | '(menu-item "Save Options" menu-bar-options-save |
| 689 | :help "Save options set from the menu above")) |
| 690 | |
| 691 | (define-key menu-bar-options-menu [custom-separator] |
| 692 | '("--")) |
| 693 | |
| 694 | (define-key menu-bar-options-menu [menu-set-font] |
| 695 | '(menu-item "Set Default Font..." menu-set-font |
| 696 | :visible (display-multi-font-p) |
| 697 | :help "Select a default font")) |
| 698 | |
| 699 | ;; The "Show/Hide" submenu of menu "Options" |
| 700 | |
| 701 | (defvar menu-bar-showhide-menu (make-sparse-keymap "Show/Hide")) |
| 702 | |
| 703 | (define-key menu-bar-showhide-menu [column-number-mode] |
| 704 | (menu-bar-make-mm-toggle column-number-mode |
| 705 | "Column Numbers" |
| 706 | "Show the current column number in the mode line")) |
| 707 | |
| 708 | (define-key menu-bar-showhide-menu [line-number-mode] |
| 709 | (menu-bar-make-mm-toggle line-number-mode |
| 710 | "Line Numbers" |
| 711 | "Show the current line number in the mode line")) |
| 712 | |
| 713 | (define-key menu-bar-showhide-menu [size-indication-mode] |
| 714 | (menu-bar-make-mm-toggle size-indication-mode |
| 715 | "Size Indication" |
| 716 | "Show the size of the buffer in the mode line")) |
| 717 | |
| 718 | (define-key menu-bar-showhide-menu [linecolumn-separator] |
| 719 | '("--")) |
| 720 | |
| 721 | (define-key menu-bar-showhide-menu [showhide-battery] |
| 722 | (menu-bar-make-mm-toggle display-battery-mode |
| 723 | "Battery Status" |
| 724 | "Display battery status information in mode line")) |
| 725 | |
| 726 | (define-key menu-bar-showhide-menu [showhide-date-time] |
| 727 | (menu-bar-make-mm-toggle display-time-mode |
| 728 | "Time, Load and Mail" |
| 729 | "Display time, system load averages and \ |
| 730 | mail status in mode line")) |
| 731 | |
| 732 | (define-key menu-bar-showhide-menu [datetime-separator] |
| 733 | '("--")) |
| 734 | |
| 735 | (define-key menu-bar-showhide-menu [showhide-speedbar] |
| 736 | '(menu-item "Speedbar" speedbar-frame-mode |
| 737 | :help "Display a Speedbar quick-navigation frame" |
| 738 | :button (:toggle |
| 739 | . (and (boundp 'speedbar-frame) |
| 740 | (frame-live-p (symbol-value 'speedbar-frame)) |
| 741 | (frame-visible-p |
| 742 | (symbol-value 'speedbar-frame)))))) |
| 743 | |
| 744 | (defvar menu-bar-showhide-fringe-menu (make-sparse-keymap "Fringe")) |
| 745 | |
| 746 | (defvar menu-bar-showhide-fringe-ind-menu |
| 747 | (make-sparse-keymap "Buffer boundaries")) |
| 748 | |
| 749 | (defun menu-bar-showhide-fringe-ind-customize () |
| 750 | "Show customization buffer for `indicate-buffer-boundaries'." |
| 751 | (interactive) |
| 752 | (customize-variable 'indicate-buffer-boundaries)) |
| 753 | |
| 754 | (define-key menu-bar-showhide-fringe-ind-menu [customize] |
| 755 | '(menu-item "Other (Customize)" |
| 756 | menu-bar-showhide-fringe-ind-customize |
| 757 | :help "Additional choices available through Custom buffer" |
| 758 | :visible (display-graphic-p) |
| 759 | :button (:radio . (not (member indicate-buffer-boundaries |
| 760 | '(nil left right |
| 761 | ((top . left) (bottom . right)) |
| 762 | ((t . right) (top . left)))))))) |
| 763 | |
| 764 | (defun menu-bar-showhide-fringe-ind-mixed () |
| 765 | "Display top and bottom indicators in opposite fringes, arrows in right." |
| 766 | (interactive) |
| 767 | (customize-set-variable 'indicate-buffer-boundaries |
| 768 | '((t . right) (top . left)))) |
| 769 | |
| 770 | (define-key menu-bar-showhide-fringe-ind-menu [mixed] |
| 771 | '(menu-item "Opposite, Arrows Right" menu-bar-showhide-fringe-ind-mixed |
| 772 | :help |
| 773 | "Show top/bottom indicators in opposite fringes, arrows in right" |
| 774 | :visible (display-graphic-p) |
| 775 | :button (:radio . (equal indicate-buffer-boundaries |
| 776 | '((t . right) (top . left)))))) |
| 777 | |
| 778 | (defun menu-bar-showhide-fringe-ind-box () |
| 779 | "Display top and bottom indicators in opposite fringes." |
| 780 | (interactive) |
| 781 | (customize-set-variable 'indicate-buffer-boundaries |
| 782 | '((top . left) (bottom . right)))) |
| 783 | |
| 784 | (define-key menu-bar-showhide-fringe-ind-menu [box] |
| 785 | '(menu-item "Opposite, No Arrows" menu-bar-showhide-fringe-ind-box |
| 786 | :help "Show top/bottom indicators in opposite fringes, no arrows" |
| 787 | :visible (display-graphic-p) |
| 788 | :button (:radio . (equal indicate-buffer-boundaries |
| 789 | '((top . left) (bottom . right)))))) |
| 790 | |
| 791 | (defun menu-bar-showhide-fringe-ind-right () |
| 792 | "Display buffer boundaries and arrows in the right fringe." |
| 793 | (interactive) |
| 794 | (customize-set-variable 'indicate-buffer-boundaries 'right)) |
| 795 | |
| 796 | (define-key menu-bar-showhide-fringe-ind-menu [right] |
| 797 | '(menu-item "In Right Fringe" menu-bar-showhide-fringe-ind-right |
| 798 | :help "Show buffer boundaries and arrows in right fringe" |
| 799 | :visible (display-graphic-p) |
| 800 | :button (:radio . (eq indicate-buffer-boundaries 'right)))) |
| 801 | |
| 802 | (defun menu-bar-showhide-fringe-ind-left () |
| 803 | "Display buffer boundaries and arrows in the left fringe." |
| 804 | (interactive) |
| 805 | (customize-set-variable 'indicate-buffer-boundaries 'left)) |
| 806 | |
| 807 | (define-key menu-bar-showhide-fringe-ind-menu [left] |
| 808 | '(menu-item "In Left Fringe" menu-bar-showhide-fringe-ind-left |
| 809 | :help "Show buffer boundaries and arrows in left fringe" |
| 810 | :visible (display-graphic-p) |
| 811 | :button (:radio . (eq indicate-buffer-boundaries 'left)))) |
| 812 | |
| 813 | (defun menu-bar-showhide-fringe-ind-none () |
| 814 | "Do not display any buffer boundary indicators." |
| 815 | (interactive) |
| 816 | (customize-set-variable 'indicate-buffer-boundaries nil)) |
| 817 | |
| 818 | (define-key menu-bar-showhide-fringe-ind-menu [none] |
| 819 | '(menu-item "No Indicators" menu-bar-showhide-fringe-ind-none |
| 820 | :help "Hide all buffer boundary indicators and arrows" |
| 821 | :visible (display-graphic-p) |
| 822 | :button (:radio . (eq indicate-buffer-boundaries nil)))) |
| 823 | |
| 824 | (define-key menu-bar-showhide-fringe-menu [showhide-fringe-ind] |
| 825 | (list 'menu-item "Buffer Boundaries" menu-bar-showhide-fringe-ind-menu |
| 826 | :visible `(display-graphic-p) |
| 827 | :help "Indicate buffer boundaries in fringe")) |
| 828 | |
| 829 | (define-key menu-bar-showhide-fringe-menu [indicate-empty-lines] |
| 830 | (menu-bar-make-toggle toggle-indicate-empty-lines indicate-empty-lines |
| 831 | "Empty Line Indicators" |
| 832 | "Indicating of empty lines %s" |
| 833 | "Indicate trailing empty lines in fringe, globally")) |
| 834 | |
| 835 | (defun menu-bar-showhide-fringe-menu-customize () |
| 836 | "Show customization buffer for `fringe-mode'." |
| 837 | (interactive) |
| 838 | (customize-variable 'fringe-mode)) |
| 839 | |
| 840 | (define-key menu-bar-showhide-fringe-menu [customize] |
| 841 | '(menu-item "Customize Fringe" menu-bar-showhide-fringe-menu-customize |
| 842 | :help "Detailed customization of fringe" |
| 843 | :visible (display-graphic-p))) |
| 844 | |
| 845 | (defun menu-bar-showhide-fringe-menu-customize-reset () |
| 846 | "Reset the fringe mode: display fringes on both sides of a window." |
| 847 | (interactive) |
| 848 | (customize-set-variable 'fringe-mode nil)) |
| 849 | |
| 850 | (define-key menu-bar-showhide-fringe-menu [default] |
| 851 | '(menu-item "Default" menu-bar-showhide-fringe-menu-customize-reset |
| 852 | :help "Default width fringe on both left and right side" |
| 853 | :visible (display-graphic-p) |
| 854 | :button (:radio . (eq fringe-mode nil)))) |
| 855 | |
| 856 | (defun menu-bar-showhide-fringe-menu-customize-right () |
| 857 | "Display fringes only on the right of each window." |
| 858 | (interactive) |
| 859 | (require 'fringe) |
| 860 | (customize-set-variable 'fringe-mode '(0 . nil))) |
| 861 | |
| 862 | (define-key menu-bar-showhide-fringe-menu [right] |
| 863 | '(menu-item "On the Right" menu-bar-showhide-fringe-menu-customize-right |
| 864 | :help "Fringe only on the right side" |
| 865 | :visible (display-graphic-p) |
| 866 | :button (:radio . (equal fringe-mode '(0 . nil))))) |
| 867 | |
| 868 | (defun menu-bar-showhide-fringe-menu-customize-left () |
| 869 | "Display fringes only on the left of each window." |
| 870 | (interactive) |
| 871 | (require 'fringe) |
| 872 | (customize-set-variable 'fringe-mode '(nil . 0))) |
| 873 | |
| 874 | (define-key menu-bar-showhide-fringe-menu [left] |
| 875 | '(menu-item "On the Left" menu-bar-showhide-fringe-menu-customize-left |
| 876 | :help "Fringe only on the left side" |
| 877 | :visible (display-graphic-p) |
| 878 | :button (:radio . (equal fringe-mode '(nil . 0))))) |
| 879 | |
| 880 | (defun menu-bar-showhide-fringe-menu-customize-disable () |
| 881 | "Do not display window fringes." |
| 882 | (interactive) |
| 883 | (require 'fringe) |
| 884 | (customize-set-variable 'fringe-mode 0)) |
| 885 | |
| 886 | (define-key menu-bar-showhide-fringe-menu [none] |
| 887 | '(menu-item "None" menu-bar-showhide-fringe-menu-customize-disable |
| 888 | :help "Turn off fringe" |
| 889 | :visible (display-graphic-p) |
| 890 | :button (:radio . (eq fringe-mode 0)))) |
| 891 | |
| 892 | (define-key menu-bar-showhide-menu [showhide-fringe] |
| 893 | (list 'menu-item "Fringe" menu-bar-showhide-fringe-menu |
| 894 | :visible `(display-graphic-p))) |
| 895 | |
| 896 | (defvar menu-bar-showhide-scroll-bar-menu (make-sparse-keymap "Scroll-bar")) |
| 897 | |
| 898 | (define-key menu-bar-showhide-scroll-bar-menu [right] |
| 899 | '(menu-item "On the Right" |
| 900 | menu-bar-right-scroll-bar |
| 901 | :help "Scroll-bar on the right side" |
| 902 | :visible (display-graphic-p) |
| 903 | :button (:radio . (eq (cdr (assq 'vertical-scroll-bars |
| 904 | (frame-parameters))) 'right)))) |
| 905 | (defun menu-bar-right-scroll-bar () |
| 906 | "Display scroll bars on the right of each window." |
| 907 | (interactive) |
| 908 | (customize-set-variable 'scroll-bar-mode 'right)) |
| 909 | |
| 910 | (define-key menu-bar-showhide-scroll-bar-menu [left] |
| 911 | '(menu-item "On the Left" |
| 912 | menu-bar-left-scroll-bar |
| 913 | :help "Scroll-bar on the left side" |
| 914 | :visible (display-graphic-p) |
| 915 | :button (:radio . (eq (cdr (assq 'vertical-scroll-bars |
| 916 | (frame-parameters))) 'left)))) |
| 917 | |
| 918 | (defun menu-bar-left-scroll-bar () |
| 919 | "Display scroll bars on the left of each window." |
| 920 | (interactive) |
| 921 | (customize-set-variable 'scroll-bar-mode 'left)) |
| 922 | |
| 923 | (define-key menu-bar-showhide-scroll-bar-menu [none] |
| 924 | '(menu-item "None" |
| 925 | menu-bar-no-scroll-bar |
| 926 | :help "Turn off scroll-bar" |
| 927 | :visible (display-graphic-p) |
| 928 | :button (:radio . (eq (cdr (assq 'vertical-scroll-bars |
| 929 | (frame-parameters))) nil)))) |
| 930 | |
| 931 | (defun menu-bar-no-scroll-bar () |
| 932 | "Turn off scroll bars." |
| 933 | (interactive) |
| 934 | (customize-set-variable 'scroll-bar-mode nil)) |
| 935 | |
| 936 | (define-key menu-bar-showhide-menu [showhide-scroll-bar] |
| 937 | (list 'menu-item "Scroll-bar" menu-bar-showhide-scroll-bar-menu |
| 938 | :visible `(display-graphic-p))) |
| 939 | |
| 940 | (define-key menu-bar-showhide-menu [showhide-tooltip-mode] |
| 941 | (list 'menu-item "Tooltips" 'tooltip-mode |
| 942 | :help "Turn tooltips on/off" |
| 943 | :visible `(and (display-graphic-p) (fboundp 'x-show-tip)) |
| 944 | :button `(:toggle . tooltip-mode))) |
| 945 | |
| 946 | (define-key menu-bar-showhide-menu [menu-bar-mode] |
| 947 | '(menu-item "Menu-bar" toggle-menu-bar-mode-from-frame |
| 948 | :help "Turn menu-bar on/off" |
| 949 | :button (:toggle . (> (frame-parameter nil 'menu-bar-lines) 0)))) |
| 950 | |
| 951 | (define-key menu-bar-showhide-menu [showhide-tool-bar] |
| 952 | (list 'menu-item "Tool-bar" 'toggle-tool-bar-mode-from-frame |
| 953 | :help "Toggle tool-bar on/off" |
| 954 | :visible `(display-graphic-p) |
| 955 | :button `(:toggle . (> (frame-parameter nil 'tool-bar-lines) 0)))) |
| 956 | |
| 957 | (define-key menu-bar-options-menu [showhide] |
| 958 | (list 'menu-item "Show/Hide" menu-bar-showhide-menu)) |
| 959 | |
| 960 | (define-key menu-bar-options-menu [showhide-separator] |
| 961 | '("--")) |
| 962 | |
| 963 | (define-key menu-bar-options-menu [mule] |
| 964 | ;; It is better not to use backquote here, |
| 965 | ;; because that makes a bootstrapping problem |
| 966 | ;; if you need to recompile all the Lisp files using interpreted code. |
| 967 | (list 'menu-item "Mule (Multilingual Environment)" mule-menu-keymap |
| 968 | ;; Most of the MULE menu actually does make sense in unibyte mode, |
| 969 | ;; e.g. language selection. |
| 970 | ;;; ':visible 'default-enable-multibyte-characters |
| 971 | )) |
| 972 | ;(setq menu-bar-final-items (cons 'mule menu-bar-final-items)) |
| 973 | ;(define-key menu-bar-options-menu [preferences] |
| 974 | ; (list 'menu-item "Preferences" menu-bar-preferences-menu |
| 975 | ; :help "Toggle important global options")) |
| 976 | |
| 977 | (define-key menu-bar-options-menu [mule-separator] |
| 978 | '("--")) |
| 979 | |
| 980 | (define-key menu-bar-options-menu [debug-on-quit] |
| 981 | (menu-bar-make-toggle toggle-debug-on-quit debug-on-quit |
| 982 | "Enter Debugger on Quit/C-g" "Debug on Quit %s" |
| 983 | "Enter Lisp debugger when C-g is pressed")) |
| 984 | (define-key menu-bar-options-menu [debug-on-error] |
| 985 | (menu-bar-make-toggle toggle-debug-on-error debug-on-error |
| 986 | "Enter Debugger on Error" "Debug on Error %s" |
| 987 | "Enter Lisp debugger when an error is signaled")) |
| 988 | (define-key menu-bar-options-menu [debugger-separator] |
| 989 | '("--")) |
| 990 | |
| 991 | (define-key menu-bar-options-menu [blink-cursor-mode] |
| 992 | (menu-bar-make-mm-toggle blink-cursor-mode |
| 993 | "Blinking Cursor" |
| 994 | "Whether the cursor blinks (Blink Cursor mode)")) |
| 995 | (define-key menu-bar-options-menu [cursor-separator] |
| 996 | '("--")) |
| 997 | |
| 998 | (define-key menu-bar-options-menu [save-place] |
| 999 | (menu-bar-make-toggle toggle-save-place-globally save-place |
| 1000 | "Save Place in Files between Sessions" |
| 1001 | "Saving place in files %s" |
| 1002 | "Visit files of previous session when restarting Emacs" |
| 1003 | (require 'saveplace) |
| 1004 | ;; Do it by name, to avoid a free-variable |
| 1005 | ;; warning during byte compilation. |
| 1006 | (set-default |
| 1007 | 'save-place (not (symbol-value 'save-place))))) |
| 1008 | |
| 1009 | (define-key menu-bar-options-menu [uniquify] |
| 1010 | (menu-bar-make-toggle toggle-uniquify-buffer-names uniquify-buffer-name-style |
| 1011 | "Use Directory Names in Buffer Names" |
| 1012 | "Directory name in buffer names (uniquify) %s" |
| 1013 | "Uniquify buffer names by adding parent directory names" |
| 1014 | (require 'uniquify) |
| 1015 | (setq uniquify-buffer-name-style |
| 1016 | (if (not uniquify-buffer-name-style) |
| 1017 | 'forward)))) |
| 1018 | |
| 1019 | (define-key menu-bar-options-menu [edit-options-separator] |
| 1020 | '("--")) |
| 1021 | (define-key menu-bar-options-menu [cua-mode] |
| 1022 | (menu-bar-make-mm-toggle cua-mode |
| 1023 | "C-x/C-c/C-v Cut and Paste (CUA)" |
| 1024 | "Use C-z/C-x/C-c/C-v keys for undo/cut/copy/paste" |
| 1025 | (:visible (or (not (boundp 'cua-enable-cua-keys)) |
| 1026 | cua-enable-cua-keys)))) |
| 1027 | |
| 1028 | (define-key menu-bar-options-menu [cua-emulation-mode] |
| 1029 | (menu-bar-make-mm-toggle cua-mode |
| 1030 | "Shift movement mark region (CUA)" |
| 1031 | "Use shifted movement keys to set and extend the region." |
| 1032 | (:visible (and (boundp 'cua-enable-cua-keys) |
| 1033 | (not cua-enable-cua-keys))))) |
| 1034 | |
| 1035 | (define-key menu-bar-options-menu [case-fold-search] |
| 1036 | (menu-bar-make-toggle toggle-case-fold-search case-fold-search |
| 1037 | "Case-Insensitive Search" |
| 1038 | "Case-Insensitive Search %s" |
| 1039 | "Ignore letter-case in search commands")) |
| 1040 | |
| 1041 | (defun menu-bar-text-mode-auto-fill () |
| 1042 | (interactive) |
| 1043 | (toggle-text-mode-auto-fill) |
| 1044 | ;; This is somewhat questionable, as `text-mode-hook' |
| 1045 | ;; might have changed outside customize. |
| 1046 | ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11. |
| 1047 | (customize-mark-as-set 'text-mode-hook)) |
| 1048 | |
| 1049 | (define-key menu-bar-options-menu [auto-fill-mode] |
| 1050 | '(menu-item "Auto Fill in Text Modes" |
| 1051 | menu-bar-text-mode-auto-fill |
| 1052 | :help "Automatically fill text while typing (Auto Fill Mode)" |
| 1053 | :button (:toggle . (if (listp text-mode-hook) |
| 1054 | (member 'turn-on-auto-fill text-mode-hook) |
| 1055 | (eq 'turn-on-auto-fill text-mode-hook))))) |
| 1056 | |
| 1057 | (define-key menu-bar-options-menu [longlines-mode] |
| 1058 | '(menu-item "Word Wrap for Long Lines in this Buffer" |
| 1059 | longlines-mode |
| 1060 | :help "Perform word wrapping for long lines (Long Lines mode)" |
| 1061 | :button (:toggle . (and (boundp 'longlines-mode) |
| 1062 | longlines-mode)))) |
| 1063 | |
| 1064 | (define-key menu-bar-options-menu [truncate-lines] |
| 1065 | '(menu-item "Truncate Long Lines in this Buffer" |
| 1066 | toggle-truncate-lines |
| 1067 | :help "Truncate long lines at the window edge " |
| 1068 | :button (:toggle . (if (or (window-full-width-p) |
| 1069 | (not truncate-partial-width-windows)) |
| 1070 | truncate-lines |
| 1071 | truncate-partial-width-windows)) |
| 1072 | :enable (and (menu-bar-menu-frame-live-and-visible-p) |
| 1073 | (or (window-full-width-p) |
| 1074 | (not truncate-partial-width-windows))))) |
| 1075 | |
| 1076 | (define-key menu-bar-options-menu [highlight-separator] |
| 1077 | '("--")) |
| 1078 | (define-key menu-bar-options-menu [highlight-paren-mode] |
| 1079 | (menu-bar-make-mm-toggle show-paren-mode |
| 1080 | "Paren Match Highlighting" |
| 1081 | "Highlight matching/mismatched parentheses at cursor (Show Paren mode)")) |
| 1082 | (define-key menu-bar-options-menu [transient-mark-mode] |
| 1083 | (menu-bar-make-mm-toggle transient-mark-mode |
| 1084 | "Active Region Highlighting" |
| 1085 | "Make text in active region stand out in color (Transient Mark mode)" |
| 1086 | (:enable (not cua-mode)))) |
| 1087 | |
| 1088 | \f |
| 1089 | ;; The "Tools" menu items |
| 1090 | |
| 1091 | (defun send-mail-item-name () |
| 1092 | (let* ((known-send-mail-commands '((sendmail-user-agent . "sendmail") |
| 1093 | (mh-e-user-agent . "MH") |
| 1094 | (message-user-agent . "Gnus Message") |
| 1095 | (gnus-user-agent . "Gnus"))) |
| 1096 | (name (assq mail-user-agent known-send-mail-commands))) |
| 1097 | (if name |
| 1098 | (setq name (cdr name)) |
| 1099 | (setq name (symbol-name mail-user-agent)) |
| 1100 | (if (string-match "\\(.+\\)-user-agent" name) |
| 1101 | (setq name (match-string 1 name)))) |
| 1102 | name)) |
| 1103 | |
| 1104 | (defun read-mail-item-name () |
| 1105 | (let* ((known-rmail-commands '((rmail . "RMAIL") |
| 1106 | (mh-rmail . "MH") |
| 1107 | (gnus . "Gnus"))) |
| 1108 | (known (assq read-mail-command known-rmail-commands))) |
| 1109 | (if known (cdr known) (symbol-name read-mail-command)))) |
| 1110 | |
| 1111 | (defvar menu-bar-games-menu (make-sparse-keymap "Games")) |
| 1112 | |
| 1113 | (define-key menu-bar-tools-menu [games] |
| 1114 | (list 'menu-item "Games" menu-bar-games-menu)) |
| 1115 | |
| 1116 | (define-key menu-bar-tools-menu [separator-games] |
| 1117 | '("--")) |
| 1118 | |
| 1119 | (define-key menu-bar-games-menu [zone] |
| 1120 | '(menu-item "Zone Out" zone |
| 1121 | :help "Play tricks with Emacs display when Emacs is idle")) |
| 1122 | (define-key menu-bar-games-menu [tetris] |
| 1123 | '(menu-item "Tetris" tetris |
| 1124 | :help "Falling blocks game")) |
| 1125 | (define-key menu-bar-games-menu [solitaire] |
| 1126 | '(menu-item "Solitaire" solitaire |
| 1127 | :help "Get rid of all the stones")) |
| 1128 | (define-key menu-bar-games-menu [snake] |
| 1129 | '(menu-item "Snake" snake |
| 1130 | :help "Move snake around avoiding collisions")) |
| 1131 | (define-key menu-bar-games-menu [pong] |
| 1132 | '(menu-item "Pong" pong |
| 1133 | :help "Bounce the ball to your opponent")) |
| 1134 | (define-key menu-bar-games-menu [mult] |
| 1135 | '(menu-item "Multiplication Puzzle" mpuz |
| 1136 | :help "Exercise brain with multiplication")) |
| 1137 | (define-key menu-bar-games-menu [life] |
| 1138 | '(menu-item "Life" life |
| 1139 | :help "Watch how John Conway's cellular automaton evolves")) |
| 1140 | (define-key menu-bar-games-menu [hanoi] |
| 1141 | '(menu-item "Towers of Hanoi" hanoi |
| 1142 | :help "Watch Towers-of-Hanoi puzzle solved by Emacs")) |
| 1143 | (define-key menu-bar-games-menu [gomoku] |
| 1144 | '(menu-item "Gomoku" gomoku |
| 1145 | :help "Mark 5 contiguous squares (like tic-tac-toe)")) |
| 1146 | (define-key menu-bar-games-menu [bubbles] |
| 1147 | '(menu-item "Bubbles" bubbles |
| 1148 | :help "Remove all bubbles using the fewest moves")) |
| 1149 | (define-key menu-bar-games-menu [black-box] |
| 1150 | '(menu-item "Blackbox" blackbox |
| 1151 | :help "Find balls in a black box by shooting rays")) |
| 1152 | (define-key menu-bar-games-menu [adventure] |
| 1153 | '(menu-item "Adventure" dunnet |
| 1154 | :help "Dunnet, a text Adventure game for Emacs")) |
| 1155 | (define-key menu-bar-games-menu [5x5] |
| 1156 | '(menu-item "5x5" 5x5 |
| 1157 | :help "Fill in all the squares on a 5x5 board")) |
| 1158 | |
| 1159 | (defvar menu-bar-encryption-decryption-menu |
| 1160 | (make-sparse-keymap "Encryption/Decryption")) |
| 1161 | |
| 1162 | (define-key menu-bar-tools-menu [encryption-decryption] |
| 1163 | (list 'menu-item "Encryption/Decryption" menu-bar-encryption-decryption-menu)) |
| 1164 | |
| 1165 | (define-key menu-bar-tools-menu [separator-encryption-decryption] |
| 1166 | '("--")) |
| 1167 | |
| 1168 | (define-key menu-bar-encryption-decryption-menu [insert-keys] |
| 1169 | '(menu-item "Insert Keys" epa-insert-keys |
| 1170 | :help "Insert public keys after the current point")) |
| 1171 | |
| 1172 | (define-key menu-bar-encryption-decryption-menu [export-keys] |
| 1173 | '(menu-item "Export Keys" epa-export-keys |
| 1174 | :help "Export public keys to a file")) |
| 1175 | |
| 1176 | (define-key menu-bar-encryption-decryption-menu [import-keys-region] |
| 1177 | '(menu-item "Import Keys from Region" epa-import-keys-region |
| 1178 | :help "Import public keys from the current region")) |
| 1179 | |
| 1180 | (define-key menu-bar-encryption-decryption-menu [import-keys] |
| 1181 | '(menu-item "Import Keys from File..." epa-import-keys |
| 1182 | :help "Import public keys from a file")) |
| 1183 | |
| 1184 | (define-key menu-bar-encryption-decryption-menu [list-keys] |
| 1185 | '(menu-item "List Keys" epa-list-keys |
| 1186 | :help "Browse your public keyring")) |
| 1187 | |
| 1188 | (define-key menu-bar-encryption-decryption-menu [separator-keys] |
| 1189 | '("--")) |
| 1190 | |
| 1191 | (define-key menu-bar-encryption-decryption-menu [sign-region] |
| 1192 | '(menu-item "Sign Region" epa-sign-region |
| 1193 | :help "Create digital signature of the current region")) |
| 1194 | |
| 1195 | (define-key menu-bar-encryption-decryption-menu [verify-region] |
| 1196 | '(menu-item "Verify Region" epa-verify-region |
| 1197 | :help "Verify digital signature of the current region")) |
| 1198 | |
| 1199 | (define-key menu-bar-encryption-decryption-menu [encrypt-region] |
| 1200 | '(menu-item "Encrypt Region" epa-encrypt-region |
| 1201 | :help "Encrypt the current region")) |
| 1202 | |
| 1203 | (define-key menu-bar-encryption-decryption-menu [decrypt-region] |
| 1204 | '(menu-item "Decrypt Region" epa-decrypt-region |
| 1205 | :help "Decrypt the current region")) |
| 1206 | |
| 1207 | (define-key menu-bar-encryption-decryption-menu [separator-file] |
| 1208 | '("--")) |
| 1209 | |
| 1210 | (define-key menu-bar-encryption-decryption-menu [sign-file] |
| 1211 | '(menu-item "Sign File..." epa-sign-file |
| 1212 | :help "Create digital signature of a file")) |
| 1213 | |
| 1214 | (define-key menu-bar-encryption-decryption-menu [verify-file] |
| 1215 | '(menu-item "Verify File..." epa-verify-file |
| 1216 | :help "Verify digital signature of a file")) |
| 1217 | |
| 1218 | (define-key menu-bar-encryption-decryption-menu [encrypt-file] |
| 1219 | '(menu-item "Encrypt File..." epa-encrypt-file |
| 1220 | :help "Encrypt a file")) |
| 1221 | |
| 1222 | (define-key menu-bar-encryption-decryption-menu [decrypt-file] |
| 1223 | '(menu-item "Decrypt File..." epa-decrypt-file |
| 1224 | :help "Decrypt a file")) |
| 1225 | |
| 1226 | (define-key menu-bar-tools-menu [simple-calculator] |
| 1227 | '(menu-item "Simple Calculator" calculator |
| 1228 | :help "Invoke the Emacs built-in quick calculator")) |
| 1229 | (define-key menu-bar-tools-menu [calc] |
| 1230 | '(menu-item "Programmable Calculator" calc |
| 1231 | :help "Invoke the Emacs built-in full scientific calculator")) |
| 1232 | (define-key menu-bar-tools-menu [calendar] |
| 1233 | '(menu-item "Calendar" calendar |
| 1234 | :help "Invoke the Emacs built-in calendar")) |
| 1235 | |
| 1236 | (define-key menu-bar-tools-menu [separator-net] |
| 1237 | '("--")) |
| 1238 | |
| 1239 | (define-key menu-bar-tools-menu [directory-search] |
| 1240 | '(menu-item "Directory Search" eudc-tools-menu)) |
| 1241 | (define-key menu-bar-tools-menu [compose-mail] |
| 1242 | (list |
| 1243 | 'menu-item `(format "Send Mail (with %s)" (send-mail-item-name)) |
| 1244 | 'compose-mail |
| 1245 | :visible `(and mail-user-agent (not (eq mail-user-agent 'ignore))) |
| 1246 | :help "Send a mail message")) |
| 1247 | (define-key menu-bar-tools-menu [rmail] |
| 1248 | (list |
| 1249 | 'menu-item `(format "Read Mail (with %s)" (read-mail-item-name)) |
| 1250 | 'menu-bar-read-mail |
| 1251 | :visible `(and read-mail-command (not (eq read-mail-command 'ignore))) |
| 1252 | :help "Read your mail and reply to it")) |
| 1253 | |
| 1254 | (defun menu-bar-read-mail () |
| 1255 | "Read mail using `read-mail-command'." |
| 1256 | (interactive) |
| 1257 | (call-interactively read-mail-command)) |
| 1258 | |
| 1259 | (define-key menu-bar-tools-menu [gnus] |
| 1260 | '(menu-item "Read Net News (Gnus)" gnus |
| 1261 | :help "Read network news groups")) |
| 1262 | |
| 1263 | (define-key menu-bar-tools-menu [separator-vc] |
| 1264 | '("--")) |
| 1265 | |
| 1266 | (define-key menu-bar-tools-menu [pcl-cvs] |
| 1267 | '(menu-item "PCL-CVS" cvs-global-menu)) |
| 1268 | (define-key menu-bar-tools-menu [vc] nil) ;Create the place for the VC menu. |
| 1269 | |
| 1270 | (define-key menu-bar-tools-menu [separator-compare] |
| 1271 | '("--")) |
| 1272 | |
| 1273 | (define-key menu-bar-tools-menu [ediff-misc] |
| 1274 | '(menu-item "Ediff Miscellanea" menu-bar-ediff-misc-menu)) |
| 1275 | (define-key menu-bar-tools-menu [epatch] |
| 1276 | '(menu-item "Apply Patch" menu-bar-epatch-menu)) |
| 1277 | (define-key menu-bar-tools-menu [ediff-merge] |
| 1278 | '(menu-item "Merge" menu-bar-ediff-merge-menu)) |
| 1279 | (define-key menu-bar-tools-menu [compare] |
| 1280 | '(menu-item "Compare (Ediff)" menu-bar-ediff-menu)) |
| 1281 | |
| 1282 | (define-key menu-bar-tools-menu [separator-spell] |
| 1283 | '("--")) |
| 1284 | |
| 1285 | (define-key menu-bar-tools-menu [spell] |
| 1286 | '(menu-item "Spell Checking" ispell-menu-map)) |
| 1287 | |
| 1288 | (define-key menu-bar-tools-menu [separator-prog] |
| 1289 | '("--")) |
| 1290 | |
| 1291 | (define-key menu-bar-tools-menu [gdb] |
| 1292 | '(menu-item "Debugger (GDB)..." gdb |
| 1293 | :help "Debug a program from within Emacs with GDB")) |
| 1294 | (define-key menu-bar-tools-menu [shell-on-region] |
| 1295 | '(menu-item "Shell Command on Region..." shell-command-on-region |
| 1296 | :enable mark-active |
| 1297 | :help "Pass marked region to a shell command")) |
| 1298 | (define-key menu-bar-tools-menu [shell] |
| 1299 | '(menu-item "Shell Command..." shell-command |
| 1300 | :help "Invoke a shell command and catch its output")) |
| 1301 | (define-key menu-bar-tools-menu [compile] |
| 1302 | '(menu-item "Compile..." compile |
| 1303 | :help "Invoke compiler or Make, view compilation errors")) |
| 1304 | (define-key menu-bar-tools-menu [grep] |
| 1305 | '(menu-item "Search Files (Grep)..." grep |
| 1306 | :help "Search files for strings or regexps (with Grep)")) |
| 1307 | |
| 1308 | \f |
| 1309 | ;; The "Help" menu items |
| 1310 | |
| 1311 | (defvar menu-bar-describe-menu (make-sparse-keymap "Describe")) |
| 1312 | |
| 1313 | (define-key menu-bar-describe-menu [mule-diag] |
| 1314 | '(menu-item "Show All of Mule Status" mule-diag |
| 1315 | :visible default-enable-multibyte-characters |
| 1316 | :help "Display multilingual environment settings")) |
| 1317 | (define-key menu-bar-describe-menu [describe-coding-system-briefly] |
| 1318 | '(menu-item "Describe Coding System (Briefly)" |
| 1319 | describe-current-coding-system-briefly |
| 1320 | :visible default-enable-multibyte-characters)) |
| 1321 | (define-key menu-bar-describe-menu [describe-coding-system] |
| 1322 | '(menu-item "Describe Coding System..." describe-coding-system |
| 1323 | :visible default-enable-multibyte-characters)) |
| 1324 | (define-key menu-bar-describe-menu [describe-input-method] |
| 1325 | '(menu-item "Describe Input Method..." describe-input-method |
| 1326 | :visible default-enable-multibyte-characters |
| 1327 | :help "Keyboard layout for specific input method")) |
| 1328 | (define-key menu-bar-describe-menu [describe-language-environment] |
| 1329 | (list 'menu-item "Describe Language Environment" |
| 1330 | describe-language-environment-map)) |
| 1331 | |
| 1332 | (define-key menu-bar-describe-menu [separator-desc-mule] |
| 1333 | '("--")) |
| 1334 | |
| 1335 | (define-key menu-bar-describe-menu [list-keybindings] |
| 1336 | '(menu-item "List Key Bindings" describe-bindings |
| 1337 | :help "Display all current keybindings (keyboard shortcuts)")) |
| 1338 | (define-key menu-bar-describe-menu [describe-current-display-table] |
| 1339 | '(menu-item "Describe Display Table" describe-current-display-table |
| 1340 | :help "Describe the current display table")) |
| 1341 | (define-key menu-bar-describe-menu [describe-face] |
| 1342 | '(menu-item "Describe Face..." describe-face |
| 1343 | :help "Display the properties of a face")) |
| 1344 | (define-key menu-bar-describe-menu [describe-variable] |
| 1345 | '(menu-item "Describe Variable..." describe-variable |
| 1346 | :help "Display documentation of variable/option")) |
| 1347 | (define-key menu-bar-describe-menu [describe-function] |
| 1348 | '(menu-item "Describe Function..." describe-function |
| 1349 | :help "Display documentation of function/command")) |
| 1350 | (define-key menu-bar-describe-menu [describe-key-1] |
| 1351 | '(menu-item "Describe Key or Mouse Operation..." describe-key |
| 1352 | ;; Users typically don't identify keys and menu items... |
| 1353 | :help "Display documentation of command bound to a \ |
| 1354 | key, a click, or a menu-item")) |
| 1355 | (define-key menu-bar-describe-menu [describe-mode] |
| 1356 | '(menu-item "Describe Buffer Modes" describe-mode |
| 1357 | :help "Describe this buffer's major and minor mode")) |
| 1358 | |
| 1359 | (defvar menu-bar-search-documentation-menu |
| 1360 | (make-sparse-keymap "Search Documentation")) |
| 1361 | (defun menu-bar-read-lispref () |
| 1362 | "Display the Emacs Lisp Reference manual in Info mode." |
| 1363 | (interactive) |
| 1364 | (info "elisp")) |
| 1365 | |
| 1366 | (defun menu-bar-read-lispintro () |
| 1367 | "Display the Introduction to Emacs Lisp Programming in Info mode." |
| 1368 | (interactive) |
| 1369 | (info "eintr")) |
| 1370 | |
| 1371 | (defun search-emacs-glossary () |
| 1372 | "Display the Glossary node of the Emacs manual in Info mode." |
| 1373 | (interactive) |
| 1374 | (info "(emacs)Glossary")) |
| 1375 | |
| 1376 | (defun emacs-index-search (topic) |
| 1377 | "Look up TOPIC in the indices of the Emacs User Manual." |
| 1378 | (interactive "sSubject to look up: ") |
| 1379 | (info "emacs") |
| 1380 | (Info-index topic)) |
| 1381 | |
| 1382 | (defun elisp-index-search (topic) |
| 1383 | "Look up TOPIC in the indices of the Emacs Lisp Reference Manual." |
| 1384 | (interactive "sSubject to look up: ") |
| 1385 | (info "elisp") |
| 1386 | (Info-index topic)) |
| 1387 | |
| 1388 | (define-key menu-bar-search-documentation-menu [search-documentation-strings] |
| 1389 | '(menu-item "Search Documentation Strings..." apropos-documentation |
| 1390 | :help |
| 1391 | "Find functions and variables whose doc strings match a regexp")) |
| 1392 | (define-key menu-bar-search-documentation-menu [find-any-object-by-name] |
| 1393 | '(menu-item "Find Any Object by Name..." apropos |
| 1394 | :help "Find symbols of any kind whose names match a regexp")) |
| 1395 | (define-key menu-bar-search-documentation-menu [find-option-by-value] |
| 1396 | '(menu-item "Find Options by Value..." apropos-value |
| 1397 | :help "Find variables whose values match a regexp")) |
| 1398 | (define-key menu-bar-search-documentation-menu [find-options-by-name] |
| 1399 | '(menu-item "Find Options by Name..." apropos-variable |
| 1400 | :help "Find variables whose names match a regexp")) |
| 1401 | (define-key menu-bar-search-documentation-menu [find-commands-by-name] |
| 1402 | '(menu-item "Find Commands by Name..." apropos-command |
| 1403 | :help "Find commands whose names match a regexp")) |
| 1404 | (define-key menu-bar-search-documentation-menu [sep1] |
| 1405 | '("--")) |
| 1406 | (define-key menu-bar-search-documentation-menu [lookup-command-in-manual] |
| 1407 | '(menu-item "Look Up Command in User Manual..." Info-goto-emacs-command-node |
| 1408 | :help "Display manual section that describes a command")) |
| 1409 | (define-key menu-bar-search-documentation-menu [lookup-key-in-manual] |
| 1410 | '(menu-item "Look Up Key in User Manual..." Info-goto-emacs-key-command-node |
| 1411 | :help "Display manual section that describes a key")) |
| 1412 | (define-key menu-bar-search-documentation-menu [lookup-subject-in-elisp-manual] |
| 1413 | '(menu-item "Look Up Subject in ELisp Manual..." elisp-index-search |
| 1414 | :help "Find description of a subject in Emacs Lisp manual")) |
| 1415 | (define-key menu-bar-search-documentation-menu [lookup-subject-in-emacs-manual] |
| 1416 | '(menu-item "Look Up Subject in User Manual..." emacs-index-search |
| 1417 | :help "Find description of a subject in Emacs User manual")) |
| 1418 | (define-key menu-bar-search-documentation-menu [emacs-terminology] |
| 1419 | '(menu-item "Emacs Terminology" search-emacs-glossary |
| 1420 | :help "Display the Glossary section of the Emacs manual")) |
| 1421 | |
| 1422 | (defvar menu-bar-manuals-menu (make-sparse-keymap "More Manuals")) |
| 1423 | |
| 1424 | (define-key menu-bar-manuals-menu [man] |
| 1425 | '(menu-item "Read Man Page..." manual-entry |
| 1426 | :help "Man-page docs for external commands and libraries")) |
| 1427 | (define-key menu-bar-manuals-menu [sep2] |
| 1428 | '("--")) |
| 1429 | (define-key menu-bar-manuals-menu [order-emacs-manuals] |
| 1430 | '(menu-item "Ordering Manuals" view-order-manuals |
| 1431 | :help "How to order manuals from the Free Software Foundation")) |
| 1432 | (define-key menu-bar-manuals-menu [lookup-subject-in-all-manuals] |
| 1433 | '(menu-item "Lookup Subject in all manuals..." info-apropos |
| 1434 | :help "Find description of a subject in all installed manuals")) |
| 1435 | (define-key menu-bar-manuals-menu [other-manuals] |
| 1436 | '(menu-item "All Other Manuals (Info)" Info-directory |
| 1437 | :help "Read any of the installed manuals")) |
| 1438 | (define-key menu-bar-manuals-menu [emacs-lisp-reference] |
| 1439 | '(menu-item "Emacs Lisp Reference" menu-bar-read-lispref |
| 1440 | :help "Read the Emacs Lisp Reference manual")) |
| 1441 | (define-key menu-bar-manuals-menu [emac-lisp-intro] |
| 1442 | '(menu-item "Introduction to Emacs Lisp" menu-bar-read-lispintro |
| 1443 | :help "Read the Introduction to Emacs Lisp Programming")) |
| 1444 | |
| 1445 | (define-key menu-bar-help-menu [about-gnu-project] |
| 1446 | '(menu-item "About GNU" describe-gnu-project |
| 1447 | :help "About the GNU System, GNU Project, and GNU/Linux")) |
| 1448 | (define-key menu-bar-help-menu [about-emacs] |
| 1449 | '(menu-item "About Emacs" about-emacs |
| 1450 | :help "Display version number, copyright info, and basic help")) |
| 1451 | (define-key menu-bar-help-menu [sep4] |
| 1452 | '("--")) |
| 1453 | (define-key menu-bar-help-menu [describe-no-warranty] |
| 1454 | '(menu-item "(Non)Warranty" describe-no-warranty |
| 1455 | :help "Explain that Emacs has NO WARRANTY")) |
| 1456 | (define-key menu-bar-help-menu [describe-copying] |
| 1457 | '(menu-item "Copying Conditions" describe-copying |
| 1458 | :help "Show the Emacs license (GPL)")) |
| 1459 | (define-key menu-bar-help-menu [getting-new-versions] |
| 1460 | '(menu-item "Getting New Versions" describe-distribution |
| 1461 | :help "How to get latest versions of Emacs")) |
| 1462 | (defun menu-bar-help-extra-packages () |
| 1463 | "Display help about some additional packages available for Emacs." |
| 1464 | (interactive) |
| 1465 | (let (enable-local-variables) |
| 1466 | (view-file (expand-file-name "MORE.STUFF" |
| 1467 | data-directory)) |
| 1468 | (goto-address))) |
| 1469 | (define-key menu-bar-help-menu [sep2] |
| 1470 | '("--")) |
| 1471 | (define-key menu-bar-help-menu [external-packages] |
| 1472 | '(menu-item "External Packages" menu-bar-help-extra-packages |
| 1473 | :help "Lisp packages distributed separately for use in Emacs")) |
| 1474 | (define-key menu-bar-help-menu [find-emacs-packages] |
| 1475 | '(menu-item "Find Emacs Packages" finder-by-keyword |
| 1476 | :help "Find packages and features by keyword")) |
| 1477 | (define-key menu-bar-help-menu [more-manuals] |
| 1478 | (list 'menu-item "More Manuals" menu-bar-manuals-menu)) |
| 1479 | (define-key menu-bar-help-menu [emacs-manual] |
| 1480 | '(menu-item "Read the Emacs Manual" info-emacs-manual |
| 1481 | :help "Full documentation of Emacs features")) |
| 1482 | (define-key menu-bar-help-menu [describe] |
| 1483 | (list 'menu-item "Describe" menu-bar-describe-menu)) |
| 1484 | (define-key menu-bar-help-menu [search-documentation] |
| 1485 | (list 'menu-item "Search Documentation" menu-bar-search-documentation-menu)) |
| 1486 | (define-key menu-bar-help-menu [sep1] |
| 1487 | '("--")) |
| 1488 | (define-key menu-bar-help-menu [emacs-psychotherapist] |
| 1489 | '(menu-item "Emacs Psychotherapist" doctor |
| 1490 | :help "Our doctor will help you feel better")) |
| 1491 | (define-key menu-bar-help-menu [send-emacs-bug-report] |
| 1492 | '(menu-item "Send Bug Report..." report-emacs-bug |
| 1493 | :help "Send e-mail to Emacs maintainers")) |
| 1494 | (define-key menu-bar-help-menu [emacs-known-problems] |
| 1495 | '(menu-item "Emacs Known Problems" view-emacs-problems |
| 1496 | :help "Read about known problems with Emacs")) |
| 1497 | (define-key menu-bar-help-menu [emacs-news] |
| 1498 | '(menu-item "Emacs News" view-emacs-news |
| 1499 | :help "New features of this version")) |
| 1500 | (define-key menu-bar-help-menu [emacs-faq] |
| 1501 | '(menu-item "Emacs FAQ" view-emacs-FAQ |
| 1502 | :help "Frequently asked (and answered) questions about Emacs")) |
| 1503 | |
| 1504 | (defun help-with-tutorial-spec-language () |
| 1505 | "Use the Emacs tutorial, specifying which language you want." |
| 1506 | (interactive) |
| 1507 | (help-with-tutorial t)) |
| 1508 | |
| 1509 | (define-key menu-bar-help-menu [emacs-tutorial-language-specific] |
| 1510 | '(menu-item "Emacs Tutorial (choose language)..." |
| 1511 | help-with-tutorial-spec-language |
| 1512 | :help "Learn how to use Emacs (choose a language)")) |
| 1513 | (define-key menu-bar-help-menu [emacs-tutorial] |
| 1514 | '(menu-item "Emacs Tutorial" help-with-tutorial |
| 1515 | :help "Learn how to use Emacs")) |
| 1516 | |
| 1517 | (defun menu-bar-menu-frame-live-and-visible-p () |
| 1518 | "Return non-nil if the menu frame is alive and visible. |
| 1519 | The menu frame is the frame for which we are updating the menu." |
| 1520 | (let ((menu-frame (or menu-updating-frame (selected-frame)))) |
| 1521 | (and (frame-live-p menu-frame) |
| 1522 | (frame-visible-p menu-frame)))) |
| 1523 | |
| 1524 | (defun menu-bar-non-minibuffer-window-p () |
| 1525 | "Return non-nil if selected window of the menu frame is not a minibuf window. |
| 1526 | |
| 1527 | See the documentation of `menu-bar-menu-frame-live-and-visible-p' |
| 1528 | for the definition of the menu frame." |
| 1529 | (let ((menu-frame (or menu-updating-frame (selected-frame)))) |
| 1530 | (not (window-minibuffer-p (frame-selected-window menu-frame))))) |
| 1531 | |
| 1532 | (defun kill-this-buffer () ; for the menu bar |
| 1533 | "Kill the current buffer. |
| 1534 | When called in the minibuffer, get out of the minibuffer |
| 1535 | using `abort-recursive-edit'." |
| 1536 | (interactive) |
| 1537 | (if (menu-bar-non-minibuffer-window-p) |
| 1538 | (kill-buffer (current-buffer)) |
| 1539 | (abort-recursive-edit))) |
| 1540 | |
| 1541 | (defun kill-this-buffer-enabled-p () |
| 1542 | (let ((count 0) |
| 1543 | (buffers (buffer-list))) |
| 1544 | (while buffers |
| 1545 | (or (string-match "^ " (buffer-name (car buffers))) |
| 1546 | (setq count (1+ count))) |
| 1547 | (setq buffers (cdr buffers))) |
| 1548 | (or (not (menu-bar-non-minibuffer-window-p)) |
| 1549 | (> count 1)))) |
| 1550 | |
| 1551 | (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p)) |
| 1552 | |
| 1553 | ;; Permit deleting frame if it would leave a visible or iconified frame. |
| 1554 | (defun delete-frame-enabled-p () |
| 1555 | "Return non-nil if `delete-frame' should be enabled in the menu bar." |
| 1556 | (let ((frames (frame-list)) |
| 1557 | (count 0)) |
| 1558 | (while frames |
| 1559 | (if (frame-visible-p (car frames)) |
| 1560 | (setq count (1+ count))) |
| 1561 | (setq frames (cdr frames))) |
| 1562 | (> count 1))) |
| 1563 | |
| 1564 | (defcustom yank-menu-length 20 |
| 1565 | "*Maximum length to display in the yank-menu." |
| 1566 | :type 'integer |
| 1567 | :group 'menu) |
| 1568 | |
| 1569 | (defun menu-bar-update-yank-menu (string old) |
| 1570 | (let ((front (car (cdr yank-menu))) |
| 1571 | (menu-string (if (<= (length string) yank-menu-length) |
| 1572 | string |
| 1573 | (concat |
| 1574 | (substring string 0 (/ yank-menu-length 2)) |
| 1575 | "..." |
| 1576 | (substring string (- (/ yank-menu-length 2))))))) |
| 1577 | ;; Don't let the menu string be all dashes |
| 1578 | ;; because that has a special meaning in a menu. |
| 1579 | (if (string-match "\\`-+\\'" menu-string) |
| 1580 | (setq menu-string (concat menu-string " "))) |
| 1581 | ;; If we're supposed to be extending an existing string, and that |
| 1582 | ;; string really is at the front of the menu, then update it in place. |
| 1583 | (if (and old (or (eq old (car front)) |
| 1584 | (string= old (car front)))) |
| 1585 | (progn |
| 1586 | (setcar front string) |
| 1587 | (setcar (cdr front) menu-string)) |
| 1588 | (setcdr yank-menu |
| 1589 | (cons |
| 1590 | (cons string (cons menu-string 'menu-bar-select-yank)) |
| 1591 | (cdr yank-menu))))) |
| 1592 | (if (> (length (cdr yank-menu)) kill-ring-max) |
| 1593 | (setcdr (nthcdr kill-ring-max yank-menu) nil))) |
| 1594 | |
| 1595 | (put 'menu-bar-select-yank 'apropos-inhibit t) |
| 1596 | (defun menu-bar-select-yank () |
| 1597 | "Insert the stretch of previously-killed text selected from menu. |
| 1598 | The menu shows all the killed text sequences stored in `kill-ring'." |
| 1599 | (interactive "*") |
| 1600 | (push-mark (point)) |
| 1601 | (insert last-command-event)) |
| 1602 | |
| 1603 | \f |
| 1604 | ;;; Buffers Menu |
| 1605 | |
| 1606 | (defcustom buffers-menu-max-size 10 |
| 1607 | "*Maximum number of entries which may appear on the Buffers menu. |
| 1608 | If this is 10, then only the ten most-recently-selected buffers are shown. |
| 1609 | If this is nil, then all buffers are shown. |
| 1610 | A large number or nil slows down menu responsiveness." |
| 1611 | :type '(choice integer |
| 1612 | (const :tag "All" nil)) |
| 1613 | :group 'menu) |
| 1614 | |
| 1615 | (defcustom buffers-menu-buffer-name-length 30 |
| 1616 | "*Maximum length of the buffer name on the Buffers menu. |
| 1617 | If this is a number, then buffer names are truncated to this length. |
| 1618 | If this is nil, then buffer names are shown in full. |
| 1619 | A large number or nil makes the menu too wide." |
| 1620 | :type '(choice integer |
| 1621 | (const :tag "Full length" nil)) |
| 1622 | :group 'menu) |
| 1623 | |
| 1624 | (defcustom buffers-menu-show-directories 'unless-uniquify |
| 1625 | "If non-nil, show directories in the Buffers menu for buffers that have them. |
| 1626 | The special value `unless-uniquify' means that directories will be shown |
| 1627 | unless `uniquify-buffer-name-style' is non-nil (in which case, buffer |
| 1628 | names should include enough of a buffer's directory to distinguish it |
| 1629 | from other buffers). |
| 1630 | |
| 1631 | Setting this variable directly does not take effect until next time the |
| 1632 | Buffers menu is regenerated." |
| 1633 | :set (lambda (symbol value) |
| 1634 | (set symbol value) |
| 1635 | (menu-bar-update-buffers t)) |
| 1636 | :initialize 'custom-initialize-default |
| 1637 | :type '(choice (const :tag "Never" nil) |
| 1638 | (const :tag "Unless uniquify is enabled" unless-uniquify) |
| 1639 | (const :tag "Always" t)) |
| 1640 | :group 'menu) |
| 1641 | |
| 1642 | (defcustom buffers-menu-show-status t |
| 1643 | "If non-nil, show modified/read-only status of buffers in the Buffers menu. |
| 1644 | Setting this variable directly does not take effect until next time the |
| 1645 | Buffers menu is regenerated." |
| 1646 | :set (lambda (symbol value) |
| 1647 | (set symbol value) |
| 1648 | (menu-bar-update-buffers t)) |
| 1649 | :initialize 'custom-initialize-default |
| 1650 | :type 'boolean |
| 1651 | :group 'menu) |
| 1652 | |
| 1653 | (defvar list-buffers-directory nil) |
| 1654 | |
| 1655 | (defun menu-bar-select-buffer () |
| 1656 | (interactive) |
| 1657 | (switch-to-buffer last-command-event)) |
| 1658 | |
| 1659 | (defun menu-bar-select-frame (frame) |
| 1660 | (make-frame-visible frame) |
| 1661 | (raise-frame frame) |
| 1662 | (select-frame frame)) |
| 1663 | |
| 1664 | (defun menu-bar-update-buffers-1 (elt) |
| 1665 | (let* ((buf (car elt)) |
| 1666 | (file |
| 1667 | (and (if (eq buffers-menu-show-directories 'unless-uniquify) |
| 1668 | (or (not (boundp 'uniquify-buffer-name-style)) |
| 1669 | (null uniquify-buffer-name-style)) |
| 1670 | buffers-menu-show-directories) |
| 1671 | (or (buffer-file-name buf) |
| 1672 | (buffer-local-value 'list-buffers-directory buf))))) |
| 1673 | (when file |
| 1674 | (setq file (file-name-directory file))) |
| 1675 | (when (and file (> (length file) 20)) |
| 1676 | (setq file (concat "..." (substring file -17)))) |
| 1677 | (cons (if buffers-menu-show-status |
| 1678 | (let ((mod (if (buffer-modified-p buf) "*" "")) |
| 1679 | (ro (if (buffer-local-value 'buffer-read-only buf) "%" ""))) |
| 1680 | (if file |
| 1681 | (format "%s %s%s -- %s" (cdr elt) mod ro file) |
| 1682 | (format "%s %s%s" (cdr elt) mod ro))) |
| 1683 | (if file |
| 1684 | (format "%s -- %s" (cdr elt) file) |
| 1685 | (cdr elt))) |
| 1686 | buf))) |
| 1687 | |
| 1688 | ;; Used to cache the menu entries for commands in the Buffers menu |
| 1689 | (defvar menu-bar-buffers-menu-command-entries nil) |
| 1690 | |
| 1691 | (defun menu-bar-update-buffers (&optional force) |
| 1692 | ;; If user discards the Buffers item, play along. |
| 1693 | (and (lookup-key (current-global-map) [menu-bar buffer]) |
| 1694 | (or force (frame-or-buffer-changed-p)) |
| 1695 | (let ((buffers (buffer-list)) |
| 1696 | (frames (frame-list)) |
| 1697 | buffers-menu) |
| 1698 | ;; If requested, list only the N most recently selected buffers. |
| 1699 | (if (and (integerp buffers-menu-max-size) |
| 1700 | (> buffers-menu-max-size 1)) |
| 1701 | (if (> (length buffers) buffers-menu-max-size) |
| 1702 | (setcdr (nthcdr buffers-menu-max-size buffers) nil))) |
| 1703 | |
| 1704 | ;; Make the menu of buffers proper. |
| 1705 | (setq buffers-menu |
| 1706 | (let (alist) |
| 1707 | ;; Put into each element of buffer-list |
| 1708 | ;; the name for actual display, |
| 1709 | ;; perhaps truncated in the middle. |
| 1710 | (dolist (buf buffers) |
| 1711 | (let ((name (buffer-name buf))) |
| 1712 | (unless (eq ?\s (aref name 0)) |
| 1713 | (push (menu-bar-update-buffers-1 |
| 1714 | (cons buf |
| 1715 | (if (and (integerp buffers-menu-buffer-name-length) |
| 1716 | (> (length name) buffers-menu-buffer-name-length)) |
| 1717 | (concat |
| 1718 | (substring |
| 1719 | name 0 (/ buffers-menu-buffer-name-length 2)) |
| 1720 | "..." |
| 1721 | (substring |
| 1722 | name (- (/ buffers-menu-buffer-name-length 2)))) |
| 1723 | name) |
| 1724 | )) |
| 1725 | alist)))) |
| 1726 | ;; Now make the actual list of items. |
| 1727 | (let ((buffers-vec (make-vector (length alist) nil)) |
| 1728 | (i (length alist))) |
| 1729 | (dolist (pair alist) |
| 1730 | (setq i (1- i)) |
| 1731 | (aset buffers-vec i |
| 1732 | (nconc (list (car pair) |
| 1733 | (cons nil nil)) |
| 1734 | `(lambda () |
| 1735 | (interactive) |
| 1736 | (switch-to-buffer ,(cdr pair)))))) |
| 1737 | (list buffers-vec)))) |
| 1738 | |
| 1739 | ;; Make a Frames menu if we have more than one frame. |
| 1740 | (when (cdr frames) |
| 1741 | (let* ((frames-vec (make-vector (length frames) nil)) |
| 1742 | (frames-menu |
| 1743 | (cons 'keymap |
| 1744 | (list "Select Frame" frames-vec))) |
| 1745 | (i 0)) |
| 1746 | (dolist (frame frames) |
| 1747 | (aset frames-vec i |
| 1748 | (nconc |
| 1749 | (list |
| 1750 | (frame-parameter frame 'name) |
| 1751 | (cons nil nil)) |
| 1752 | `(lambda () |
| 1753 | (interactive) (menu-bar-select-frame ,frame)))) |
| 1754 | (setq i (1+ i))) |
| 1755 | ;; Put it after the normal buffers |
| 1756 | (setq buffers-menu |
| 1757 | (nconc buffers-menu |
| 1758 | `((frames-separator "--") |
| 1759 | (frames menu-item "Frames" ,frames-menu)))))) |
| 1760 | |
| 1761 | ;; Add in some normal commands at the end of the menu. We use |
| 1762 | ;; the copy cached in `menu-bar-buffers-menu-command-entries' |
| 1763 | ;; if it's been set already. Note that we can't use constant |
| 1764 | ;; lists for the menu-entries, because the low-level menu-code |
| 1765 | ;; modifies them. |
| 1766 | (unless menu-bar-buffers-menu-command-entries |
| 1767 | (setq menu-bar-buffers-menu-command-entries |
| 1768 | (list '(command-separator "--") |
| 1769 | (list 'next-buffer |
| 1770 | 'menu-item |
| 1771 | "Next Buffer" |
| 1772 | 'next-buffer |
| 1773 | :help "Switch to the \"next\" buffer in a cyclic order") |
| 1774 | (list 'previous-buffer |
| 1775 | 'menu-item |
| 1776 | "Previous Buffer" |
| 1777 | 'previous-buffer |
| 1778 | :help "Switch to the \"previous\" buffer in a cyclic order") |
| 1779 | (list 'select-named-buffer |
| 1780 | 'menu-item |
| 1781 | "Select Named Buffer..." |
| 1782 | 'switch-to-buffer |
| 1783 | :help "Prompt for a buffer name, and select that buffer in the current window") |
| 1784 | (list 'list-all-buffers |
| 1785 | 'menu-item |
| 1786 | "List All Buffers" |
| 1787 | 'list-buffers |
| 1788 | :help "Pop up a window listing all Emacs buffers" |
| 1789 | )))) |
| 1790 | (setq buffers-menu |
| 1791 | (nconc buffers-menu menu-bar-buffers-menu-command-entries)) |
| 1792 | |
| 1793 | ;; We used to "(define-key (current-global-map) [menu-bar buffer]" |
| 1794 | ;; but that did not do the right thing when the [menu-bar buffer] |
| 1795 | ;; entry above had been moved (e.g. to a parent keymap). |
| 1796 | (setcdr global-buffers-menu-map (cons "Select Buffer" buffers-menu))))) |
| 1797 | |
| 1798 | (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers) |
| 1799 | |
| 1800 | (menu-bar-update-buffers) |
| 1801 | |
| 1802 | ;; this version is too slow |
| 1803 | ;;(defun format-buffers-menu-line (buffer) |
| 1804 | ;; "Returns a string to represent the given buffer in the Buffer menu. |
| 1805 | ;;nil means the buffer shouldn't be listed. You can redefine this." |
| 1806 | ;; (if (string-match "\\` " (buffer-name buffer)) |
| 1807 | ;; nil |
| 1808 | ;; (save-excursion |
| 1809 | ;; (set-buffer buffer) |
| 1810 | ;; (let ((size (buffer-size))) |
| 1811 | ;; (format "%s%s %-19s %6s %-15s %s" |
| 1812 | ;; (if (buffer-modified-p) "*" " ") |
| 1813 | ;; (if buffer-read-only "%" " ") |
| 1814 | ;; (buffer-name) |
| 1815 | ;; size |
| 1816 | ;; mode-name |
| 1817 | ;; (or (buffer-file-name) "")))))) |
| 1818 | \f |
| 1819 | ;;; Set up a menu bar menu for the minibuffer. |
| 1820 | |
| 1821 | (dolist (map (list minibuffer-local-map |
| 1822 | ;; This shouldn't be necessary, but there's a funny |
| 1823 | ;; bug in keymap.c that I don't understand yet. -stef |
| 1824 | minibuffer-local-completion-map)) |
| 1825 | (define-key map [menu-bar minibuf] |
| 1826 | (cons "Minibuf" (make-sparse-keymap "Minibuf")))) |
| 1827 | |
| 1828 | (let ((map minibuffer-local-completion-map)) |
| 1829 | (define-key map [menu-bar minibuf ?\?] |
| 1830 | (list 'menu-item "List Completions" 'minibuffer-completion-help |
| 1831 | :help "Display all possible completions")) |
| 1832 | (define-key map [menu-bar minibuf space] |
| 1833 | (list 'menu-item "Complete Word" 'minibuffer-complete-word |
| 1834 | :help "Complete at most one word")) |
| 1835 | (define-key map [menu-bar minibuf tab] |
| 1836 | (list 'menu-item "Complete" 'minibuffer-complete |
| 1837 | :help "Complete as far as possible"))) |
| 1838 | |
| 1839 | (let ((map minibuffer-local-map)) |
| 1840 | (define-key map [menu-bar minibuf quit] |
| 1841 | (list 'menu-item "Quit" 'abort-recursive-edit |
| 1842 | :help "Abort input and exit minibuffer")) |
| 1843 | (define-key map [menu-bar minibuf return] |
| 1844 | (list 'menu-item "Enter" 'exit-minibuffer |
| 1845 | :key-sequence "\r" |
| 1846 | :help "Terminate input and exit minibuffer")) |
| 1847 | (define-key map [menu-bar minibuf isearch-forward] |
| 1848 | (list 'menu-item "Isearch History Forward" 'isearch-forward |
| 1849 | :help "Incrementally search minibuffer history forward")) |
| 1850 | (define-key map [menu-bar minibuf isearch-backward] |
| 1851 | (list 'menu-item "Isearch History Backward" 'isearch-backward |
| 1852 | :help "Incrementally search minibuffer history backward")) |
| 1853 | (define-key map [menu-bar minibuf next] |
| 1854 | (list 'menu-item "Next History Item" 'next-history-element |
| 1855 | :help "Put next minibuffer history element in the minibuffer")) |
| 1856 | (define-key map [menu-bar minibuf previous] |
| 1857 | (list 'menu-item "Previous History Item" 'previous-history-element |
| 1858 | :help "Put previous minibuffer history element in the minibuffer"))) |
| 1859 | \f |
| 1860 | ;;;###autoload |
| 1861 | ;; This comment is taken from tool-bar.el near |
| 1862 | ;; (put 'tool-bar-mode ...) |
| 1863 | ;; We want to pretend the menu bar by standard is on, as this will make |
| 1864 | ;; customize consider disabling the menu bar a customization, and save |
| 1865 | ;; that. We could do this for real by setting :init-value below, but |
| 1866 | ;; that would overwrite disabling the tool bar from X resources. |
| 1867 | (put 'menu-bar-mode 'standard-value '(t)) |
| 1868 | |
| 1869 | (define-minor-mode menu-bar-mode |
| 1870 | "Toggle display of a menu bar on each frame. |
| 1871 | This command applies to all frames that exist and frames to be |
| 1872 | created in the future. |
| 1873 | With a numeric argument, if the argument is positive, |
| 1874 | turn on menu bars; otherwise, turn off menu bars." |
| 1875 | :init-value nil |
| 1876 | :global t |
| 1877 | :group 'frames |
| 1878 | |
| 1879 | ;; Make menu-bar-mode and default-frame-alist consistent. |
| 1880 | (modify-all-frames-parameters (list (cons 'menu-bar-lines |
| 1881 | (if menu-bar-mode 1 0)))) |
| 1882 | |
| 1883 | ;; Make the message appear when Emacs is idle. We can not call message |
| 1884 | ;; directly. The minor-mode message "Menu-bar mode disabled" comes |
| 1885 | ;; after this function returns, overwriting any message we do here. |
| 1886 | (when (and (interactive-p) (not menu-bar-mode)) |
| 1887 | (run-with-idle-timer 0 nil 'message |
| 1888 | "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")) |
| 1889 | menu-bar-mode) |
| 1890 | |
| 1891 | (defun toggle-menu-bar-mode-from-frame (&optional arg) |
| 1892 | "Toggle menu bar on or off, based on the status of the current frame. |
| 1893 | See `menu-bar-mode' for more information." |
| 1894 | (interactive (list (or current-prefix-arg 'toggle))) |
| 1895 | (if (eq arg 'toggle) |
| 1896 | (menu-bar-mode (if (> (frame-parameter nil 'menu-bar-lines) 0) 0 1)) |
| 1897 | (menu-bar-mode arg))) |
| 1898 | |
| 1899 | (declare-function x-menu-bar-open "term/x-win" (&optional frame)) |
| 1900 | |
| 1901 | (defun menu-bar-open (&optional frame) |
| 1902 | "Start key navigation of the menu bar in FRAME. |
| 1903 | |
| 1904 | This function decides which method to use to access the menu |
| 1905 | depending on FRAME's terminal device. On X displays, it calls |
| 1906 | `x-menu-bar-open'; otherwise it calls `tmm-menubar'. |
| 1907 | |
| 1908 | If FRAME is nil or not given, use the selected frame." |
| 1909 | (interactive) |
| 1910 | (if (eq window-system 'x) |
| 1911 | (x-menu-bar-open frame) |
| 1912 | (with-selected-frame (or frame (selected-frame)) |
| 1913 | (tmm-menubar)))) |
| 1914 | |
| 1915 | (global-set-key [f10] 'menu-bar-open) |
| 1916 | |
| 1917 | (provide 'menu-bar) |
| 1918 | |
| 1919 | ;; arch-tag: 6e6a3c22-4ec4-4d3d-8190-583f8ef94ced |
| 1920 | ;;; menu-bar.el ends here |