all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* easy-menu / remove dividers from menu -> fails...
@ 2005-05-26  7:49 David Reitter
  2005-05-26 16:36 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: David Reitter @ 2005-05-26  7:49 UTC (permalink / raw)


How do I delete divider bars from a menu?
Deleting normal items works, deleting the divider bar doesn't:

(easy-menu-remove-item global-map  '("menu-bar" "file") 'exit- 
emacs)    ; works
(easy-menu-remove-item global-map  '("menu-bar" "file") 'separator- 
exit) ; doesn't work

The latter just doesn't do anything.

Your help would be appreciated!

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

* RE: easy-menu / remove dividers from menu -> fails...
  2005-05-26  7:49 David Reitter
@ 2005-05-26 16:36 ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2005-05-26 16:36 UTC (permalink / raw)


    How do I delete divider bars from a menu?
    Deleting normal items works, deleting the divider bar doesn't:
    
    (easy-menu-remove-item global-map  '("menu-bar" "file") 'exit- 
    emacs)    ; works
    (easy-menu-remove-item global-map  '("menu-bar" "file") 'separator- 
    exit) ; doesn't work
    
    The latter just doesn't do anything.
        
This may not be the kosher or easy-menu way to do it, but...

 (global-unset-key [menu-bar files separator-exit])

A question would be: "Why doesn't easy-menu-remove do the job?"

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

* Re: easy-menu / remove dividers from menu -> fails...
       [not found] <mailman.1868.1117094342.25862.help-gnu-emacs@gnu.org>
  2005-05-26 17:29 ` easy-menu / remove dividers from menu -> fails Stefan Monnier
@ 2005-05-26 17:29 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2005-05-26 17:29 UTC (permalink / raw)
  Cc: emacs-devel

The following message is a courtesy copy of an article
that has been posted to gnu.emacs.help as well.

> How do I delete divider bars from a menu?
> Deleting normal items works, deleting the divider bar doesn't:

> (easy-menu-remove-item global-map '("menu-bar" "file") 'exit-emacs)    ;works
> (easy-menu-remove-item global-map '("menu-bar" "file") 'separator-exit);doesn't work

> The latter just doesn't do anything.

The problem is a bug in easy-menu.
The patch below fixes it in your case.


        Stefan


--- orig/lisp/emacs-lisp/easymenu.el
+++ mod/lisp/emacs-lisp/easymenu.el
@@ -549,7 +549,14 @@
   "In menu MENU try to look for menu item with name NAME.
 If a menu item is found, return (NAME . item), otherwise return nil.
 If item is an old format item, a new format item is returned."
-  (let ((item (lookup-key menu (vector (easy-menu-intern name))))
+  ;; The call to `lookup-key' also calls the C function `get_keyelt' which
+  ;; looks inside a menu-item to only return the actual command.  This is
+  ;; not what we want here.  We should either add an arg to lookup-key to be
+  ;; able to turn off this "feature", or else we could use map-keymap here.
+  ;; In the mean time, I just use `assq' which is an OK approximation since
+  ;; menus are rarely built from vectors or char-tables.
+  (let ((item (or (cdr (assq name menu))
+                  (lookup-key menu (vector (easy-menu-intern name)))))
 	ret enable cache label)
     (cond
      ((stringp (car-safe item))

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

* Re: easy-menu / remove dividers from menu -> fails...
       [not found] <mailman.1868.1117094342.25862.help-gnu-emacs@gnu.org>
@ 2005-05-26 17:29 ` Stefan Monnier
  2005-05-26 17:29 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2005-05-26 17:29 UTC (permalink / raw)


> How do I delete divider bars from a menu?
> Deleting normal items works, deleting the divider bar doesn't:

> (easy-menu-remove-item global-map '("menu-bar" "file") 'exit-emacs)    ;works
> (easy-menu-remove-item global-map '("menu-bar" "file") 'separator-exit);doesn't work

> The latter just doesn't do anything.

The problem is a bug in easy-menu.
The patch below fixes it in your case.


        Stefan


--- orig/lisp/emacs-lisp/easymenu.el
+++ mod/lisp/emacs-lisp/easymenu.el
@@ -549,7 +549,14 @@
   "In menu MENU try to look for menu item with name NAME.
 If a menu item is found, return (NAME . item), otherwise return nil.
 If item is an old format item, a new format item is returned."
-  (let ((item (lookup-key menu (vector (easy-menu-intern name))))
+  ;; The call to `lookup-key' also calls the C function `get_keyelt' which
+  ;; looks inside a menu-item to only return the actual command.  This is
+  ;; not what we want here.  We should either add an arg to lookup-key to be
+  ;; able to turn off this "feature", or else we could use map-keymap here.
+  ;; In the mean time, I just use `assq' which is an OK approximation since
+  ;; menus are rarely built from vectors or char-tables.
+  (let ((item (or (cdr (assq name menu))
+                  (lookup-key menu (vector (easy-menu-intern name)))))
 	ret enable cache label)
     (cond
      ((stringp (car-safe item))

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

end of thread, other threads:[~2005-05-26 17:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1868.1117094342.25862.help-gnu-emacs@gnu.org>
2005-05-26 17:29 ` easy-menu / remove dividers from menu -> fails Stefan Monnier
2005-05-26 17:29 ` Stefan Monnier
2005-05-26  7:49 David Reitter
2005-05-26 16:36 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.