From e19ecb469549c7be685c0102f020b68467802c81 Mon Sep 17 00:00:00 2001 From: capitaomorte Date: Sun, 14 Mar 2010 19:59:46 +0000 Subject: [PATCH] fix a small bug when reading keybindings --- yasnippet.el | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 38e0846..35fe56a 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1179,6 +1179,20 @@ return an expression that when evaluated will issue an error." (error (and (not nil-on-error) `(error ,(error-message-string err)))))) +(defun yas/read-keybinding (keybinding) + "Read KEYBINDING as a snippet keybinding, return a vector." + (when keybinding + (condition-case err + (let ((keybinding-string (or (and (string-match "\".*\"" keybinding) + (read keybinding)) + ;; "KEY-DESC" with quotes is deprecated..., but supported + keybinding))) + (read-kbd-macro keybinding-string 'need-vector)) + (error + (message "[yas] warning: keybinding \"%s\" invalid for snippet \"%s\" since %s." + keybinding name (error-message-string err)) + nil)))) + (defvar yas/mode-symbol nil "If non-nil, lookup snippets using this instead of `major-mode'.") (make-variable-buffer-local 'yas/mode-symbol) @@ -1783,22 +1797,8 @@ not need to be a real mode." (file-name-directory file)))) (condition (fourth snippet)) (group (fifth snippet)) - (keybinding (eighth snippet)) + (keybinding (yas/read-keybinding (eighth snippet))) (template nil)) - ;; Read the snippet's "binding :" expression and turn it into - ;; a keysequence vector if all is OK. - ;; - (when keybinding - (condition-case err - (let ((keybinding-string (or (and (string-match "\".*\"" (eighth snippet)) - (read (eighth snippet))) - ;; "KEY-DESC" with quotes is deprecated..., but supported - (eighth snippet)))) - (setq keybinding (read-kbd-macro keybinding-string 'need-vector))) - (error - (message "[yas] warning: keybinding \"%s\" invalid for snippet \"%s\" since %s." - keybinding name (error-message-string err)) - (setf keybinding nil)))) ;; Create the `yas/template' object and store in the ;; appropriate snippet table. This only done if we have found @@ -2307,7 +2307,7 @@ With optional prefix argument KILL quit the window and buffer." (setf (yas/template-name yas/current-template) (third parsed)) (setf (yas/template-condition yas/current-template) (fourth parsed)) (setf (yas/template-expand-env yas/current-template) (sixth parsed)) - (setf (yas/template-keybinding yas/current-template) (eighth parsed)) + (setf (yas/template-keybinding yas/current-template) (yas/read-keybinding (eighth parsed))) (yas/update-snippet (yas/template-table yas/current-template) yas/current-template old-name @@ -3368,7 +3368,8 @@ If it does, also: field Also, if FOM is an exit-marker, always call -`yas/advance-start-maybe' on its next fom. +`yas/advance-start-maybe' on its next fom. This is beacuse +exit-marker have identical start and end markers. " (cond ((and fom (< (yas/fom-end fom) newend))