788 Commits

Author SHA1 Message Date
Noam Postavsky
5534cab0b7 Respect yas-indent-line for mirror updates
* yasnippet.el (yas--mirror-update-display): Check yas-indent-line
before indenting.
2016-12-02 19:43:54 -05:00
Noam Postavsky
7b013dbbdb Keep yas--snippets-at-point for compatibility
While officially it was an "internal" function, there were at least 2
other packages using it.

* yasnippet.el (yas--snippets-at-point): Restore as obsolete alias of
yas-active-snippets.

Close #754.
2016-12-01 18:20:09 -05:00
Noam Postavsky
2ca6321b47 Promote yas--snippets-at-point to a public API
* yasnippet.el (yas-active-snippets): Rename from
yas--snippets-at-point, adjust callers.  Handle arbitrary positions and
ranges as a parameter.
* yasnippet-tests.el (nested-snippet-expansion): New test.
2016-11-30 20:54:55 -05:00
João Távora
8412d71e44 Reword #744 yet again
* yasnippet.el (yas-reload-all): Simplify message form.
2016-11-10 20:26:47 +00:00
João Távora
80a1098493 Rework yas-reload-all message introduced by #744
* yasnippet.el (yas-reload-all): Reword final message regarding
snippet loading.
2016-11-10 14:30:54 +00:00
Bost
4fa52e6ac2 Improve final message produced by yas-reload-all
* yasnippet.el (yas-reload-all): Clarify message.

Copyright-paperwork-exempt: yes
2016-11-09 21:47:44 -05:00
Noam Postavsky
e6b8651277 * NEWS: Update for 0.11.0.
* snippets/: Update snippets submodule.

* yasnippet.el: Bump version number.
2016-10-26 19:01:49 -04:00
Александар Симић
eaaec309b1 Replace all occurances of `capitaomorte'
* CONTRIBUTING.md:
* NEWS:
* README.mdown:
* doc/index.org:
* doc/nav-menu.html.inc:
* yasnippet.el: Since the new repo destination is now under
`joaotavora', fix all the stale links to point to the new destination.

Copyright-paperwork-exempt: yes
2016-10-22 09:46:15 -04:00
Noam Postavsky
1532e66d76 Fix saving of new snippets
`buffer-file-name' is a permanent buffer-local variable, so if we reuse
the "*new snippet*" buffer, we could end up visiting the last new
snippet's file.

* yasnippet.el (yas-load-snippet-buffer-and-close): Rename the "*new
snippet*" buffer when making it visit a file.
2016-09-24 23:01:38 -04:00
Stefan Monnier
5264379908 Cleanup redundant cl dependency, :group & :require
* yasnippet.el: Replace calls to cl functions with cl- prefixed cl-lib
equivalents.  Use #' to quote function symbols.
(yas-snippet-dirs, yas-new-snippet-default, yas-prompt-functions):
(yas-indent-line, yas-also-auto-indent-first-line):
(yas-snippet-revival, yas-triggers-in-field):
(yas-fallback-behavior, yas-choose-keys-first, yas-choose-tables-first):
(yas-use-menu, yas-trigger-symbol, yas-wrap-around-region):
(yas-good-grace, yas-visit-from-menu, yas-expand-only-for-last-commands):
(yas-field-highlight-face, yas--field-debug-face): Remove redundant
:group.
(yas-snippet-dirs, yas-global-mode): Remove :require.  The :set value
for yas-snippet-dirs checks if yas-reload-all is fbound, and the
autoload cookie on yas-global-mode makes :require redundant.
2016-08-01 14:42:58 -04:00
Sudarshan Gaikaiwari
7e0a0de499 Use new name of python-in-string/comment in docs
* doc/snippet-expansion.org:
* yasnippet.el (yas-buffer-local-condition): python.el renames
python-in-string/comment to python-syntax-comment-or-string-p.  Modify
the documentation to reflect that.

Copyright-paperwork-exempt: yes

Close #725
2016-07-23 08:10:48 -04:00
Noam Postavsky
5af9276f21 Support yas/ symbols in yas-define-menu
These symbols were overlooked in backporting because they're not bound
or fbound.

* yasnippet.el (yas--define-menu-1): Rewrite with `cl-loop', and support
yas/ prefixed symbols.
2016-07-19 20:23:12 -04:00
Noam Postavsky
dc098cf23e Fix yas--message verbosity levels
The yas--message function was comparing with `>' instead of `>=', which
meant it was quieter than intended (i.e., level 3 message were being
suppressed by defualt).  Also push the "Snippet %d exited" message up to
level 4, so the net effect should actually be quieter than before for
normal usage (the only level 3 messages are now for loading and saving
snippets).

* yasnippet.el (yas--message): Fix off-by-1 error.
(yas--load-snippet-dirs): Lowest yas--message level should be 1, not 0.
(yas--commit-snippet): "Snippet %d exited" is more of a debug message,
put it at level 4.
2016-07-18 21:44:33 -04:00
Noam Postavsky
3129040fe3 Load snippet after saving
* yasnippet.el (yas-maybe-load-snippet-buffer): New function.
(snippet-mode): Add it to `after-save-hook'.
2016-07-18 21:44:33 -04:00
João Távora
0ee86a2d1e Simplify `yas-new-snippet' load&save logic
Two significant changes:

1. The criteria for offering to save in upon
   `yas-load-snippet-buffer-and-close' is much simplified, and relies
   on `buffer-modified-p' solely.

2. C-x C-s snippet after `yas-new-snippet' or `yas-visit-snippet'
   suggests at least a sensible directory.

Still missing in this commit is the suggestion for loading upon
saving. The `after-save-hook' could be used for something like that.

* yasnippet.el (yas-new-snippet): Set `default-directory' based on
result of `yas--guess-snippet-directories'.
(yas-load-snippet-buffer): Return template object.
(yas-load-snippet-buffer-and-close): Simplify.
(yas--visit-snippet-file-1): Also set `default-directory' here.
(yas--guess-snippet-directories-1): Return directory names, i.e., ending
in slash.
2016-07-18 21:26:01 -04:00
Paul Eggert
ea9581fb19 Fix some quoting problems in doc strings
Most of these are minor issues involving, e.g., quoting `like this'
instead of 'like this'.  A few involve escaping ` and ' with a
preceding \= when the characters should not be turned into curved single
quotes.
2016-07-18 21:25:11 -04:00
Noam Postavsky
9500b000fd Fix field navigation in the backwards direction
* yasnippet.el (yas--find-next-field): For negative N, actually give the
Nth previous field, not the 1st field.
* yasnippet-tests.el (field-navigation): Add a 3rd field, and test
calling `yas-prev-field' while on it.

Fixes #722.
2016-07-13 17:03:30 -04:00
Noam Postavsky
0db65ee0bb Don't clobber match data in modification hooks
Since modification hooks run just after any function that changes buffer
contents, it's important to save the match data, or else the code doing
the modification can become really confused.  See also Emacs bugs #23917
and #23869.

* yasnippet.el (yas--on-field-overlay-modification): Wrap main body in
`save-match-data'.
2016-07-12 20:13:59 -04:00
Noam Postavsky
7661dc161d yasnippet.el (yas-escape-text): No error on nil text 2016-07-05 23:39:07 -04:00
Noam Postavsky
42b0c269ca Don't warn about modifications to other buffers
* yasnippet.el (yas--save-backquotes): Detect changes only in buffer
where snippet is being expanded.
2016-07-05 23:38:09 -04:00
Akinori MUSHA
d4da806e5c Fix removal of snippets by uuid
* yasnippet.el (yas--remove-template-by-uuid): Test uuid equality with
`equal' instead of `eq'.

Copyright-paperwork-exempt: yes

Close #714
2016-07-05 23:18:35 -04:00
Noam Postavsky
4296a86139 yasnippet.el (yas--quote-string): Remove. 2016-06-29 22:22:00 -04:00
rubikitch
8907fd1d42 Escape yas-selected-text for new snippet.
* yasnippet.el (yas-escape-text): New function.
(yas-new-snippet-default): Call it on yas-selected-text.

Close #709.
2016-06-29 22:22:00 -04:00
João Távora
d218ed8b1b Do indent the first line of mirrors, but in correct order
This changes the strategy for fixing #712 to a simpler alternative,
which doesn't remove the benefits of indenting single line mirrors.

It reverts the functional parts of commit
351c1e3dcbb73e3154aae0755d5b7016f1561ebc, while keeping the tests.

* yasnippet.el (yas--update-mirrors): Sort mirrors to be updated by
  start position.
2016-06-24 13:17:34 +01:00
Noam Postavsky
351c1e3dcb Don't indent first line of mirrors
* yasnippet.el (yas--mirror-update-display): Don't indent the first line
of mirror output (meaning no indentation happens if there is a single
line).
* yasnippet-tests.el (single-line-multi-mirror-indentation): New test.
(snippet-with-multiline-mirrors-issue-665): Renamed from
navigate-a-snippet-with-multiline-mirrors-issue-665, test for precise
indentation in addition to navigation (this was already implemented,
contrary to its obsolete docstring).

Fixes #712
2016-06-23 20:09:49 -04:00
Stefan Monnier
ee6e7a9602 Fix some compilation warnings
* yasnippet-tests.el (complicated-yas-key-syntaxes): Avoid looking-back.

* yasnippet.el (yas--font-lock-keywords): Escape $, even if first in the
regexp.
(yas--indent): Remove unused var `end'.
(yas--indent-parse-create): Remove unused arg `snippet'.  Update caller.
2016-06-22 22:50:51 -04:00
Noam Postavsky
6b785e185f Say how to hide the backquote side-effect warning
* yasnippet.el (yas--save-backquotes): Explain how to hide warning in
the warning message.
2016-06-22 19:58:56 -04:00
Noam Postavsky
85f39cec2b Warn about backquote exprs modifying the buffer
* yasnippet.el (yas--save-backquotes): Show a warning if evaluating the
backquote expression modifies the buffer.
2016-06-21 22:10:22 -04:00
Noam Postavsky
ee4efdbbde Revert "Separate parsing from evaluation of backquote lisp"
This reverts commit e21420a497c1d79edc6b36ffb1f3bf1bb70f6227.  This
breaks existing snippets which use side-effecting functions inside
backquotes to insert data instead of return the string to insert.  This
usage will be deprecated, but we still need to support it for at least
another release.

* yasnippet.el (yas--save-backquotes): Go back to interleaved parsing
and evaluating of backquoted lisp forms.
2016-06-21 22:09:28 -04:00
Noam Postavsky
e21420a497 Separate parsing from evaluation of backquote lisp
* yasnippet.el (yas--save-backquotes): Parse all backquoted lisp forms
and only then evaluate them.
2016-06-12 09:20:08 -04:00
Noam Postavsky
c7441486db Make yas-describe-tables easier to use from lisp
* yasnippet.el (yas-describe-table-by-namehash): new function.
(yas-describe-tables): remove query for by-namehash variant, replace
query for non-active tables with prefix arg.
2016-06-11 21:02:01 -04:00
songjie dong
1735a283d2 Add region contents to new snippet
* yasnippet.el (yas-new-snippet-default): Add yas-selected-text.
(yas-new-snippet): Let-bind yas-selected-text to region content.

Copyright-paperwork-exempt: yes
2016-06-11 19:40:54 -04:00
Noam Postavsky
dc3e4ca345 Release 0.10.0
- Update NEWS
- Bump version number
- update snippets submodule
2016-06-11 14:45:42 -04:00
Noam Postavsky
e23a053b00 Avoid bug in insert-file-contents with REPLACE=t
* yasnippet.el (yas--load-directory-2): Call `erase-buffer' before
`insert-file-contents' instead of passing non-nil REPLACE, avoids Emacs
bug #23659.

Fixes #707.
2016-05-30 20:21:19 -04:00
Noam Postavsky
497867cea5 Rename yas-backport-obsolete-alias
* yasnippet.el (yas-alias-to-yas/prefix-p): Rename from
yas-backport-obsolete-alias.
(yas/root-directory): Only define if yas-alias-to-yas/prefix-p is
non-nil.  Mark obsolete.
2016-05-17 19:28:14 -04:00
USAMI Kenta
bbfa1f0c9a Add yas-backport-obsolete-alias option
* yasnippet.el (yas-backport-obsolete-alias): New option.
2016-05-17 08:03:25 -04:00
Noam Postavsky
0d79e6988e Extra measures to prevent premature yas-minor-mode
The user's hooks may try to enable yas-minor-mode before yasnippet.el
has finished loading.  In [1], we catch and ignore the errors arising
from this, but it's better if we can avoid hitting the error in the
first place.

This means we have 3 separate measures to avoid the problem, but since
this bug can leave Emacs unusable due to a failing post-command-hook,
a bit of redundant safety is not a bad thing.

* yasnippet.el (yas-minor-mode): Only turn on if yasnippet is fully
loaded.
(yas--font-lock-keywords): Disable user hooks.

[1]: "Avoid potential problems with user's hooks"
4c6064ce1aff07fe4481b5e2d987c8a7f044c207
2016-05-14 07:18:38 -04:00
Noam Postavsky
1b8f5b7a72 Don't use major-mode syntax-propertize-function
during snippet creation.  The snippet creation manipulates the
syntax-table which can lead to conflicts (see also
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23443).

* yasnippet.el (yas-expand-snippet): Let-bind syntax-propertize-function
to nil and then call syntax-ppss-flush-cache afterwards.
2016-05-12 05:41:08 -04:00
Noam Postavsky
6180cc4059 Fix field transform application in yas-next-field
* yasnippet.el (yas--apply-transform): Don't let-bind yas-moving-away-p
to nil, it's nil by default.
(yas-next-field): Call `yas--field-update-display' instead of only
calling `yas--eval-lisp' so that the result of the transform is inserted
into the buffer.
2016-05-12 04:57:08 -04:00
Noam Postavsky
6f97316551 Fix outdated and misformatted docs
yas-find-snippets was removed by [1].

* doc/snippet-development.org: Add keybindings on same line as command
names, fixup intra document links, and remove mention of non-existent
command yas-find-snippets.
* yasnippet.el (yas-load-snippet-buffer):
(yas-load-snippet-buffer-and-close): Fix docstring formatting.

[1]: "cleanup: remove `yas/find-snippets\', complicated and no one seems
to use it anyway" 29 May, 2012 433c93746534ebb062afe4dbc7690f736be72d42.
2016-05-10 12:24:25 -04:00
Noam Postavsky
e9406f5126 Document $> and fix escaping
* doc/snippet-development.org: New "Indentation markers" section.
* yasnippet-tests.el (indentation-markers): New test.
* yasnippet.el (yas--indent-markers): New variable.
(yas--indent): Use it instead of searching for $> directly.
(yas--indent-parse-create): New function, records occurences of $> into
`yas--indent-markers'.
(yas--snippet-parse-create): Call it.
2016-05-08 15:32:20 -04:00
Noam Postavsky
146b161112 Don't indent empty lines in snippet expansion
* yasnippet.el (yas--indent-region): Indent only non-empty lines.
* yasnippet-tests.el (basic-indentation): Add empy and non-empty (but
blank) lines in test snippet.
2016-05-04 12:35:48 -04:00
Noam Postavsky
bdfab67eac Make yasnippet less chatty
Make sure output that occurs in normal use goes to verbosity levels 3 or
higher, and level 2 and below are reserved for something unexpected
happening.  Level 3 (the new default) should be a reasonably quiet but
informative level.

* yasnippet.el (yas--read-keybinding, yas--safely-run-hooks):
(yas--on-protection-overlay-modification): Put warnings at verbosity
level 2.
(yas--load-yas-setup-file, yas-load-directory):
(yas--load-directory-1, yas--load-snippet-dirs):
(yas-expand-snippet, yas--load-pending-jits): Put per-file loading and
other debug messages at level 4.
(yas-load-snippet-buffer, yas--template-get-file, yas-reload-all): Put
top level loading messages at level 3 (or 2 if there were errors).
(yas--define-menu-1, yas-insert-snippet, yas-tryout-snippet): Put error
messages at level 1.
(yas-verbosity): Reduce default verbosity to level 3.
2016-05-01 21:41:42 -04:00
Noam Postavsky
beb2ba4d7f Fix fields following $0 + region insertion
When inserting text due to a  non-nil yas-wrap-around-region and the
snippet had fields occuring later in the buffer than $0, the insertion
of the text was shifting the location of later fields, thus invalidating
the calculation of yas--dollar-regions.

* yasnippet.el (yas--simple-mirror-parse-create): Don't insert text fo
yas-wrap-around-region here.
(yas--snippet-parse-create): Do it here, after deleting
`yas--dollar-regions`, instead.
2016-04-30 20:19:12 -04:00
Noam Postavsky
db4cd31a11 Delete active region for trigger key expansion
This makes yas-expand-from-trigger-key consistent with
yas-insert-snippet.

* yasnippet.el (yas-expand-from-trigger-key): Expand start end interval
with active region.
2016-04-30 20:19:12 -04:00
Noam Postavsky
5d44a9f15e Revert "Disable region wrapping for trigger key expansion"
This reverts commit f8d1af1f50f42ac1689c583c152c3b15e8774ae4.

Disabling this for trigger key introduced an inconsistency that is more
complicated to implement and document than simply fixing region wrapping
for trigger key expanded snippets.
2016-04-30 20:17:38 -04:00
Noam Postavsky
e37ce9e488 Disable region wrapping for trigger key expansion
It's too awkward to highlight the relevant text while maneuvering point
in front of the trigger key.

* yasnippet.el (yas-expand-from-trigger-key): Let-bind
yas-wrap-around-region to nil if it was t.
* doc/snippet-expansion.org: Document it.
2016-04-30 20:10:01 -04:00
Noam Postavsky
c1b2cb7c5e Improve documentation for new register option
* doc/snippet-expansion.org: Add new section about
yas-wrap-around-region.
* yasnippet.el (yas-wrap-around-region): Improve docstring.
2016-04-30 20:10:01 -04:00
Noam Postavsky
ccc9adc3c4 Add register option for yas-wrap-around-region
Replace `cua' setting with more general behaviour that can use any given
register.  A `cua' setting is converted to ?0 for backwards
compatibility.

* yasnippet.el (yas--simple-mirror-parse-create): Use contents of any
  register depending on `yas-wrap-around-region' value.
(yas-wrap-around-region): Update docstring.
2016-04-30 20:10:01 -04:00
João Távora
eca2f995c1 Indent multi-line output from mirrors
* yasnippet.el (yas--indent-region): Adapted and redesigned from
`yas--indent-according-to-mode'
(yas--indent-according-to-mode): Deleted.
(yas--indent): Use `yas--indent-region'.
(yas--real-line-beginning): Deleted.
(yas--update-mirrors): Always re-place active field overlay if it
exists.  Pass the snippet to `yas--mirror-update-display'.
(yas--mirror-update-display): Indent the mirror text after
inserting the reflection.
2016-04-30 19:00:53 -04:00