0

The problem:

Before installing YASnippet changing themes was instantaneous, now it YASnippet reloads itself in someway making changes take a few seconds.

Is this functionality necessary? Can I turn it off?

Is there some way around it?

Context:

I have this as part of my evil mode config:

;; Evil Mode Switcher
(defun toggle-evil-mode ()
  (interactive)
  (if (not evil-mode)
      (progn
        (evil-mode 1)
        (enable-theme 'ample))
    (progn
      (evil-mode 0)
      (enable-theme 'ample-flat))))

(global-set-key (kbd "<C-escape>") 'toggle-evil-mode)

It allows me to switch in and out of evil mode with C-escape.

While doing though it toggles to a darker theme, this makes it easier to recognise whether I am in it or not.

It used to work well, but now that I have YASnippet installed it takes too long.

Updated: Stack trace

Here is a slightly truncated stacktrace, by using debug-on-entry. From this it appears that yas is adding custom items to the theme, do they need to be updated though?

Debugger entered--entering a function:
* yas-reload-all()
  yas--global-mode-reload-with-jit-maybe()
  run-hooks(yas-global-mode-hook yas-global-mode-on-hook)
  yas-global-mode(1)
  custom-set-minor-mode(yas-global-mode t)
  custom-theme-recalc-variable(yas-global-mode)
  enable-theme(user)
  enable-theme(ample)
  toggle-evil-mode()
  call-interactively(toggle-evil-mode nil nil)
  command-execute(toggle-evil-mode)
2
  • 2
    Not an answer about yasnippet, but why not just switch to evil-emacs-state rather than turn evil completely on and off?
    – Dan
    Jul 25, 2015 at 14:20
  • Try doing M-x debug-on-entry RET yas-reload-all RET, this should give a backtrace so you can see what is causing the reload.
    – npostavs
    Jul 26, 2015 at 8:36

1 Answer 1

0

It looks like yas-global-mode became part of your user theme (perhaps because you set it via the customize interface? (the docstring of custom-set-variables says "These settings are registered as theme `user'.")).

A possible workaround could be to let-bind yas-global-mode-hook in toggle-evil-mode:

;; Evil Mode Switcher
(defun toggle-evil-mode ()
  (interactive)
  (let ((yas-global-mode-hook nil)) ; don't reload snippets
    (if (not evil-mode)
        (progn
          (evil-mode 1)
          (enable-theme 'ample))
      (progn
        (evil-mode 0)
        (enable-theme 'ample-flat)))))

Another possibility might be to remove yas-global-mode from your custom settings, and just call (yas-global-mode +1) in your init file directly.

1
  • The let workaround works perfectly, thanks
    – Jessie
    Jul 28, 2015 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.