[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master fa6a71c 45/51: ; Wait until post-command, or bad auto-fill
From: |
Noam Postavsky |
Subject: |
[elpa] master fa6a71c 45/51: ; Wait until post-command, or bad auto-fill call to print stacktrace |
Date: |
Sun, 13 May 2018 13:11:46 -0400 (EDT) |
branch: master
commit fa6a71c42de7fecd58193e2fd3681a0225b71dc5
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
; Wait until post-command, or bad auto-fill call to print stacktrace
If we popup a warning as soon as yas--original-auto-fill-function is
changed to nil, we'll have false positives in cases where
auto-fill-function was *also* going to be turned nil afterwards.
* yasnippet.el (yas--watch-auto-fill-backtrace): New variable, to save
backtrace into.
(yas--watch-auto-fill): Check both yas--original-auto-fill-function
and auto-fill-function, but only save the backtrace, don't popup the
debugger.
(yas--auto-fill): Also print the saved backtrace if
yas--original-auto-fill-function is nil.
(yas--post-command-handler): Print the saved backtrace if
yas--original-auto-fill-function and auto-fill-function is
yas--auto-fill, which means we're in a bad state.
---
yasnippet.el | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 562a1db..9c7e88f 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -582,8 +582,16 @@ override bindings from other packages (e.g.,
`company-mode')."
"The original value of `auto-fill-function'.")
(make-variable-buffer-local 'yas--original-auto-fill-function)
-(defun yas--watch-auto-fill (_sym newval op _where)
- (when (and (null newval) (eq auto-fill-function 'yas--auto-fill)
+(defvar yas--watch-auto-fill-backtrace nil)
+
+(defun yas--watch-auto-fill (sym newval op _where)
+ (when (and (or (and (eq sym 'yas--original-auto-fill-function)
+ (null newval)
+ (eq auto-fill-function 'yas--auto-fill))
+ (and (eq sym 'auto-fill-function)
+ (eq newval 'yas--auto-fill)
+ (null yas--original-auto-fill-function)))
+ (null yas--watch-auto-fill-backtrace)
(fboundp 'backtrace-frames) ; Suppress compiler warning.
;; If we're about to change `auto-fill-function' too,
;; it's okay (probably).
@@ -592,11 +600,14 @@ override bindings from other packages (e.g.,
`company-mode')."
(cl-member 'kill-all-local-variables
(backtrace-frames 'yas--watch-auto-fill)
:key (lambda (frame) (nth 1 frame))))))
- (debug nil "`yas--original-auto-fill-function' unexpectedly nil! Please
report this backtrace (hit `c' to continue)")) )
+ (setq yas--watch-auto-fill-backtrace
+ (backtrace-frames 'yas--watch-auto-fill))))
;; Try to get more info on #873/919 (this only works for Emacs 26+).
(when (fboundp 'add-variable-watcher)
(add-variable-watcher 'yas--original-auto-fill-function
+ #'yas--watch-auto-fill)
+ (add-variable-watcher 'auto-fill-function
#'yas--watch-auto-fill))
(defun yas--snippet-next-id ()
@@ -3724,8 +3735,14 @@ field start. This hook does nothing if an undo is in
progress."
(lwarn '(yasnippet auto-fill bug) :error
"`yas--original-auto-fill-function' unexpectedly nil
in %S! Disabling auto-fill.
%S
- `auto-fill-function': %S"
- (current-buffer) yas--fill-fun-values fill-fun-values)
+ `auto-fill-function': %S\n%s"
+ (current-buffer) yas--fill-fun-values fill-fun-values
+ (if (fboundp 'backtrace--print-frame)
+ (with-output-to-string
+ (mapc (lambda (frame)
+ (apply #'backtrace--print-frame frame))
+ yas--watch-auto-fill-backtrace))
+ ""))
;; Try to avoid repeated triggering of this bug.
(auto-fill-mode -1)
;; 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."
;;
(defun yas--post-command-handler ()
"Handles various yasnippet conditions after each command."
+ (when (and yas--watch-auto-fill-backtrace
+ (fboundp 'backtrace--print-frame)
+ (null yas--original-auto-fill-function)
+ (eq auto-fill-function 'yas--auto-fill))
+ (lwarn '(yasnippet auto-fill bug) :error
+ "`yas--original-auto-fill-function' unexpectedly nil! Please report
this backtrace\n%S"
+ (with-output-to-string
+ (mapc #'backtrace--print-frame
+ yas--watch-auto-fill-backtrace)))
+ ;; Don't pop up more than once in a session (still log though).
+ (defvar warning-suppress-types) ; `warnings' is autoloaded by `lwarn'.
+ (add-to-list 'warning-suppress-types '(yasnippet auto-fill bug)))
(condition-case err
(progn (yas--finish-moving-snippets)
(cond ((eq 'undo this-command)
- [elpa] master ba73f20 27/51: Bind field skip and clear command conditionally, (continued)
- [elpa] master ba73f20 27/51: Bind field skip and clear command conditionally, Noam Postavsky, 2018/05/13
- [elpa] master ce11fd6 13/51: * yasnippet.el (yas-reload-all): Mention if no snippets were found., Noam Postavsky, 2018/05/13
- [elpa] master e200a3b 08/51: Let snippet insertion trigger active field clearing., Noam Postavsky, 2018/05/13
- [elpa] master 04062d8 14/51: Don't set yas-selected-text to non-selected text, Noam Postavsky, 2018/05/13
- [elpa] master ad3a4d1 16/51: Don't use prog-mode in older Emacs, Noam Postavsky, 2018/05/13
- [elpa] master 16c2b38 18/51: Update `yas--take-care-of-redo' call in buffer undo list, Noam Postavsky, 2018/05/13
- [elpa] master e35c031 25/51: * yasnippet.el (yas--guess-snippet-directories): Guess major mode first., Noam Postavsky, 2018/05/13
- [elpa] master 4467e93 40/51: Use fancy field adjustment for fixed indent too, Noam Postavsky, 2018/05/13
- [elpa] master 7c9edb5 29/51: ; doc/snippet-development.org: Further copy edit., Noam Postavsky, 2018/05/13
- [elpa] master cf23537 33/51: Fix expansion of commands snippet, Noam Postavsky, 2018/05/13
- [elpa] master fa6a71c 45/51: ; Wait until post-command, or bad auto-fill call to print stacktrace,
Noam Postavsky <=
- [elpa] master c9277d3 32/51: Change yas-lookup-snippet to return a yas--template struct, Noam Postavsky, 2018/05/13
- [elpa] master 6066631 28/51: Fix typos in "Writing Templates" documentation, Noam Postavsky, 2018/05/13
- [elpa] master b0aa5c2 48/51: Tweak bug-reporting information slightly, Noam Postavsky, 2018/05/13
- [elpa] master fe9f8b6 21/51: ; yasnippet-debug.el: Update yas-debug-snippets arg for previous change., Noam Postavsky, 2018/05/13
- [elpa] master caf3dba 30/51: Don't use global variable for backquote expression locations, Noam Postavsky, 2018/05/13
- [elpa] master ff26e3b 19/51: Close #824: Simple fields can be parented like other fields or mirrors, Noam Postavsky, 2018/05/13
- [elpa] master ff8e833 23/51: ; yasnippet-debug.el: Fix deprecation warning., Noam Postavsky, 2018/05/13
- [elpa] master a0d2cff 44/51: ; Don't enter debugger for kill-all-local-variables case, Noam Postavsky, 2018/05/13
- [elpa] master 5170f05 42/51: Don't indent first and only line of expanded snippet, Noam Postavsky, 2018/05/13
- [elpa] master 5a29fe6 50/51: Release 0.13.0, Noam Postavsky, 2018/05/13