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

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

Re: Menu on minor mode lighter


From: Michael Heerdegen
Subject: Re: Menu on minor mode lighter
Date: Sun, 03 Aug 2014 19:57:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux)

Sebastian Wiesner <swiesner@lunaryorn.com> writes:

> So how do I do that?  How do I “define a menu for a minor mode”?

As you like, e.g. with "easymenu".  Here is an example of how you could
do it:

--8<---------------cut here---------------start------------->8---
(require 'easymenu)

(defvar my-mode-line-menus '()
  "My alist of menus for the mode-line.")

(defun my-add-menu-to-mode-line (mode menu)
  "Add MENU as mode-line indicator menu for MODE."
  (unless (assoc mode my-mode-line-menus)
    (push (cons mode menu)
          my-mode-line-menus)))

(defadvice minor-mode-menu-from-indicator
           (around add-my-stuff activate)
  (let* ((mode (lookup-minor-mode-from-indicator (ad-get-arg 0)))
         (my-menu (cdr (assoc mode my-mode-line-menus))))
    (if my-menu
        (popup-menu my-menu)
      ad-do-it)))


;; Example: add menu for ispell

(my-add-menu-to-mode-line
 'ispell-minor-mode
 (easy-menu-create-menu
  "Ispell"
  '(["Spell word"   ispell-word]
    ["Spell buffer" ispell-buffer])))
--8<---------------cut here---------------end--------------->8---

Does that do what you want?


Regards,

Michael.




reply via email to

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