Is this feature implemented? Maybe running the previous word through a filter on every white space and the inserting a color tag that is not exported if it is an unrecognized word. I would do it myself, but the texmacs docs seem really bad compared with Vim or Emacs. Also, are there any hooks like in Emacs or autocommands like in Vim in TeXmacs?
Spellcheck as-you-type
As far as I know it is not.
I have the feeling that the answer may be a partial yes but could you please explain in a synthetic way what are hooks and autocommands? Links with short explanations will also fit as an answer.
Autocommands in vim are functions that get called on specific events, e.g. file save, cursor movement, cursor at word boundary, loading a specific type of file etc. You can add your functions to the list of commands that Vim calls whenever the event occurs. Hooks are a similar concept in Emacs. There is a list of functions that each gets executed when some event that is associated with the hook occurs. This is another way to extend Emacs or Vim.
Vim autocommands:
https://vimdoc.sourceforge.net/htmldoc/autocmd.html
Emacs hooks:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Hooks.html
I have experimented a bit. This is very hackish, spellchecking every 2 seconds, but perhaps it can lead to something useful
(delayed
(:while #t)
(:every 2000)
(with
sels ((@@ (generic spell-widgets) spell-buffer-tree))
(set-alt-selection "alternate" sels)))
Thanks for the effort. Maybe you could write something about what those functions do and put it in some TeXmacs release.
There is a mechanism for functions, keyboard mappings and menus with which they can be redefined and call their earlier definition (see Help->Scheme extensions-> Overview of the scheme extension language -> 5. Contextual overloading
).
For example, to highlight misspelled words on every press of the space bar, we can do
(tm-define (spell-highlight)
(with
sels ((@@ (generic spell-widgets) spell-buffer-tree))
(set-alt-selection "alternate" sels)))
(tm-define (kbd-space-bar t shift?)
(:require (and (tree-is-buffer? t) (in-text?)
(!= (get-env "language") "verbatim")))
(former t shift?)
(spell-highlight))
The :require
part sets up the conditions under which this version of the function should apply. The (former t shift?)
bit calls the existing definition of the function, so that the space character still gets inserted.
Iâm not sure we want to ship this until some more experimentation. The implementation seems all right, however. Great work @jeroen. It would be nice if we have a way to change the display style of different kinds of selections.
At the moment there are only the âselection-colorâ and âmatch-colorâ environment variables that can be used to set the color of the standard and alternate selections.
One thing Iâve noticed now is that this also spell-checks and highlights things like source code and slideshows (also while in full-screen). This will need a bit of fine-tuning. Also a preference to enable it should be added.
Also the matching bracket highlighting in source code uses the same âalternate selectionâ procedure, so the two donât work together.