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

Re: A user menu in the wrong position

>>>>> In [emacs-w3m : No.09152] Leo wrote:

> I have defined a menu to display in global menu map as follows.

> ,----
>| (easy-menu-define sdl:user-utils-menu nil "User utilities menu."
>|   '("Add-On"
>|     ["BBDB" bbdb :visible (fboundp 'bbdb)]
>|     ["W3M" w3m :visible (fboundp 'w3m)]
>|     ["Slime" slime :visible (fboundp 'slime)]))
>| (define-key-after
>|   (lookup-key global-map [menu-bar])
>|   [user-utils]
>|   (cons "Utils" sdl:user-utils-menu))
> `----

> In w3m, this menu will be place after the "Help" menu while in all
> other modes it is placed after "Tools" menu. I am wondering if w3m is
> doing something funny.

It is because the value of the `menu-bar-final-items' variable[1]
is modified in emacs-w3m buffers locally in order to place the
w3m menu at the forefront of the menu bar.  You can customize it
as follows:

--8<---------------cut here---------------start------------->8---
 (lambda nil
   (let ((item 'tools) ;; Place the `user-utils' menu after this.
	 (items (delq 'user-utils (copy-sequence menu-bar-final-items))))
     (setq menu-bar-final-items
	    (nreverse (cons 'user-utils (memq item (reverse items))))
	    (cdr (memq item items)))))))
--8<---------------cut here---------------end--------------->8---

[1] If you want to know the value, you'd better evaluate the
    following form in the *scratch* buffer:

(with-current-buffer "*w3m*"