1307 Commits

Author SHA1 Message Date
Noam Postavsky
58b88d8be6 Merge: doc style improvements 2018-03-04 19:05:57 -05:00
Noam Postavsky
d364425176 * yasnippet.el (yas-field-value): Fix docstring. 2018-03-04 19:02:36 -05:00
Noam Postavsky
3032337831 Improve rendering of docstrings in manual's reference section
* doc/yas-doc-helper.el (yas--org-raw-html): Accept an ATTRS argument.
(yas--document-symbol): Render variables with <code
class='variable>... and functions with <code
class='function'>... instead of =...=.  Render indented lisp
forms (recognized as lines beginning 4+ spaces followed by open paren)
with #+BEGIN_SRC elisp...#+END_SRC.  Render \\{keymap} with
substitute-command-keys and #+BEGIN_EXAMPOE...#+END_EXAMPLE.  Link
"Info node `(manul) Node Name'" to gnu.org manual page.
* yasnippet.el (yas-prompt-functions): Add spaces to make example lisp
form be recognized as lisp.
2018-03-04 19:02:36 -05:00
Noam Postavsky
e261832b1a Add some styling to doc, improve top menu
* doc/snippet-expansion.org:
* doc/snippet-organization.org: Fix typos.
* doc/stylesheets/manual.css: Add some simple styling.  Mainly, this
sets 'max-width' for the main text, and centers it.  Adjust the
background color.
* doc/nav-menu.html.inc: Adjust 'class' of top menu.
* doc/yas-doc-helper.el (yas--make-preamble): New function, used for
:html-preamble.  It sets the element for the current page in the top
menu as bolded text to aid navigation.
* doc/stylesheets/styles.css: Remove, it was unused since the old rst
manual was removed.
2018-03-04 19:02:24 -05:00
Noam Postavsky
0afc638e16 Fix docs for new org mode
* Rakefile: Comment to remind me how to run it.
* doc/snippet-expansion.org:
* doc/snippet-menu.org: It seems org 9.x got a bit stricter about link
formatting.  Cross-file links *must* use the 'file:' prefix.
* doc/yas-doc-helper.el (yas--document-symbol): Org 9.x also got a bit
more strict about empty lines between a node and its property list.
Make sure not to put a blank line between variable nodes and the
property list.
2018-03-04 18:56:26 -05:00
Noam Postavsky
3d7cafccf8 Make yas-snippet-mode-buffer-p robust against symlinks
* yasnippet.el (yas-snippet-mode-buffer-p): Instead of a string
comparison of file names to check whether the buffer file is in on of
the `yas-snippet-dirs', use the builtin `file-in-directory-p'
function.
2018-02-18 07:59:33 -05:00
Noam Postavsky
cf23537279 Fix expansion of commands snippet
The previous changed failed to account for command snippets which have
lists for bodies, not strings.
* yasnippet.el (yas-expand-snippet): Don't error if SNIPPET is a list
representing a command snippet body.
* yasnippet-tests.el (yas-expand-command-snippet): New test.
2018-02-13 09:02:23 -05:00
Noam Postavsky
c9277d326e Change yas-lookup-snippet to return a yas--template struct
This allows proper handling of a snippet's expand-env field when doing

    (yas-expand-snippet (yas-lookup-snippet NAME))

* yasnippet.el (yas-expand-snippet): Return the yas--template struct
instead of snippet body.
(yas-expand-snippet): Let first argument be a yas--template struct.
* yasnippet-tests.el (snippet-lookup, snippet-load-uuid): Update tests
accordingly.
(yas-lookup-snippet-with-env): New test.
2018-02-11 17:42:24 -05:00
Noam Postavsky
05ac1da894 ; yasnippet-tests.el (yas-no-memory-of-bad-snippet): Fix docstring. 2018-02-07 18:37:00 -05:00
Noam Postavsky
caf3dba320 Don't use global variable for backquote expression locations
* yasnippet.el (yas--backquote-markers-and-strings): Remove.
(yas--save-backquotes): Return list of backquote expressions.
(yas--restore-backquotes): Receive it as a parameter.
(yas--snippet-parse-create): Keep it in a local variable.
* yasnippet-tests.el (yas-no-memory-of-bad-snippet): New test.
2018-02-04 19:13:48 -05:00
Noam Postavsky
7c9edb5b34 ; doc/snippet-development.org: Further copy edit. 2018-02-02 09:57:16 -05:00
Joerg Bornemann
60666310af Fix typos in "Writing Templates" documentation
* doc/snippet-development.org: Fix typos.

Copyright-paperwork-exempt: yes
2018-02-02 09:53:32 -05:00
Noam Postavsky
ba73f20bc3 Bind field skip and clear command conditionally
Rather than embedding the conditionality inside the function body, and
hardcoding fallback to `delete-char'.  This allows users who want, for
example, to use backspace for field skipping to simply do

    (define-key yas-minor-mode-map (kbd "DEL")
      yas-maybe-skip-and-clear-field)

* yasnippet.el (yas-skip-and-clear-field, yas-current-field)
(yas--maybe-clear-field-filter): New command and function, extracted
from yas-skip-and-clear-or-delete-char.
(yas-skip-and-clear-or-delete-char): Mark obsolete.
(yas-maybe-skip-and-clear-field): New constant, for conditional
binding.
(yas-keymap): Bind it to `C-d' instead of
`yas-skip-and-clear-or-delete-char'.
* yasnippet-tests.el (delete-numberless-inner-snippet-issue-562): Use
`yas-skip-and-clear-field' instead of
`yas-skip-and-clear-or-delete-char'.
2018-02-02 09:52:10 -05:00
Noam Postavsky
074d670be4 Add yasnippet-unload-function
* yasnippet.el (yasnippet-unload-function): New function.
* yasnippet-debug.el (yas-exterminate-package): Remove, it was only
doing a partial job of undoing modes, and uninterning is entirely not
needed.
* yasnippet-tests.el (yas-unload): New test.
2018-01-31 08:11:04 -05:00
Noam Postavsky
e35c031410 * yasnippet.el (yas--guess-snippet-directories): Guess major mode first. 2018-01-31 07:44:35 -05:00
Noam Postavsky
2e69471df2 ; yasnippet-debug.el: macroexp-progn is not avaiable in Emacs 23. 2018-01-31 07:39:37 -05:00
Noam Postavsky
ff8e833375 ; yasnippet-debug.el: Fix deprecation warning. 2018-01-31 07:37:48 -05:00
Noam Postavsky
6ffd1c7950 ; .travis.yml: Test with 25.3 and 26 prelease. 2018-01-31 06:36:35 -05:00
Noam Postavsky
fe9f8b6c98 ; yasnippet-debug.el: Update yas-debug-snippets arg for previous change. 2018-01-31 06:34:43 -05:00
João Távora
8b421bc78d Reinstate the old debug behaviour for yas-tryout-snippet
During a redesign of the debug facilities, the old shortcut C-u C-t
available and useful in snippet-mode, was lost.

* yasnippet-debug.el (yas-debug-snippets): Add docstring.
Add post-command-hook locally if HOOK is snippet-navigation.
Concisely describe parent field (not just mention it).

* yasnippet.el (yas-tryout-snippet): Call yas-debug-snippets and display
buffer.  Tweak docstring.
(yas-debug-snippets): Forward declare function defined in
yasnippet-debug.el
2018-01-24 22:45:14 +00:00
João Távora
ff26e3ba7f Close #824: Simple fields can be parented like other fields or mirrors
The fact that they didn't prevented a deletion of the parent field to
also delete the child, confusing snippet navigation.

* yasnippet-tests.el (delete-nested-simple-field-issue-824): Add a
test for this issue.

* yasnippet.el (yas--calculate-simple-fom-parentage): Renamed from
yas--calculate-mirrors-in-fields.  Generalize to FOMs.
(yas--transform-mirror-parse-create): Call yas--simple-fom-create
and yas--calculate-simple-fom-parentage.
(yas--simple-fom-create): Rename from
yas--simple-mirror-parse-create.  Call
yas--calculate-simple-fom-parentage also for fields.
2018-01-24 22:45:02 +00:00
Noam Postavsky
16c2b38bce Update `yas--take-care-of-redo' call in buffer undo list
On 2018-01-01 "Fix undo when first line indentation moves snippet
forward", `yas--take-care-of-redo' removed the BEG and END arguments,
but the call added to `buffer-undo-list' from `yas--snippet-revive',
was not updated accordingly.

* yasnippet.el (yas--snippet-revive): Remove `beg' and `end' from
`yas--take-care-of-redo' entry.
* yasnippet-tests.el (undo-redo): New test.
2018-01-21 15:13:25 -05:00
Noam Postavsky
203059a95e * yasnippet.el (yas-key-syntaxes): Prefer the longest key. 2018-01-11 18:33:53 -05:00
Noam Postavsky
ad3a4d192d Don't use prog-mode in older Emacs
* yasnippet.el (snippet-mode): Derive from prog-mode only if it's
fbound.
* yasnippet-tests.el (extra-modes-parenthood)
(loading-with-cyclic-parenthood): Fix comment typo.
2018-01-11 18:28:41 -05:00
Noam Postavsky
d806b04fc0 * yasnippet.el (snippet-mode): Derive from prog-mode. 2018-01-11 18:28:41 -05:00
Noam Postavsky
04062d8b4f Don't set yas-selected-text to non-selected text
* yasnippet.el (yas-expand-snippet): Only use the `to-delete' text if
`region-active-p' return true.
* yasnippet-tests.el (expand-with-unused-yas-selected-text): New test.
2018-01-02 21:24:48 -05:00
Noam Postavsky
ce11fd6690 * yasnippet.el (yas-reload-all): Mention if no snippets were found. 2018-01-01 15:11:56 -05:00
Noam Postavsky
b1ca219706 Remove submodules (snippet and yasmate)
* snippets:
* yasmate: Remove.
* README.mdown: Suggest yasnippet-snippets and yasmate as possible
things to download rather than submodules.
* yasnippet.el (yas-installed-snippets-dirn): Mark obsolete.
(yas-snippet-dirs): Remove `yas-installed-snippets-dir' from
default value.
2018-01-01 15:11:55 -05:00
Noam Postavsky
ee81da91d9 Allow "# --" end-of-header marker to have trailing space
* yasnippet.el (yas--parse-template): Allow trailing space after "#
--" marker.
2018-01-01 15:09:32 -05:00
Noam Postavsky
1292cd263a Refactor undo tests
* yasnippet-tests.el (yas-test-expand-and-undo): New helper function.
(undo-indentation-1, undo-indentation-2, undo-indentation-multiline-1)
(undo-indentation-multiline-2): Use it.
2018-01-01 15:07:01 -05:00
Noam Postavsky
7ea1305e67 Fix undo when first line indentation moves snippet forward
* yasnippet.el (yas--first-indent-undo, yas--get-indent-undo-pos):
Remove.
(yas-expand-snippet): Move undo-related code from here...
(yas--snippet-create): ... to here.  Collect undo information from
yas--indent in the normal, unsuppressed way.
(yas--indent-region): Don't collect undo information specially.
(yas--take-care-of-redo): Remove unused parameters.
* yasnippet-tests.el (undo-indentation-1): Rename from
undo-indentation.
(undo-indentation-2): New test.
(undo-indentation-multiline-1): Rename from
undo-indentation-multiline.
(undo-indentation-multiline-2): New test.
2018-01-01 15:07:01 -05:00
Noam Postavsky
e200a3b9b1 Let snippet insertion trigger active field clearing.
* yasnippet.el (yas-expand-snippet): Since the actual insertion must
happen with modification hooks inhibited, we can't rely on that
mechanism to clear the field.  Call yas--skip-and-clear-field-p on the
active field.
2018-01-01 14:59:25 -05:00
Juergen Hoetzel
ece7935d7a * yasnippet.el (yas--message): Fix invalid docstring reference.
Copyright-paperwork-exempt: yes
2018-01-01 14:44:09 -05:00
Kaligule
acec3ba3ae * doc/faq.org: Fix typo.
Copyright-paperwork-exempt: yes
2018-01-01 14:42:27 -05:00
Noam Postavsky
0b8d43490c Unset autoload-compute-prefixes for utility files
* yasnippet-debug.el:
* yasnippet-tests.el: Set autoload-compute-prefixes to nil
file-locally.
2018-01-01 12:59:52 -05:00
Noam Postavsky
4ab9cb5bac Set test to fail with newer org version
* yasnippet-tests.el (yas-org-native-tab-in-source-block): Expect to
fail for org 9.x.
2017-11-25 18:01:28 -05:00
Noam Postavsky
35a4df769c Let whitespace-global-mode work in new snippet buffers
* yasnippet.el (yas-new-snippet-buffer-name): New constant, holds the
name of new snippet buffers.  Change it to "+new-snippet+" to avoid
the leading "*" from fooling whitespace-global-mode into thinking it
shouldn't activate.
(yas-new-snippet):
* yasnippet-tests.el (snippet-save): Use the constant instead of
hardcoding the literal string.
2017-09-23 19:46:07 -04:00
Noam Postavsky
1fc34266a4 Add test relying on overlay hook inhibition in `yas-expand-snippet'
* yasnippet-tests.el
(insert-snippet-with-backslashes-in-active-field): New test.
2017-09-23 19:38:57 -04:00
Noam Postavsky
ba4e5c1736 * yasnippet-debug.el (yas-debug-snippet): Handle non-numbered fields. 2017-09-23 18:32:57 -04:00
Noam Postavsky
89eb7ab64d Release 0.12.2
* NEWS: Add changes for 0.12.2.
* yasnippet.el: Bump version.
* snippets: Update submodule.
0.12.2
2017-08-28 22:08:58 -04:00
Noam Postavsky
c79c8df599 Add yas-also-indent-empty-lines to allow old indent behavior
* yasnippet.el (yas-also-auto-indent-first-line): New option.
(yas--indent-region): Also indent empty lines if it's set.
* yasnippet-tests.el (yas-also-indent-empty-lines): New test.
2017-08-18 22:16:45 -04:00
Noam Postavsky
e371c119ec Don't keep region active when expanding from keymap
* yasnippet.el (yas-expand-snippet): Only keep region active if we are
going to field $0 and it has some text.
2017-08-08 12:40:33 -04:00
Noam Postavsky
0463c75b63 Release 0.12.1
* NEWS: Changes for 0.12.1.
* yasnippet.el (yas--version): Bump version number.
0.12.1
2017-07-23 18:30:56 -04:00
Noam Postavsky
dd65fe6186 Add compile_all target, fix all compilation warnings
* Rakefile (.elc): Set byte-compile-force-lexical-warnings when
compiling.
(:compile_all): New target that compiles yasnippet-debug.el and
yasnippet-tests.el too.
* .travis.yml (script): Use it instead of `compile'.  Update cl-lib to
0.6.1.  Don't error on warnings for Emacs 24.3 on yasnippet-tests.el.
* yasnippet-debug.el: Don't use `yas--loaddir' if it's not
bound (e.g., when compiling).  Require `color' and `edebug' at
toplevel.  Check if `subr-x' defines `when-let'.
(yas-debug-snippet-vars): Remove, it was unused and broken.
* yasnippet-tests.el (yas-with-snippet-dirs, (yas-should-expand)
(yas--collect-menu-items, yas-should-not-expand, yas-mock-insert)
(yas-mock-yank, yas--key-binding, yas-make-file-or-dirs)
(yas-variables, yas-call-with-saving-variables)
(yas-call-with-snippet-dirs, special-mode, string-suffix-p): Move to
top section.
(yas-tests--ran-exit-hook): Rename from yas--ran-exit-hook, and move
to top-level.
* yasnippet.el (yas--letenv): Evaluate the FORMs of ENV.
2017-07-23 08:11:36 -04:00
Stefan Monnier
304c01a44a Fix some compilation warnings
* yasnippet-debug.el (yas--condition-cache-timestamp): Move it before first use.
(yas-debug-live-marker, yas-debug-live-range, yas-debug-snippet-vars)
(yas-debug-process-command-line): Remove or mark unused
variable/parameters.
(yas--letenv): Use `cl-progv'.
(yas--mirror-update-display): Remove unused SNIPPET parameter, update
caller.
2017-07-23 08:11:35 -04:00
Pierre Téchoueyres
7365f9ed40 Avoid to indent snippets having setup `(yas-indent-line 'fixed)'
Avoid `yas--auto-fill' call to `yas--update-mirrors' without setting
the snippet environment.

* yasnippet.el (yas--auto-fill): Reinstate snippet environment before
calling `yas--update-mirrors'.
2017-07-23 07:18:20 -04:00
Noam Postavsky
75cbf7251b Update NEWS, version number to 0.12, and snippets submodule
* NEWS: Update for 0.12 changes.
* snippets/: Update to latest.
* yasnippet-debug.el:
* yasnippet-tests.el:
* yasnippet.el: Update copright years.  Update version number to
0.12.0.
0.12.0
2017-07-17 22:46:04 -04:00
Noam Postavsky
2a3a0cd2b1 Update CONTRIBUTING.md information
* README.mdown: Note that bugs can be submitted to main Emacs list.
* CONTRIBUTING.md: Fix double spacing, remove carriage returns.
Tighten up commit message example.
2017-07-16 19:38:41 -04:00
Noam Postavsky
1436d211d2 ; Merge yasnippet-debug.el updates 2017-07-16 15:23:04 -04:00
Noam Postavsky
164acd6869 * yasnippet-debug.el (yas-debug-snippet): Show modified flag. 2017-07-16 15:19:35 -04:00