summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2018-03-22 17:24:14 +0100
committerSimeon Simeonov2018-03-22 17:24:14 +0100
commitee3838a8fa94db17b0e583a81b1941c2778e4d0e (patch)
tree9748cfafff3ef45cf97d1dffa064699d2dcb67fa
parent56e823ecbecf1b3bc7b485dc7acb268735d21d8e (diff)
Upgrade yasnippet
-rw-r--r--.emacs.d/lisp/yasnippet.el39
1 files changed, 34 insertions, 5 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index 562a1db..9c7e88f 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -582,8 +582,16 @@ override bindings from other packages (e.g., `company-mode')."
582 "The original value of `auto-fill-function'.") 582 "The original value of `auto-fill-function'.")
583(make-variable-buffer-local 'yas--original-auto-fill-function) 583(make-variable-buffer-local 'yas--original-auto-fill-function)
584 584
585(defun yas--watch-auto-fill (_sym newval op _where) 585(defvar yas--watch-auto-fill-backtrace nil)
586 (when (and (null newval) (eq auto-fill-function 'yas--auto-fill) 586
587(defun yas--watch-auto-fill (sym newval op _where)
588 (when (and (or (and (eq sym 'yas--original-auto-fill-function)
589 (null newval)
590 (eq auto-fill-function 'yas--auto-fill))
591 (and (eq sym 'auto-fill-function)
592 (eq newval 'yas--auto-fill)
593 (null yas--original-auto-fill-function)))
594 (null yas--watch-auto-fill-backtrace)
587 (fboundp 'backtrace-frames) ; Suppress compiler warning. 595 (fboundp 'backtrace-frames) ; Suppress compiler warning.
588 ;; If we're about to change `auto-fill-function' too, 596 ;; If we're about to change `auto-fill-function' too,
589 ;; it's okay (probably). 597 ;; it's okay (probably).
@@ -592,11 +600,14 @@ override bindings from other packages (e.g., `company-mode')."
592 (cl-member 'kill-all-local-variables 600 (cl-member 'kill-all-local-variables
593 (backtrace-frames 'yas--watch-auto-fill) 601 (backtrace-frames 'yas--watch-auto-fill)
594 :key (lambda (frame) (nth 1 frame)))))) 602 :key (lambda (frame) (nth 1 frame))))))
595 (debug nil "`yas--original-auto-fill-function' unexpectedly nil! Please report this backtrace (hit `c' to continue)")) ) 603 (setq yas--watch-auto-fill-backtrace
604 (backtrace-frames 'yas--watch-auto-fill))))
596 605
597;; Try to get more info on #873/919 (this only works for Emacs 26+). 606;; Try to get more info on #873/919 (this only works for Emacs 26+).
598(when (fboundp 'add-variable-watcher) 607(when (fboundp 'add-variable-watcher)
599 (add-variable-watcher 'yas--original-auto-fill-function 608 (add-variable-watcher 'yas--original-auto-fill-function
609 #'yas--watch-auto-fill)
610 (add-variable-watcher 'auto-fill-function
600 #'yas--watch-auto-fill)) 611 #'yas--watch-auto-fill))
601 612
602(defun yas--snippet-next-id () 613(defun yas--snippet-next-id ()
@@ -3724,8 +3735,14 @@ field start. This hook does nothing if an undo is in progress."
3724 (lwarn '(yasnippet auto-fill bug) :error 3735 (lwarn '(yasnippet auto-fill bug) :error
3725 "`yas--original-auto-fill-function' unexpectedly nil in %S! Disabling auto-fill. 3736 "`yas--original-auto-fill-function' unexpectedly nil in %S! Disabling auto-fill.
3726 %S 3737 %S
3727 `auto-fill-function': %S" 3738 `auto-fill-function': %S\n%s"
3728 (current-buffer) yas--fill-fun-values fill-fun-values) 3739 (current-buffer) yas--fill-fun-values fill-fun-values
3740 (if (fboundp 'backtrace--print-frame)
3741 (with-output-to-string
3742 (mapc (lambda (frame)
3743 (apply #'backtrace--print-frame frame))
3744 yas--watch-auto-fill-backtrace))
3745 ""))
3729 ;; Try to avoid repeated triggering of this bug. 3746 ;; Try to avoid repeated triggering of this bug.
3730 (auto-fill-mode -1) 3747 (auto-fill-mode -1)
3731 ;; Don't pop up more than once in a session (still log though). 3748 ;; Don't pop up more than once in a session (still log though).
@@ -4718,6 +4735,18 @@ When multiple expressions are found, only the last one counts."
4718;; 4735;;
4719(defun yas--post-command-handler () 4736(defun yas--post-command-handler ()
4720 "Handles various yasnippet conditions after each command." 4737 "Handles various yasnippet conditions after each command."
4738 (when (and yas--watch-auto-fill-backtrace
4739 (fboundp 'backtrace--print-frame)
4740 (null yas--original-auto-fill-function)
4741 (eq auto-fill-function 'yas--auto-fill))
4742 (lwarn '(yasnippet auto-fill bug) :error
4743 "`yas--original-auto-fill-function' unexpectedly nil! Please report this backtrace\n%S"
4744 (with-output-to-string
4745 (mapc #'backtrace--print-frame
4746 yas--watch-auto-fill-backtrace)))
4747 ;; Don't pop up more than once in a session (still log though).
4748 (defvar warning-suppress-types) ; `warnings' is autoloaded by `lwarn'.
4749 (add-to-list 'warning-suppress-types '(yasnippet auto-fill bug)))
4721 (condition-case err 4750 (condition-case err
4722 (progn (yas--finish-moving-snippets) 4751 (progn (yas--finish-moving-snippets)
4723 (cond ((eq 'undo this-command) 4752 (cond ((eq 'undo this-command)