mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
Merge pull request #251 from lewang/master
bugfix: don't hippie-expand unless in `yas/minor-mode` enhancement: yas/dont-activate can now be a list of functions
This commit is contained in:
commit
28cd4ca0c9
19
yasnippet.el
19
yasnippet.el
@ -812,9 +812,14 @@ Key bindings:
|
|||||||
(remove-hook 'emulation-mode-map-alists 'yas/direct-keymaps))))
|
(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 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
|
`yas/minor-mode-on' is usually called by `yas/global-mode' so
|
||||||
this effectively lets you define exceptions to the \"global\"
|
this effectively lets you define exceptions to the \"global\"
|
||||||
behaviour. Can also be a function of zero arguments.")
|
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 "
|
Do this unless `yas/dont-activate' is truish "
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless (or (minibufferp)
|
(unless (cond ((functionp yas/dont-activate)
|
||||||
(if (functionp yas/dont-activate)
|
(funcall yas/dont-activate))
|
||||||
(funcall yas/dont-activate)
|
((consp yas/dont-activate)
|
||||||
yas/dont-activate))
|
(some #'funcall yas/dont-activate))
|
||||||
|
(yas/dont-activate))
|
||||||
;; Load all snippets definitions unless we still don't have a
|
;; Load all snippets definitions unless we still don't have a
|
||||||
;; root-directory or some snippets have already been loaded.
|
;; root-directory or some snippets have already been loaded.
|
||||||
;;
|
;;
|
||||||
@ -2026,11 +2032,12 @@ will only be expanded when the condition evaluated to non-nil."
|
|||||||
(defun yas/hippie-try-expand (first-time?)
|
(defun yas/hippie-try-expand (first-time?)
|
||||||
"Integrate with hippie expand. Just put this function in
|
"Integrate with hippie expand. Just put this function in
|
||||||
`hippie-expand-try-functions-list'."
|
`hippie-expand-try-functions-list'."
|
||||||
|
(when yas/minor-mode
|
||||||
(if (not first-time?)
|
(if (not first-time?)
|
||||||
(let ((yas/fallback-behavior 'return-nil))
|
(let ((yas/fallback-behavior 'return-nil))
|
||||||
(yas/expand))
|
(yas/expand))
|
||||||
(undo 1)
|
(undo 1)
|
||||||
nil))
|
nil)))
|
||||||
|
|
||||||
|
|
||||||
;;; Apropos condition-cache:
|
;;; Apropos condition-cache:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user