From 5ed6adadcec13565700dc431fb2a5ba6f0a70df4 Mon Sep 17 00:00:00 2001 From: Le Wang Date: Tue, 5 Jun 2012 00:08:44 +0800 Subject: [PATCH 1/2] only hippie-expand when yas/minor-mode is on --- yasnippet.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 69105fd..4a74157 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -2026,11 +2026,12 @@ will only be expanded when the condition evaluated to non-nil." (defun yas/hippie-try-expand (first-time?) "Integrate with hippie expand. Just put this function in `hippie-expand-try-functions-list'." - (if (not first-time?) - (let ((yas/fallback-behavior 'return-nil)) - (yas/expand)) - (undo 1) - nil)) + (when yas/minor-mode + (if (not first-time?) + (let ((yas/fallback-behavior 'return-nil)) + (yas/expand)) + (undo 1) + nil))) ;;; Apropos condition-cache: From 6b841dd2471d8a99019415f4ac526445c2133c3d Mon Sep 17 00:00:00 2001 From: Le Wang Date: Tue, 5 Jun 2012 00:34:08 +0800 Subject: [PATCH 2/2] allow yas/dont-activate to take list of functions with default being `(minibufferp)` - This allows the user to configure whether yasnippet should be enabled in minibuffer while preserving the current default. --- yasnippet.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 4a74157..9f373cd 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -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. ;;