Lisp programs are expected to use the following primitives to edit the Neomacs DOM. These primitives provides positions-based interface and handles text-node splitting and merging automatically. These primitives also maintain undo history, update renderer-side DOM, manage setup and destruction of observers and computed attributes, and allocate neomacs-identifier
's.
delete-nodes
(beg end)
extract-nodes
(beg end)
delete-nodes
, but clone and return the deleted contents.insert-nodes
(marker-or-pos &rest things)
move-nodes
(beg end to)
More often than not the structured data in a buffer only makes sense if they follow certain constraints or invariants. Neomacs provides a number of facilities to help enforcing invariants, including computed attributes, pre/post command hooks and the following facilities.
Catch all nodes entering and leaving a buffer's DOM:
on-node-setup
(buffer node)
element
or a text-node
.on-node-cleanup
(buffer node)
element
or a text-node
.Schedule some action to run after current command invocation if a node is edited:
with-post-command
((node &rest slots) &body body)
Typically, on-node-setup
is used to register some computed attributes and post command actions depending on type of node being inserted. with-post-command
should be used to restore invariants instead of adding observers (via lwcells
's add-observer
) that directly edits the DOM, because observers can run in the middle of compound editing operations and commands which might cause unpredictable behavior.
Functions implemented using editing primitives, provided for convenience:
splice-node
(node)
join-nodes
(dst src)
raise-node
(node)
split-node
(&optional (pos (focus)))
wrap-node
(node new-node)
delete-node
(node)
replace-node
(node new-node)
The following generic editing commands are avaliable in any Neomacs buffer:
enter
): new-line
(&optional (marker (focus)))
backspace
): backward-delete
(&optional (marker (focus)))
C-d
): forward-delete
(&optional (marker (focus)))
M-backspace
): backward-delete-word
(&optional (marker (focus)))
space, !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, =, >, ?, @, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, [, \, ], ^, _, `, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, {, |, }, ~, , ¡, ¢, £, ¤, ¥, ¦, §, ¨, ©, ª, «, ¬, , ®, ¯, °, ±, ², ³, ´, µ, ¶, ·, ¸, ¹, º, », ¼, ½, ¾, ¿, À, Á, Â, Ã, Ä, Å, Æ, Ç, È, É, Ê, Ë, Ì, Í, Î, Ï, Ð, Ñ, Ò, Ó, Ô, Õ, Ö, ×, Ø, Ù, Ú, Û, Ü, Ý, Þ, ß, à, á, â, ã, ä, å, æ, ç, è, é, ê, ë, ì, í, î, ï, ð, ñ, ò, ó, ô, õ, ö, ÷, ø, ù, ú, û, ü, ý, þ
): self-insert-command
()
*clipboard-ring*
*clipboard-ring-index*
C-w
): cut-element
()
M-w
): copy-element
()
C-y
): paste
()
M-y
): paste-pop
()
C-k
): forward-cut
(&optional (pos (focus)))