help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: New menu creation


From: Drew Adams
Subject: RE: New menu creation
Date: Thu, 27 May 2010 07:21:15 -0700

> I am very new to Emacs. I am trying to create a new menu in 
> the menu bar. How do I proceed?

Here is one way. Paste this text in a new file `mine.el', save it, and do `M-x
load-file RET mine.el'. (`M-x' means `ALT-x'.)

;; 1. Define a keymap variable:
(defvar my-menu (make-sparse-keymap "My Great Menu"))

;; 2. Put it on the menu bar:
(define-key global-map [menu-bar mine] (cons "Mine" my-menu))

;; 3. Add menu items:
(define-key my-menu [my-cmd1]
 '(menu-item "Command Uno" my-cmd1 :help "My first command"))
(define-key my-menu [forward-char]
 '(menu-item "Command Duo" my-cmd1 :help "Move forward one char"))

...

Alternatively, skip defining a variable (step #1) and just define everything
directly wrt the `global-map':

(define-key global-map [menu-bar mine]
 (cons "Mine" (make-sparse-keymap "My Great Menu")))

(define-key global-map [menu-bar mine my-cmd1]
 '(menu-item "Command Uno" my-cmd1 :help "My first command"))

...

> I downloaded the source and I see a lot of .el files under the lisp
> directory. Do I create a new file there? How do I link it?

No. Put the file in any directory you like, then add that directory to your
`load-path':

(add-to-list 'load-path "/my/directory/for/my/lisp/") 

> Please let me know if there are any links or info that I can follow.

* `C-h i', then choose Elisp, for the Emacs-Lisp manual. Then `i', type `menu',
and hit `TAB'. You'll see the manual pages about the menus. Choose the
completion candidate `menu bar' by typing ` bar' and hitting `RET'. That takes
you to the manual page (node) `Menu Bar'. Read.

* Google `emacs wiki' and pick the first search hit: `EmacsWiki: Site Map'.
Search there for `menu bar'. Pick the first search hit: `EmacsWiki: Menu Bar'.
You are here: http://www.emacswiki.org/emacs/MenuBar. Read. Explore the wiki for
more.

HTH.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]