]> code.delx.au - gnu-emacs-elpa/commitdiff
allow yas/dont-activate to take list of functions with default being `(minibufferp)`
authorLe Wang <le.wang@agworld.com.au>
Mon, 4 Jun 2012 16:34:08 +0000 (00:34 +0800)
committerLe Wang <le.wang@agworld.com.au>
Mon, 4 Jun 2012 16:40:21 +0000 (00:40 +0800)
- This allows the user to configure whether yasnippet should be enabled in
  minibuffer while preserving the current default.

yasnippet.el

index 4a74157ceecd652ee69f3b9f71041a8b816dadce..9f373cd99c50595c23f8d39b2f1ceb95ce2ba3e3 100644 (file)
@@ -812,9 +812,14 @@ Key bindings:
          (remove-hook 'emulation-mode-map-alists 'yas/direct-keymaps))))
 
 
-(defvar yas/dont-activate nil
+(defvar yas/dont-activate '(minibufferp)
   "If non-nil don't let `yas/minor-mode-on' active yas for this buffer.
 
+If a function, then its result is used.
+
+If a list of functions, then all functions must return nil to
+activate yas for this buffer.
+
 `yas/minor-mode-on' is usually called by `yas/global-mode' so
 this effectively lets you define exceptions to the \"global\"
 behaviour. Can also be a function of zero arguments.")
@@ -825,10 +830,11 @@ behaviour. Can also be a function of zero arguments.")
 
 Do this unless `yas/dont-activate' is truish "
   (interactive)
-  (unless (or (minibufferp)
-              (if (functionp yas/dont-activate)
-                  (funcall yas/dont-activate)
-                yas/dont-activate))
+  (unless (cond ((functionp yas/dont-activate)
+                 (funcall yas/dont-activate))
+                ((consp yas/dont-activate)
+                 (some #'funcall yas/dont-activate))
+                (yas/dont-activate))
     ;; Load all snippets definitions unless we still don't have a
     ;; root-directory or some snippets have already been loaded.
     ;;