mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Make yas-buffer-local-condition into a defcustom
* yasnippet.el (yas-not-string-or-comment-condition): New constant, holding the previous default value of `yas-buffer-local-condition'. (yas-buffer-local-condition): Make into defcustom.
This commit is contained in:
parent
4f37afd493
commit
14819c931f
@ -181,8 +181,9 @@ In particular, the following things matter:
|
|||||||
- Buffer-local [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] variable
|
- Buffer-local [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] variable
|
||||||
|
|
||||||
This variable provides finer grained control over what snippets can
|
This variable provides finer grained control over what snippets can
|
||||||
be expanded in the current buffer. You could disable snippet
|
be expanded in the current buffer. For example, the constant
|
||||||
expansion inside comments or string literals for example. See [[condition-system][the
|
[[sym:yas-not-string-or-comment-condition][=yas-not-string-or-comment-condition=]] has a value that disables
|
||||||
|
snippet expansion inside comments or string literals. See [[condition-system][the
|
||||||
condition system]] for more info.
|
condition system]] for more info.
|
||||||
|
|
||||||
** The condition system <<condition-system>>
|
** The condition system <<condition-system>>
|
||||||
|
22
yasnippet.el
22
yasnippet.el
@ -456,7 +456,17 @@ Attention: These hooks are not run when exiting nested/stacked snippet expansion
|
|||||||
'()
|
'()
|
||||||
"Hooks to run just before expanding a snippet.")
|
"Hooks to run just before expanding a snippet.")
|
||||||
|
|
||||||
(defvar yas-buffer-local-condition t
|
(defconst yas-not-string-or-comment-condition
|
||||||
|
'(if (and (let ((ppss (syntax-ppss)))
|
||||||
|
(or (nth 3 ppss) (nth 4 ppss)))
|
||||||
|
(memq this-command '(yas-expand yas-expand-from-trigger-key
|
||||||
|
yas-expand-from-keymap)))
|
||||||
|
'(require-snippet-condition . force-in-comment)
|
||||||
|
t)
|
||||||
|
"Disables snippet expansion in strings and comments.
|
||||||
|
To use, set `yas-buffer-local-condition' to this value.")
|
||||||
|
|
||||||
|
(defcustom yas-buffer-local-condition t
|
||||||
"Snippet expanding condition.
|
"Snippet expanding condition.
|
||||||
|
|
||||||
This variable is a Lisp form which is evaluated every time a
|
This variable is a Lisp form which is evaluated every time a
|
||||||
@ -503,7 +513,15 @@ conditions.
|
|||||||
(setq yas-buffer-local-condition
|
(setq yas-buffer-local-condition
|
||||||
\\='(if (python-syntax-comment-or-string-p)
|
\\='(if (python-syntax-comment-or-string-p)
|
||||||
\\='(require-snippet-condition . force-in-comment)
|
\\='(require-snippet-condition . force-in-comment)
|
||||||
t))))")
|
t))))"
|
||||||
|
:type
|
||||||
|
`(choice
|
||||||
|
(const :tag "Disable snippet expansion inside strings and comments"
|
||||||
|
,yas-not-string-or-comment-condition)
|
||||||
|
(const :tag "Expand all snippets regardless of conditions" always)
|
||||||
|
(const :tag "Expand snippets unless their condition is nil" t)
|
||||||
|
(const :tag "Disable all snippet expansion" nil)
|
||||||
|
sexp))
|
||||||
|
|
||||||
|
|
||||||
;;; Internal variables
|
;;; Internal variables
|
||||||
|
Loading…
x
Reference in New Issue
Block a user