[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 14819c9 28/63: Make yas-buffer-local-condition into a defc
From: |
Noam Postavsky |
Subject: |
[elpa] master 14819c9 28/63: Make yas-buffer-local-condition into a defcustom |
Date: |
Mon, 17 Jul 2017 22:54:14 -0400 (EDT) |
branch: master
commit 14819c931f35aaa8d6ee0e60431801a7709ad93e
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
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.
---
doc/snippet-expansion.org | 5 +++--
yasnippet.el | 22 ++++++++++++++++++++--
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/doc/snippet-expansion.org b/doc/snippet-expansion.org
index 9b9f45b..3ee0adf 100644
--- a/doc/snippet-expansion.org
+++ b/doc/snippet-expansion.org
@@ -181,8 +181,9 @@ In particular, the following things matter:
- Buffer-local
[[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] variable
This variable provides finer grained control over what snippets can
- be expanded in the current buffer. You could disable snippet
- expansion inside comments or string literals for example. See
[[condition-system][the
+ be expanded in the current buffer. For example, the constant
+
[[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.
** The condition system <<condition-system>>
diff --git a/yasnippet.el b/yasnippet.el
index 933f4ac..7b871b9 100644
--- a/yasnippet.el
+++ b/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.")
-(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.
This variable is a Lisp form which is evaluated every time a
@@ -503,7 +513,15 @@ conditions.
(setq yas-buffer-local-condition
\\='(if (python-syntax-comment-or-string-p)
\\='(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
- [elpa] master 5534cab 07/63: Respect yas-indent-line for mirror updates, (continued)
- [elpa] master 5534cab 07/63: Respect yas-indent-line for mirror updates, Noam Postavsky, 2017/07/17
- [elpa] master c485d13 04/63: Remove last use of flet, Noam Postavsky, 2017/07/17
- [elpa] master 80a1098 02/63: Rework yas-reload-all message introduced by #744, Noam Postavsky, 2017/07/17
- [elpa] master 28d5496 11/63: Use git describe for doc HTML output, Noam Postavsky, 2017/07/17
- [elpa] master cce2e0d 09/63: Make the documentation build reproducible, Noam Postavsky, 2017/07/17
- [elpa] master 2ca6321 05/63: Promote yas--snippets-at-point to a public API, Noam Postavsky, 2017/07/17
- [elpa] master 9abf842 19/63: Enable snippet-mode automatically, Noam Postavsky, 2017/07/17
- [elpa] master 48cd716 14/63: Use more compact format for snippet menus, Noam Postavsky, 2017/07/17
- [elpa] master b62cf52 23/63: Remove lambda list building hack, Noam Postavsky, 2017/07/17
- [elpa] master 7b3c29d 13/63: * doc/faq.org: Typos and grammar., Noam Postavsky, 2017/07/17
- [elpa] master 14819c9 28/63: Make yas-buffer-local-condition into a defcustom,
Noam Postavsky <=
- [elpa] master f3d0e03 25/63: * yasnippet-tests.el (snippet-exit-hooks): New test., Noam Postavsky, 2017/07/17
- [elpa] master 4ee3835 08/63: Use expand-env for all snippet evaluations, Noam Postavsky, 2017/07/17
- [elpa] master 203df22 22/63: Use debug-on-error to simplify error handling, Noam Postavsky, 2017/07/17
- [elpa] master 9c9547a 21/63: Don't catch and rethrow yas-{-}exception, Noam Postavsky, 2017/07/17
- [elpa] master e878afb 12/63: Update handling of markers during indentation, Noam Postavsky, 2017/07/17
- [elpa] master 6c4fbb2 24/63: Fix snippet local exit hook, Noam Postavsky, 2017/07/17
- [elpa] master d0c6fec 16/63: Refactor snippet marker manipulating functions, Noam Postavsky, 2017/07/17
- [elpa] master e74f00e 18/63: Fix whitespace lossage between mirrors, Noam Postavsky, 2017/07/17
- [elpa] master 4f37afd 27/63: Let snippets expand in strings/comments by default, Noam Postavsky, 2017/07/17
- [elpa] master cddb826 29/63: Merge: let snippets expand in strings/comments by default, Noam Postavsky, 2017/07/17