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

Adding Items to the Middle of a Menu



specht@cogpsy.Uni-Trier.de (Marcus Specht) writes:
> I have the same problem with the menu-items in a menu:
> (add-menu-items ... only adds them at the bottom, is there a way to add new
> menu-items at any place in the menu?

Here's one way to do it. This routine adds a menu item to position n
in an existing menu. I suspect a similar approach might do the job
for adding menus to the middle of the menu bar, but I haven't tried
that.

(defun install-item-at (menu item n)
  "Add a new menu item in menu at position n."
  (let ((afteritems (nthcdr (- n 1) (menu-items menu))))
    (when afteritems
      (apply #'remove-menu-items menu afteritems))
    (apply #'add-menu-items menu item afteritems)))

(install-item-at *file-menu* your-new-item 10) ; put it just after the
; Revert item

 -- 
Shannon Spires
Internet: svspire@sandia.gov
Voice: 505-844-4287
Fax: 505-844-3296