bugfix: fix #233

This commit is contained in:
Joao Tavora 2012-05-21 14:47:42 +01:00
parent 9fc2e20d91
commit 4f846f2c36

View File

@ -1018,7 +1018,6 @@ Has the following fields:
;; ;;
(remhash uuid (yas/table-uuidhash table)))))) (remhash uuid (yas/table-uuidhash table))))))
(defun yas/add-template (table template) (defun yas/add-template (table template)
"Store in TABLE the snippet template TEMPLATE. "Store in TABLE the snippet template TEMPLATE.
@ -1027,7 +1026,7 @@ keybinding)."
(let ((name (yas/template-name template)) (let ((name (yas/template-name template))
(key (yas/template-key template)) (key (yas/template-key template))
(keybinding (yas/template-keybinding template)) (keybinding (yas/template-keybinding template))
(menu-binding (car (yas/template-menu-binding-pair template)))) (menu-binding-pair (yas/snippet-menu-binding-pair-get-create template)))
(dolist (k (remove nil (list key keybinding))) (dolist (k (remove nil (list key keybinding)))
(puthash name (puthash name
template template
@ -1039,28 +1038,27 @@ keybinding)."
(when (vectorp k) (when (vectorp k)
(define-key (yas/table-direct-keymap table) k 'yas/expand-from-keymap))) (define-key (yas/table-direct-keymap table) k 'yas/expand-from-keymap)))
(when menu-binding ;; Update trigger & keybinding in the menu-binding pair
(setf (getf (cdr menu-binding) :keys) ;;
(setf (getf (cdr (car menu-binding-pair)) :keys)
(or (and keybinding (key-description keybinding)) (or (and keybinding (key-description keybinding))
(and key (concat key yas/trigger-symbol)))) (and key (concat key yas/trigger-symbol))))
(setcar (cdr menu-binding)
name))
(puthash (yas/template-uuid template) template (yas/table-uuidhash table)))) (puthash (yas/template-uuid template) template (yas/table-uuidhash table))))
(defun yas/update-template (snippet-table template) (defun yas/update-template (table template)
"Add or update TEMPLATE in SNIPPET-TABLE. "Add or update TEMPLATE in TABLE.
Also takes care of adding and updaring to the associated menu." Also takes care of adding and updating to the associated menu."
;; Remove from table by uuid ;; Remove from table by uuid
;; ;;
(yas/remove-template-by-uuid snippet-table (yas/template-uuid template)) (yas/remove-template-by-uuid table (yas/template-uuid template))
;; Add to table again ;; Add to table again
;; ;;
(yas/add-template snippet-table template) (yas/add-template table template)
;; Take care of the menu ;; Take care of the menu
;; ;;
(let ((keymap (yas/menu-keymap-get-create snippet-table)) (let ((keymap (yas/menu-keymap-get-create table))
(group (yas/template-group template))) (group (yas/template-group template)))
(when (and yas/use-menu (when (and yas/use-menu
keymap keymap
@ -1680,7 +1678,21 @@ Below TOP-LEVEL-DIR each directory is a mode name."
Behaviour is affected by `yas/no-jit', which see." Behaviour is affected by `yas/no-jit', which see."
(interactive "p") (interactive "p")
(let ((errors)) (catch 'abort
(let ((errors)
(snippet-editing-buffers
(remove-if-not #'(lambda (buffer)
(with-current-buffer buffer yas/editing-template))
(buffer-list))))
;; Warn if there are buffers visiting snippets, since reloading will break
;; any on-line editing of those buffers.
;;
(if snippet-editing-buffers
(if (y-or-n-p "Some buffers editing live snippets, close them and proceed with reload?")
(mapcar #'kill-buffer snippet-editing-buffers)
(yas/message 1 "Aborted reload...")
(throw 'abort nil)))
;; Empty all snippet tables, parenting info and all menu tables ;; Empty all snippet tables, parenting info and all menu tables
;; ;;
(setq yas/tables (make-hash-table)) (setq yas/tables (make-hash-table))
@ -1707,7 +1719,8 @@ Behaviour is affected by `yas/no-jit', which see."
;; Reload the trigger-key (shoudn't be needed, but see issue #237) ;; Reload the trigger-key (shoudn't be needed, but see issue #237)
;; ;;
(yas/trigger-key-reload) (yas/trigger-key-reload)
(yas/message 3 "Reloaded everything...%s." (if errors " (some errors, check *Messages*)" ""))))
(yas/message 3 "Reloaded everything...%s." (if errors " (some errors, check *Messages*)" "")))))
(defun yas/load-pending-jits () (defun yas/load-pending-jits ()
(when yas/minor-mode (when yas/minor-mode