David Kastrup <[EMAIL PROTECTED]> writes:

> how feasible would it be to
> make kbd accept File=>Print=>Print With Faces strings?  Then there
> would be no necessity to report a different form.

Does kbd really generate proper menu bindings in its current form?
Does it make sense at all to use kbd for that purpose?

(kbd "<menu-bar> <file> <new-file>")
=> [menu-bar file new-file]


In any case, the main problem is that parsing the new form must go
through the active keymaps to find the relevant menu bindings.
However, this is doable if we limit it to the global map:

(defun kbd-menu-binding (menu-binding)
  (let ((items (split-string menu-binding "=>"))
        (map (lookup-key global-map [menu-bar]))
        m keys)
    (while (and items map)
      (setq m (car map)
            map (cdr map))
      (when (consp m)
        (if (eq (nth 1 m) 'menu-item)
            (if (equal (car items) (nth 2 m))
                (setq map (and (keymapp (nth 3 m)) (nth 3 m))
                      items (cdr items)
                      keys (cons (car m) keys)))
          (if (equal (car items) (nth 1 m))
              (setq map (if (and (symbolp (nthcdr 2 m))
                                 (boundp (nthcdr 2 m))
                                 (keymapp (symbol-value (nthcdr 2 m))))
                            (cdr (symbol-value (nthcdr 2 m)))
                          (nthcdr 2 m))
                    items (cdr items)
                    keys (cons (car m) keys))))))
    (if items
        (error "No menu binding for %s" menu-binding)
      (apply 'vector 'menu-bar (reverse keys)))))


(kbd-menu-binding "File=>New File...")
=> [menu-bar file new-file]

(kbd-menu-binding "Options=>Mule (Multilingual Environment)=>Set Language 
Environment=>European=>Brazilian Portuguese")
=> [menu-bar options mule set-language-environment European Brazilian\ 
Portuguese]

-- 
Kim F. Storm <[EMAIL PROTECTED]> http://www.cua.dk



_______________________________________________
Emacs-pretest-bug mailing list
Emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

Reply via email to