1061 Commits

Author SHA1 Message Date
Noam Postavsky
bc80f67782 .travis.yml: Don't notify on success 2016-06-11 19:36:21 -04:00
Noam Postavsky
dc3e4ca345 Release 0.10.0
- Update NEWS
- Bump version number
- update snippets submodule
0.10.0
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
João Távora
47dbe93d86 Fix broken links in README.mdown
After the Github acocunt name change (capitaomorte -> joaotavora), 
most links to repositories are redirected excpect Travis CI and 
Github Pages (documentation).

* README.mdown: Fix documentation and Travis badge links
2016-05-24 08:24:18 +01: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
df229b9ab8 Fix some doc formatting
* doc/snippet-development.org (Template Syntax):
(Placeholder fields, Mirrors): Text inside dedicated target <<angle
brackets>> does not show up in output, so duplicate it.  Add
descriptions to avoid getting numbers instead of names in links.
2016-04-30 22:36:34 -04:00
Noam Postavsky
78fe979b7b Support htmlize.el in Rakefile doc target
Htmlized output can now be produced by

    rake doc[/path/to/htmlize/]

* Rakefile (doc): Add htmlize argument.
* doc/yas-doc-helper.el (yas--generate-html-batch): Tell org to use css
selectors only when exporting htmlized faces.
* doc/stylesheets/manual.css: Add styles for faces used by org export.
2016-04-30 22:36:34 -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
João Távora
eeb4b62efb Add new tests for multi-line mirror indentation
* yasnippet-tests.el (basic-indentation):
(navigate-a-snippet-with-multiline-mirrors-issue-665): New tests.
2016-04-30 18:32:30 -04:00
Noam Postavsky
14f830a37d Test expansion in an empty buffer
* yasnippet-tests.el (yas-should-expand, yas-should-not-expand): Call
`erase-buffer' instead of narrowing.
2016-04-30 18:32:30 -04:00
Noam Postavsky
a87ec549a6 yasnippet.el (yas-next-field-will-exit-p): New function. 2016-04-28 21:27:00 -04:00
Noam Postavsky
cc14db399c Refactor yas-next-field a bit
* yasnippet.el (yas--find-next-field): New function to find target field.
  (yas-next-field): Use it.
2016-04-28 21:26:59 -04:00
Noam Postavsky
bfe14f19ac Test and fix problem with mirror+autofill
cc-mode fill paragraph narrows to the paragraph being filled.  This
causes problems if there is a mirror needing to be updated outside of
the current paragraph.

* yasnippet-tests.el: New test.
* yasnippet.el (yas--update-mirrors): Widen while updating the mirrors.
2016-04-28 21:16:30 -04:00
Noam Postavsky
7799aa908b Document .yas-setup.el
* doc/snippet-organization.org: Explain .yas-setup.el.
2016-04-27 17:08:19 -04:00
Barak A. Pearlmutter
c0032e6e61 chmod -x doc/yas-doc-helper.el 2016-04-27 16:51:03 -04:00
Noam Postavsky
7f03a2319e Change Emacs installation method for Travis CI
* .travis.yml: Don't use sudo, submodules.
(env): Test with additional Emacs versions.
(install): Get Emacs binaries from
https://github.com/npostavs/emacs-travis/releases.  Download ert and
cl-lib if needed.
(script): Split compilation and testing into separate steps.
* Rakefile: Use batch-byte-compile.  Treat compilation warnings as
errors.
2016-04-24 17:29:05 -04:00
Noam Postavsky
567ada01e6 Decide field clearing based on command's effect
In [1] we started deciding clearing based on a command's
delete-selection property, but it turns out that some commands perform
insertion, and optionally use the region's contents.  So these commands
should have a nil delete-selection property, but they still ought to
clear a snippet field when used.

To achieve this, we now check if the command has inserted text in the
post-change hook of the field overlay.

* yasnippet.el (yas--skip-and-clear): Add optional FROM paramter.  Only
clear non-empty fields.
(yas--skip-and-clear-field-p): Check the change start and length
instead of current command delete-selection property.
(yas--on-field-overlay-modification): Perform field clearing on the
post-change call.

[1]: acf2cdd "Decide field clearing commands based on delsel"
2016-04-23 16:36:10 -04:00
Noam Postavsky
4f2aa1526a Only kill snippets for text length change
of protection overlay.  Changes that keep the same length of text are
probably harmless (e.g. just change of text properties).  It's possible
that some harmful changes don't change text length, but the protection
overlays are already unable to catch all important changes since they
only cover 1 character each at the edges.

cc-mode modifies text properties in the buffer to cache parsing results,
therefore it's important that yasnippet not kill yasnippets when parsing
is triggered by a function that only wants to parse the
buffer (e.g. which-function-mode).

* yasnippet.el (yas--on-protection-overlay-modification): Check length
of text change to decide if change is harmful.  Fix docstring.
2016-04-16 11:31:44 -04:00
Stefan Monnier
bd30a30d88 yas-dont-activate is a hook
* yasnippet.el (yas-dont-activate-functions): Rename from yas-dont-activate.
(yas-minor-mode-on): Use run-hook-with-args-until-success instead of
funcall.
2016-04-11 19:05:37 -04:00
BEN ENGLISCH
87710827e9 Don't add useless kill ring entries
while describing snippet tables.  This should also help users of
packages like pbcopy.el (which creates a new process on every
modification of the kill-ring, hence many `kill-region' calls at once
cause Emacs to run out of file descriptors).

* yasnippet.el (yas--create-snippet-xrefs): Use delete-region instead of kill-region.

Copyright-paperwork-exempt: yes

Close #675.
2016-04-10 11:33:31 -04:00
Noam Postavsky
3e67b1bb7b yasnippet.el (snippet-mode): Add autoload cookie. 2016-04-09 19:51:56 -04:00
Noam Postavsky
4c6064ce1a Avoid potential problems with user's hooks
* yasnippet.el (yas--font-lock-keywords): ignore-errors from
emacs-lisp-mode call, in case user's hooks cause problems (e.g. enabling
`yas-minor-mode' before we finish loading).
2016-04-09 19:50:47 -04:00
Noam Postavsky
4af9fc9815 Further cleanup
* yasnippet.el (yas-snippet-dirs): Fix :type.
(yas--modes-to-activate): Add explicit fboundp check instead of
ignore-errors.
(yas--font-lock-keywords): Remove redundant entries.
(yas--guess-snippet-directories): Simplify.
(yas-load-snippet-buffer-and-close): Use read-file-name.
2016-04-08 18:58:17 -04:00
Stefan Monnier
18f7b1b9fe Various cleanup
* yasnippet/yasnippet.el: Add Package-Requires since we use cl-lib.
(yas-installed-snippets-dir, yas--default-user-snippets-dir)
(yas--load-directory-1, yas-load-snippet-buffer-and-close):
Use expand-file-name.
(yas-buffer-local-condition): Let's not quote lambdas.
(yas--modes-to-activate): Fix compiler warning about free `dfs' var and
unused return value of `mapcar'.
(yas-minor-mode): Don't confuse emulation-mode-map-alists for a hook.
(yas--font-lock-keywords): Don't hardcode the name of emacs-lisp-mode's
font-lock keywords.
(yas--calculate-group): Use file-relative-name.
(yas--subdirs): Don't mismatch \n in file name.
(yas-expand-from-trigger-key, yas-tryout-snippet): Prefer numbers to
number names.
(yas--guess-snippet-directories): Use expand-file-name rather than
removing&adding / by hand.
(yas--on-field-overlay-modification): Mark `length' as unused.
(yas--update-mirrors): Try to better fit within 80 columns.
(yas--backported-syms, yas--exported-syms): Don't mismatch \n in
symbol name.
2016-04-08 18:57:48 -04:00
Noam Postavsky
6aeccce2f1 Release 0.9.1
- add NEWS
- update version numbers
- update snippet submodule
0.9.1
2016-04-03 11:30:04 -04:00
Noam Postavsky
115f5ffff0 yasnippet.el (yas--describe-pretty-table): Cleanup. 2016-04-02 10:38:05 -04:00
USAMI Kenta
ea5ed74fb2 Avoid trailing whitespace in snippet tables
* yasnippet.el (yas-describe-tables, yas--describe-pretty-table): Remove
  redundant tail spaces from output.

Copyright-paperwork-exempt: yes
2016-04-02 10:30:10 -04:00
Noam Postavsky
572c73d50b Avoid error in case this-command isn't a symbol.
Fixes #664.

* yasnippet.el (yas--skip-and-clear-field-p): Only get
  `delete-selection' property of `this-command' when it's a symbol.
2016-02-26 16:59:39 -05:00
Noam Postavsky
88b7950554 Reduce `yas-new-snippet-default'
* yasnippet.el (yas-new-snippet-default): Remove
  "require-final-newline: nil", it's redundant since `snippet-mode' already
  sets that.  Also remove the direct-keybinding, since it's hardly ever
  used, and often the literal "# binding: direct-keybinding" ends up in
  actual snippets.
2016-01-31 12:48:06 -05:00
Noam Postavsky
8632262a50 Don't use yas-x-prompt by default
It is not a very pleasant method when there are many values, and
`yas-completing-prompt' will usually do a better job, in addition to
respecting customizations to `completing-read-function'.
`yas-dropdown-prompt' remains in first place, since it only takes effect
if the `dropdown' library is loaded, which likely indicates a preference
for it.

* yasnippet.el (yas-prompt-functions): Remove yas-x-prompt from default value.
2016-01-29 13:57:18 -05:00
Stefan Monnier
42601d2ff8 Apply changes from GNU ELPA
* doc/yas-doc-helper.el:
* yasnippet-debug.el:
* yasnippet-tests.el: Fix up copyright headers.

* yasnippet-tests.el: Fix lexical-binding cookie.
* yasnippet-debug.el: Require cl.

* yasnippet-tests.el: Silence byte-compiler.
(yas-saving-variables, yas-with-snippet-dirs): Move macros before their use.
(yas--barbaz, yas--foobarbaz): Declare.
(yas--phony-c-mode, yas--test-mode, yas--another-test-mode): Move out of
deftest, so the byte-compiler understands they're defined.
2016-01-28 14:36:19 -05:00
Noam Postavsky
80941c077f Update snippets submodule 0.9.1-snapshot 2016-01-22 13:56:26 -05:00
Noam Postavsky
acf2cdd03e Decide field clearing commands based on delsel
* yasnippet.el (yas--skip-and-clear-field-p): Check `delete-selection'
  of `this-command'.

Fix #644, close #645.
2016-01-22 11:45:01 -05:00
João Távora
4a6d923c9d Slightly improve on fix for #515: Refactor code and add tests
While I agree with the solution for #515 in commit 17fe790 for now,
other approaches might be interesting in the future, like clearing on
other types of insertion, not just self-insertion.

So add some tests and refactor a new function that could be used for
that purpose later on. For now, change no behaviour.

* yasnippet-tests.el (dont-clear-on-partial-deletion-issue-515,
  dont-clear-on-yank-issue-515): New tests. (yas-mock-yank): New
  function.

* yasnippet.el (yas--skip-and-clear-field-p): New function.
  (yas--on-field-overlay-modification): Use it.
2016-01-22 11:19:34 -05:00
Noam Postavsky
1a98c38d9c Fix silly mistake in previous commit
* yasnippet.el (yas--load-snippet-dirs): Put `make-directory' call in
  same branch of the `if' as the `dolist' loop.
2016-01-20 09:44:28 -05:00
Noam Postavsky
46256db43d Fix #648; create ~/.emacs.d/snippets automatically
* yasnippet.el (yas--load-snippet-dirs): Create
  yas--default-user-snippets-dir, if needed.
2016-01-20 09:27:24 -05:00