67 Commits

Author SHA1 Message Date
João Távora
73f208d6d5 Internal documentation overhaul. Still unfinished. 2015-04-05 13:51:18 +01:00
João Távora
ad2bb8bed1 Implement protection overlays
* snippet.el (snippet--field-overlay): Make buffer-local and permanent-local.
(snippet--field-protection-overlays): New variable.
(snippet--move-to-field): Also move protection overlays.
(snippet--field-overlay-changed): Don't do anything if undo in
progress or snippet being exited.
(snippet--field-protection-violated): new function.
(snippet--protection-overlay-face): New debug-only face.
(snippet-exit): Rename from `snippet-exit-snippet'
(snippet--exiting-p): New function
(snippet--activate-snippet): Create protection overlays.
(snippet--cleanup): New function.
(snippet--post-command-hook): Use `snippet--exiting-p' and
`snippet--cleanup'.
(snippet--debug-snippet): Consider that `snippet--field-overlay'
is now buffer-local.
2015-04-05 11:54:02 +01:00
João Távora
579ca936d2 Minor tweaks
* snippet.el (with-static-snippet): Move checks for duplicate
&exit to macroexpansion time.
(define-static-snippet): Tweak docstring a bit.
2015-04-04 23:00:32 +01:00
João Távora
2d111e82b1 Minor simplification
(with-static-snippet, with-dynamic-snippet)
(snippet--activate-snippet): Update use of `snippet--make-object'.
(snippet--make-object): Don't take `prev' arg.
2015-04-04 22:38:52 +01:00
João Távora
7a00c79746 Implement snippet exits as snippet fields
* snippet.el (snippet--object-<): New function.
(snippet--make-object): Replace `cl-assert' with ordinary error.
(snippet--open-object, snippet--with-current-object): Remove #'
prefix from lambda.
(snippet-next-field): Exiting is moving to the exit field.
(snippet--activate-snippet): Create exit field here if not created
yet.
(snippet--debug-snippet): Use `snippet--object-<'.
2015-04-04 22:30:33 +01:00
João Távora
59113376aa More simplification
* snippet.el (with-static-snippet, with-dynamic-snippet): Use
`snippet--make-object'.
(snippet--object): Reorder slots to avoid strange eieio bug.
(snippet--make-object): Renamed from
`snippet--call-with-inserting-object'.
(snippet--inserting-object, snippet--make-and-insert-field)
(snippet--make-and-insert-mirror): Deleted.
2015-04-04 17:39:28 +01:00
João Távora
e6f5504dd6 More simplification
* snippet.el (with-static-snippet): Dummy param in lambda to
`snippet--make-and-insert-field'.
(with-dynamic-snippet): Use `snippet--make-and-insert-field' and
`snippet-make-and-insert-mirror'
(snippet--make-and-insert-field): Call function with field.
2015-04-04 16:30:23 +01:00
João Távora
5366d29c64 Prepare for more simplification
* snippet.el (snippet--make-lambda, with-static-snippet): Simplify.
(snippet--make-and-insert-field): Renamed from `snippet--insert-field'
(snippet--call-with-inserting-object): Improve docstring.
2015-04-04 15:44:38 +01:00
João Távora
04591a4a86 Make dynamic version of all tests and fix bugs
* snippet-tests.el (cl-lib): require it
(snippet--fixtures): Renamed from
`snippet--test-snippets-alist'. Add dynamic versions to all tests.
(snippet--get-fixture): Use `snippet--fixtures'

* snippet.el (with-dynamic-snippet): Relax syntax restrictions.
(&mirror): Update edebug spec.
(snippet--call-with-inserting-object): Don't try to set the start
of an object to its previous object's end, if that object hasn't
got an end yet.
(snippet--call-with-inserting-object): Fix previous bugfix.
2015-04-04 15:07:15 +01:00
João Távora
94bd529d08 Fix nesting bug
* snippet-tests.el (nested-skip-fields, navigate-fields-and-exit):
Fix test.
(wrap-selected-region): Use eval trick temporarily.
(snippet--test-fixture): New helper.

* snippet.el (snippet--debug-snippet): More stable sort in
debugging helper.

* snippet.el (with-dynamic-snippet): Fix nesting.
(snippet--call-with-inserting-object): Fix setting the `prev'
slot.
(snippet--call-with-inserting-object): Fix nesting.
2015-04-04 14:13:15 +01:00
João Távora
08784e769f * snippet.el (snippet--debug-snippet): More stable sort 2015-04-04 13:22:21 +01:00
João Távora
d92a479263 Bugfixes
* snippet.el (snippet--post-command-hook): Robustify snippet exit
logic.
(snippet-exit-snippet): Just schedule and exit, but don't exit
directly.
(snippet--activate-snippet): Initialise `snippet--exit-reason' to
nil.
(snippet--activate-snippet): Add to post-command-hook locally.
(snippet--describe-object, snippet--debug-snippet): Fix whitespace
2015-04-04 13:15:59 +01:00
João Távora
91a0b281c7 Improve debugging tool
* snippet.el (define-static-snippet): Fix bug.
(snippet--activate-snippet): Must use `cl-copy-list'
(snippet--describe-object): Changed to generic function.
(snippet--describe-exit, snippet--describe-mirror)
(snippet--describe-field): Part of the generic.
(snippet--debug-snippet): Uses `snippet--describe-object'
2015-04-04 11:50:28 +01:00
João Távora
7750c03f4b Arrange for same tests to run over dynamic fixtures
* snippet-tests.el (snippet--insert-test-snippet): Removed.
(basic-expansion, basic-clear-field, basic-delete-char-in-field)
(contrived, contrived-2, nested-expansion, nested-skip-fields)
(mirror-of-nested-field, more-nesting, printf-expansion)
(printf-mirrors, printf-mirrors-and-navigation)
(printf-jump-to-second-field-right-away, sprintf-variation)
(constants-and-default-values): Converted to
`snippet--define-expansion-test'
(snippet--get-fixture): New function.
(snippet--define-expansion-test): New helper macro.

* snippet.el: Improve documentation slightly.
(define-static-snippet): Take `properties' instead of
`args'. Re-add debug spec.

* snippet.el (define-static-snippet): forms -> snippet-forms
2015-04-03 22:40:32 +01:00
João Távora
00967aa8c0 Minor documentation tweaks
* snippet.el: Improve documentation slightly.
(define-static-snippet): Take `properties' instead of
`args'. Re-add debug spec.
2015-04-03 20:29:46 +01:00
João Távora
42543cd9e2 Better names for dynamic and static version
* snippet-tests.el (snippet--test-snippets-alist): Add static and
dynamic version of snippet to fixture.
(snippet--insert-test-snippet): Aware of dynamic snippets.
(sprintf-variation): Reintegrated deleted `snippet--test-sprintf-snippet'
(snippet--test-sprintf-snippet): Deleted.
(snippet-tests): Provide it.

* snippet.el: Better documentation.
(with-static-snippet): Renamed from `snippet--define-body'.
(define-dynamic-snippet): Renamed from `define-snippet'.
(with-dynamic-snippet): New macro.
2015-04-03 20:17:32 +01:00
João Távora
ece2e7d1f2 snippet-defmacro is the dynamic approach, make-snippet the static one
* snippet-tests.el (snippet--sprintf): Use `define-snippet'

* snippet.el: Pass copyright to FSF. Some doc change.
(snippet--define-body): Docstring update.
(define-snippet): Renamed from `snippet-defmacro'
2015-04-03 12:57:26 +01:00
João Távora
9f88e596bf First working test for the new macrolet approach
* snippet-tests.el: Use `lexical-binding: t`
(snippet--test-sprintf-snippet): New helper.
(sprintf-variation): Use it.
(macro-test): Removed.
(snippet--sprintf): New macrolet-style snippet for testing.
(sprintf-maybe-2): New test.

* snippet.el (snippet--define-body): Call
`snippet--make-transform-lambda' here.
(snippet--make-and-insert-mirror): Don't require `source' arg.
(snippet--update-mirror): Only insert when transform returns string.
(snippet-defmacro): Redesign.
(&exit): Add indent spec
2015-04-03 12:31:35 +01:00
João Távora
414d2cbc57 Work a little to support nested fields
* snippet.el (snippet-defmacro): Support nested fields, more or
less...
(&field, &mirror): Add edebug and indent specs.
2015-04-02 21:43:28 +01:00
João Távora
ddca1181a0 Use eieio and attempt a snippet-defmacro per Stefan's suggestion
* snippet-tests.el (macro-test): Dummy test for
`snippet-defmacro'.

* snippet.el (eieio): require 'eieio
(snippet--define-body, snippet--make-and-insert-mirror)
(snippet--make-and-insert-exit): Use `make-instance'
(snippet--field-overlay-changed): Use `snippet--object-start'
(snippet--field-skip-p): Use `snippet--object-parent'
(snippet--object, snippet--field, snippet--mirror)
(snippet--exit): Use `defclass'
(snippet-defmacro): New broken macro.
(&mirror, &field): New edebug specs.
2015-04-02 21:07:23 +01:00
Joao Tavora
4732c6993b doc: add commentary section, ran checkdoc 2013-11-07 09:11:41 +00:00
Joao Tavora
ef1747d947 fix: must sometimes chain object to the end of parent of previous object 2013-11-07 00:49:52 +00:00
Joao Tavora
ff48006f55 fix: sort by nesting depth before initial mirror update
this is still incomplete, but should be enough for most cases
2013-11-07 00:46:08 +00:00
Joao Tavora
660b90a746 refactor: reorganize code around to shoosh compiler 2013-11-06 14:36:24 +00:00
Joao Tavora
f1a40e5b57 refactor: less macroexpanded code, simplify marker management 2013-11-06 14:27:06 +00:00
Joao Tavora
539c143d49 wip: even closer 2013-11-06 11:15:51 +00:00
Joao Tavora
891c76fa71 wip: in the green! 2013-11-06 10:02:59 +00:00
Joao Tavora
98946135a9 wip: just one test failing 2013-11-06 08:45:01 +00:00
Joao Tavora
dc12a8b4a2 wip: some tests already passing, but lambda scheme sucks 2013-11-06 01:05:39 +00:00
Joao Tavora
c5f62d81ae wip: still broken, but closer 2013-11-06 00:13:29 +00:00
Joao Tavora
7b7d2cea53 wip: on-going refactor, broken 2013-11-05 19:55:08 +00:00
Joao Tavora
d04d5dbae6 add: field ordering and snippet exits 2013-11-04 01:00:03 +00:00
Joao Tavora
b789c13f75 doc: update doc and clarify interface 2013-11-02 14:42:41 +00:00
Joao Tavora
782c57985b fix: don't need this function anymore 2013-11-02 13:25:43 +00:00
Joao Tavora
4ece494427 fix: better logic for wrapping selected text and writing mirror transforms 2013-11-02 01:00:03 +00:00
Joao Tavora
f32e4fe2ea fix: better input validation 2013-11-02 00:59:31 +00:00
Joao Tavora
db38009ee8 add: support expansion-time evaluation forms and validate some input 2013-10-31 01:35:19 +00:00
Joao Tavora
f76b876c53 refactor: use new 2013-10-30 16:28:46 +01:00
Joao Tavora
478211060c add: nested fields and nested field skipping 2013-10-20 13:41:32 +01:00
Joao Tavora
386e84fdde fix: make-snippet can be a function 2013-10-20 12:40:23 +01:00
Joao Tavora
0daac695e2 add: clear unmodified fields when inserting text at the beginning 2013-10-20 12:28:03 +01:00
Joao Tavora
2db4102fda fixup: guess I need to close snippet-objects after all 2013-10-19 17:20:25 +01:00
Joao Tavora
76bc40fd03 fix: properly handle snippet and mirror markers with `snippet--open-object'
* also snippet--close-object is apparently not needed

* don't call the mirror transforms when field-text is null, just
  return empty string. also zero-length fields considered to have a
  null field-text, not the empty string.

* correctly place markers when inserting objects
2013-10-19 15:31:24 +01:00
Joao Tavora
d43f42186d refactor: store prev' and next' in all objects, not prev-field' and next-field' 2013-10-19 01:40:44 +01:00
Joao Tavora
67ddacd916 refactor: snippet--[open|close]-markers take objects not markers 2013-10-19 01:17:27 +01:00
Joao Tavora
62c40c50b9 fix: better take a list rather than &rest args in make-snippet 2013-10-19 00:56:35 +01:00
Joao Tavora
b682f6bcac refactor: snippet--object struct included in fields and mirrors 2013-10-19 00:46:56 +01:00
Joao Tavora
4149acbaae fix: prefix cl-lib functions with cl and wrap long lines 2013-10-19 00:27:17 +01:00
Joao Tavora
ccf3579344 fix: require cl-lib instead of cl 2013-10-18 14:40:37 +01:00
Joao Tavora
c5276642b8 refactor: do away with snippet--form-[mirror/field]-p, use pcase and cleaner loops 2013-10-18 14:40:01 +01:00