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

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

Adding a popup menu option to close the current buffer


From: Paul G. Gardner
Subject: Adding a popup menu option to close the current buffer
Date: 22 Jan 2004 18:10:19 -0800

I've got EMACS v21.3.1 and I've added EMacro to the start up. 
Everything is fine until I tried to add a menu item to the default
popup menu.  For some reason, I am unable to do so, and I'm not sure
why.  I'm not very familiar with ELisp (used it in college for a year,
but that's it) so I'm assuming that's the problem.

Here is the code:
In EMacro, here is the relavant parts of the definition of the popup
menu.
;;_________________________________________________________________________(defvar
right-popup-menu
  (let ((menu (make-sparse-keymap "Commands")))
    (define-key menu [dabbrev-expand] (cons "Complete word"
'dabbrev-expand))
    (define-key menu [undo] (cons "Undo" 'undo))
    (define-key menu [redo] (cons "Redo" 'redo))

    (define-key menu [--] (cons "--" 'nil)) ;separator
 
    (define-key menu [menu-paste] (cons "Paste" 'yank))
    (define-key menu [menu-copy] (cons "Copy" 'copy-region-as-kill))
    (define-key menu [menu-cut] (cons "Cut" 'kill-region))

    (define-key menu [-] (cons "-" 'nil)) ;separator
    (define-key menu [emacro-help]
      (cons (concat (concat "EMacro v" emacro-version) " help")
'emacro-help))
    menu))

(defun right-popup() "Run the command selected from
`right-popup-menu'."
  (interactive)
  (call-interactively (or (car (x-popup-menu t right-popup-menu))
'ignore)))

(global-set-key [mouse-3] 'right-popup)
;;_________________________________________________________________________


I've tried to add the following:
    (define-key menu [menu-close-buffer] ( cons "Close-buffer" 
'kill-this-buffer))

both in the the original definition, and separately ('menu' replaced
by 'right-popup-menu').  However, while I don't receive any errors,
when I select the option, which does show up, all I get is a beep, and
the buffer stays open.

Can someone point me in the right direction?  I've tried to read the
manuals, but keep getting stumped.

Thanks!
Paul


reply via email to

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