diff options
Diffstat (limited to '.emacs.d/lisp/yasnippet.el')
| -rw-r--r-- | .emacs.d/lisp/yasnippet.el | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 7b871b9..76e1d25 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el | |||
| @@ -1352,7 +1352,7 @@ Returns (TEMPLATES START END). This function respects | |||
| 1352 | ((debug error) (cdr oops))))) | 1352 | ((debug error) (cdr oops))))) |
| 1353 | 1353 | ||
| 1354 | (defun yas--eval-for-effect (form) | 1354 | (defun yas--eval-for-effect (form) |
| 1355 | (yas--safely-run-hook (apply-partially #'eval form))) | 1355 | (yas--safely-call-fun (apply-partially #'eval form))) |
| 1356 | 1356 | ||
| 1357 | (defun yas--read-lisp (string &optional nil-on-error) | 1357 | (defun yas--read-lisp (string &optional nil-on-error) |
| 1358 | "Read STRING as a elisp expression and return it. | 1358 | "Read STRING as a elisp expression and return it. |
| @@ -3336,18 +3336,19 @@ This renders the snippet as ordinary text." | |||
| 3336 | (setq yas--snippets-to-move nil)) | 3336 | (setq yas--snippets-to-move nil)) |
| 3337 | 3337 | ||
| 3338 | (defun yas--safely-call-fun (fun) | 3338 | (defun yas--safely-call-fun (fun) |
| 3339 | "Call FUN and catch any errors." | ||
| 3339 | (condition-case error | 3340 | (condition-case error |
| 3340 | (funcall fun) | 3341 | (funcall fun) |
| 3341 | ((debug error) | 3342 | ((debug error) |
| 3342 | (yas--message 2 "Error running %s: %s" | 3343 | (yas--message 2 "Error running %s: %s" fun |
| 3343 | (if (symbolp fun) fun "a hook") | ||
| 3344 | (error-message-string error))))) | 3344 | (error-message-string error))))) |
| 3345 | 3345 | ||
| 3346 | (defun yas--safely-run-hook (hook) | 3346 | (defun yas--safely-run-hook (hook) |
| 3347 | "Call HOOK's functions. | ||
| 3348 | HOOK should be a symbol, a hook variable, as in `run-hooks'." | ||
| 3347 | (let ((debug-on-error (and (not (memq yas-good-grace '(t hooks))) | 3349 | (let ((debug-on-error (and (not (memq yas-good-grace '(t hooks))) |
| 3348 | debug-on-error))) | 3350 | debug-on-error))) |
| 3349 | (if (functionp hook) (yas--safely-call-fun hook) | 3351 | (yas--safely-call-fun (apply-partially #'run-hooks hook)))) |
| 3350 | (mapc #'yas--safely-call-fun hook)))) | ||
| 3351 | 3352 | ||
| 3352 | (defun yas--check-commit-snippet () | 3353 | (defun yas--check-commit-snippet () |
| 3353 | "Check if point exited the currently active field of the snippet. | 3354 | "Check if point exited the currently active field of the snippet. |
| @@ -3355,7 +3356,9 @@ This renders the snippet as ordinary text." | |||
| 3355 | If so cleans up the whole snippet up." | 3356 | If so cleans up the whole snippet up." |
| 3356 | (let* ((snippets (yas-active-snippets 'all)) | 3357 | (let* ((snippets (yas-active-snippets 'all)) |
| 3357 | (snippets-left snippets) | 3358 | (snippets-left snippets) |
| 3358 | (snippet-exit-transform nil) | 3359 | (snippet-exit-transform) |
| 3360 | ;; Record the custom snippet `yas-after-exit-snippet-hook' | ||
| 3361 | ;; set in the expand-env field. | ||
| 3359 | (snippet-exit-hook yas-after-exit-snippet-hook)) | 3362 | (snippet-exit-hook yas-after-exit-snippet-hook)) |
| 3360 | (dolist (snippet snippets) | 3363 | (dolist (snippet snippets) |
| 3361 | (let ((active-field (yas--snippet-active-field snippet))) | 3364 | (let ((active-field (yas--snippet-active-field snippet))) |
| @@ -3383,9 +3386,10 @@ If so cleans up the whole snippet up." | |||
| 3383 | (t | 3386 | (t |
| 3384 | nil))))) | 3387 | nil))))) |
| 3385 | (unless (or (null snippets) snippets-left) | 3388 | (unless (or (null snippets) snippets-left) |
| 3386 | (if snippet-exit-transform | 3389 | (when snippet-exit-transform |
| 3387 | (yas--eval-for-effect snippet-exit-transform)) | 3390 | (yas--eval-for-effect snippet-exit-transform)) |
| 3388 | (yas--safely-run-hook snippet-exit-hook)))) | 3391 | (let ((yas-after-exit-snippet-hook snippet-exit-hook)) |
| 3392 | (yas--safely-run-hook 'yas-after-exit-snippet-hook))))) | ||
| 3389 | 3393 | ||
| 3390 | ;; Apropos markers-to-points: | 3394 | ;; Apropos markers-to-points: |
| 3391 | ;; | 3395 | ;; |
