mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
fix a small bug when reading keybindings
This commit is contained in:
parent
23bf5b7a1e
commit
e19ecb4695
35
yasnippet.el
35
yasnippet.el
@ -1179,6 +1179,20 @@ return an expression that when evaluated will issue an error."
|
|||||||
(error (and (not nil-on-error)
|
(error (and (not nil-on-error)
|
||||||
`(error ,(error-message-string err))))))
|
`(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
|
(defvar yas/mode-symbol nil
|
||||||
"If non-nil, lookup snippets using this instead of `major-mode'.")
|
"If non-nil, lookup snippets using this instead of `major-mode'.")
|
||||||
(make-variable-buffer-local 'yas/mode-symbol)
|
(make-variable-buffer-local 'yas/mode-symbol)
|
||||||
@ -1783,22 +1797,8 @@ not need to be a real mode."
|
|||||||
(file-name-directory file))))
|
(file-name-directory file))))
|
||||||
(condition (fourth snippet))
|
(condition (fourth snippet))
|
||||||
(group (fifth snippet))
|
(group (fifth snippet))
|
||||||
(keybinding (eighth snippet))
|
(keybinding (yas/read-keybinding (eighth snippet)))
|
||||||
(template nil))
|
(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
|
;; Create the `yas/template' object and store in the
|
||||||
;; appropriate snippet table. This only done if we have found
|
;; 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-name yas/current-template) (third parsed))
|
||||||
(setf (yas/template-condition yas/current-template) (fourth parsed))
|
(setf (yas/template-condition yas/current-template) (fourth parsed))
|
||||||
(setf (yas/template-expand-env yas/current-template) (sixth 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/update-snippet (yas/template-table yas/current-template)
|
||||||
yas/current-template
|
yas/current-template
|
||||||
old-name
|
old-name
|
||||||
@ -3368,7 +3368,8 @@ If it does, also:
|
|||||||
field
|
field
|
||||||
|
|
||||||
Also, if FOM is an exit-marker, always call
|
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))
|
(cond ((and fom (< (yas/fom-end fom) newend))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user