unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* New menu creation
@ 2010-05-26 20:32 supreet
  2010-05-27 14:21 ` Drew Adams
  2010-05-27 14:47 ` Tassilo Horn
  0 siblings, 2 replies; 4+ messages in thread
From: supreet @ 2010-05-26 20:32 UTC (permalink / raw)
  To: Help-gnu-emacs


Hi All,

I am very new to Emacs. I am trying to create a new menu in the menu bar.
How do I proceed?
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?
Please let me know if there are any links or info that I can follow.

Thanks,
Supreet
-- 
View this message in context: http://old.nabble.com/New-menu-creation-tp28685978p28685978.html
Sent from the Emacs - Help mailing list archive at Nabble.com.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: New menu creation
  2010-05-26 20:32 New menu creation supreet
@ 2010-05-27 14:21 ` Drew Adams
  2010-06-01 20:09   ` supreet
  2010-05-27 14:47 ` Tassilo Horn
  1 sibling, 1 reply; 4+ messages in thread
From: Drew Adams @ 2010-05-27 14:21 UTC (permalink / raw)
  To: 'supreet', Help-gnu-emacs

> 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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New menu creation
  2010-05-26 20:32 New menu creation supreet
  2010-05-27 14:21 ` Drew Adams
@ 2010-05-27 14:47 ` Tassilo Horn
  1 sibling, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2010-05-27 14:47 UTC (permalink / raw)
  To: help-gnu-emacs

supreet <supreet.prasad@gmail.com> writes:

Hi!

> I am very new to Emacs. I am trying to create a new menu in the menu bar.
> How do I proceed?
> I downloaded the source and I see a lot of .el files under the lisp
> directory. Do I create a new file there?

No, you can do that by placing some code into your ~/.emacs file.  No
need to modify the emacs source code.

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

Have a look at the documentation:

,----[ (info "(elisp)Menu Bar") ]
|      ;; Make a menu keymap (with a prompt string)
|      ;; and make it the menu bar item's definition.
|      (define-key global-map [menu-bar words]
|        (cons "Words" (make-sparse-keymap "Words")))
| 
|      ;; Define specific subcommands in this menu.
|      (define-key global-map
|        [menu-bar words forward]
|        '("Forward word" . forward-word))
|      (define-key global-map
|        [menu-bar words backward]
|        '("Backward word" . backward-word))
`----

To jump to this documentation page inside emacs, put the boxquote
heading

  (info "(elisp)Menu Bar")

into emacs' *scratch* buffer and hit `C-x C-e' after the last closing
paren.

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: New menu creation
  2010-05-27 14:21 ` Drew Adams
@ 2010-06-01 20:09   ` supreet
  0 siblings, 0 replies; 4+ messages in thread
From: supreet @ 2010-06-01 20:09 UTC (permalink / raw)
  To: Help-gnu-emacs


Hi,

Thank you very much for all the info. It really helped.
the answers to my questions were so precise. Thanks once again for taking
your time.

Supreet



Drew Adams wrote:
> 
>> 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.
> 
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/New-menu-creation-tp28685978p28746877.html
Sent from the Emacs - Help mailing list archive at Nabble.com.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-06-01 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 20:32 New menu creation supreet
2010-05-27 14:21 ` Drew Adams
2010-06-01 20:09   ` supreet
2010-05-27 14:47 ` Tassilo Horn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).