Support yas/ symbols in yas-define-menu

These symbols were overlooked in backporting because they're not bound
or fbound.

* yasnippet.el (yas--define-menu-1): Rewrite with `cl-loop', and support
yas/ prefixed symbols.
This commit is contained in:
Noam Postavsky 2016-07-19 20:23:12 -04:00
parent 244cdfa53b
commit 5af9276f21

View File

@ -2075,31 +2075,37 @@ omitted from MODE's menu, even if they're manually loaded."
(defun yas--define-menu-1 (table menu-keymap menu uuidhash &optional group-list) (defun yas--define-menu-1 (table menu-keymap menu uuidhash &optional group-list)
"Helper for `yas-define-menu'." "Helper for `yas-define-menu'."
(dolist (e (reverse menu)) (cl-loop
(cond ((eq (first e) 'yas-item) for (type name submenu) in (reverse menu)
(let ((template (or (gethash (second e) uuidhash) if (or (eq type 'yas-item)
(puthash (second e) (and yas-alias-to-yas/prefix-p
(yas--make-template (eq type 'yas/item)))
:table table do (let ((template (or (gethash name uuidhash)
:perm-group group-list (puthash name
:uuid (second e)) (yas--make-template
uuidhash)))) :table table
(define-key menu-keymap (vector (gensym)) :perm-group group-list
(car (yas--template-menu-binding-pair-get-create template :stay))))) :uuid name)
((eq (first e) 'yas-submenu) uuidhash))))
(let ((subkeymap (make-sparse-keymap))) (define-key menu-keymap (vector (gensym))
(define-key menu-keymap (vector (gensym)) (car (yas--template-menu-binding-pair-get-create template :stay))))
`(menu-item ,(second e) ,subkeymap)) else if (or (eq type 'yas-submenu)
(yas--define-menu-1 table (and yas-alias-to-yas/prefix-p
subkeymap (eq type 'yas/submenu)))
(third e) do (let ((subkeymap (make-sparse-keymap)))
uuidhash (define-key menu-keymap (vector (gensym))
(append group-list (list (second e)))))) `(menu-item ,name ,subkeymap))
((eq (first e) 'yas-separator) (yas--define-menu-1 table
(define-key menu-keymap (vector (gensym)) subkeymap
'(menu-item "----"))) submenu
(t uuidhash
(yas--message 1 "Don't know anything about menu entry %s" (first e)))))) (append group-list (list name))))
else if (or (eq type 'yas-separator)
(and yas-alias-to-yas/prefix-p
(eq type 'yas/separator)))
do (define-key menu-keymap (vector (gensym))
'(menu-item "----"))
else do (yas--message 1 "Don't know anything about menu entry %s" type)))
(defun yas--define (mode key template &optional name condition group) (defun yas--define (mode key template &optional name condition group)
"Define a snippet. Expanding KEY into TEMPLATE. "Define a snippet. Expanding KEY into TEMPLATE.