-
Notifications
You must be signed in to change notification settings - Fork 2
snify
snify has an shell-based interface like an old ispell and just steps through a set of
sTeX files and suggests term reference annotations based on the verbalizations in the
SMGloM. The user can select annotations by number, and snify inserts the appropriate
annotation in the sTeX source, together with the respective imports (if necessary and
consistent). A couple of other keyboard-based interactions allow to fine-tune the workflow
and/or skip/refine annotations.
snify is a good productivity tool for bulk annotation of existing LaTeX source files. It
works well, if the material covered is backed by a well-developed domain model (for the
respective language).
You can call snify and pass a list of files to be annotated. Example:
stextools snify path/to/file1.tex path/to/file2.texOn the first run, snify will scan all of MathHub for verbalizations, symbols, etc.
This may take a while. Subsequent runs will be faster, as snify caches the results.
If everything works as expected, you will see the annotation prompt, similar to the following:

You can now enter commands.
If you want to annotate the highlighted word, you can enter the number of the annotation you want to use and press Return.
If you want to skip the word, you can enter s to skip it. snify will then move on to the next candidate for annotation.
There are many more commands available. The next section gives a more detailed overview of the available commands.
The list if all commands in snify can be invoked at any time by typing h to the prompt. We give more details below.
-
[h]elpDisplays a command overview similar to this one. -
[q]uitQuits the program. You will get asked if you want to resume the session at a later point. This will save the current state of your annotation progress. Next time you startsnify, you will get asked if you want to resume an existing session. -
[X]Exit fileStops annotating the file and and continues with the next one. -
[u]ndoUndoes the most recent modification. -
[uu]redo ("undo undo")Redoes the most recently undone modification. -
[R]escanRescans all of MathHub. If files have changed, it will process them to update the verbalization database. This might be useful if you do agit pullduring asnifysession (whenever you startsnify, it will do an automatic rescan).
-
[π]annotate with πAnnotates the current selection with option number π. If the symbol is not in scope, a dialog will pop-up with different import options. -
[l]ookup a symbolLookup a symbol for annotation. This is helpful if the correct symbol is not in the suggestions. It requires https://junegunn.github.io/fzf/ for fuzzy search (iffzfis not available, installation instructions will be displayed). -
[xπ]explain πProvides more information about suggested symbol no. π. At the moment, this is restricted to explaining why it was suggested, i.e. where a matching verbalization was found. This may be useful if a symbol is suggested due to a wrong annotation in a different file. In the future, we plan to also explain how the symbol was imported (if it is in the current scope as indicated by the green checkmark). This could help with "trimming the import tree" if a symbol is unexpectedly in scope.
Sometimes, the selected range in the document is not precisely what you had in mind. The following commands can modify the selected range.
-
[p]revious token should be includedExtends the selection to include the previous token. -
[P]exclude first selected tokenOpposite of[p]. Excludes the first token from the selection. -
[n]ext token should be includedExtends the selection to include the next token. -
[N]exclude last selected tokenOpposite of [n]. Excludes the last token from the selection.
-
[s]kip onceSkips the current selection and continues with the next possible annotation. -
[s!]kip until end of filesnifywill not propose any occurrences of the selected phrase in this file anymore (until the end of the session). -
[s!!]kip until end of sessionsnifywill not propose any occurrences of the selected phrase in this session. -
[i]gnore the selected word foreverThe word gets put into the (language-specific) ignore list and will never be proposed for annotation again, unless removed from that list. This is useful, if you are sure you never never never want to annotate this word. This includes all the tiny stop words like "and", "or", and "not", but also any other word you are sure has no technical meaning for you. You can find the ignore list at~/.config/stextools/srify_ignore.*.txt. -
[S]kip word in this file foreversnifywill never propose the word again in the current context, i.e. in this file. The end of a file contains a comment starting with% srskipthat lists all words that should be skipped bysnify. -
[SS]kip stem (i.e. all words with the same stem) in this file foreverLike[S], butsnifywill also skip other forms of the word. For example, if you apply it to the word documents,snifywill also not proposedocumentordocumentingordocumentationfor annotation.
The idea of focussing in snify is to reduce the mental overhead of seeing a different
list of candidate symbols for every annotation.
By focussing on a particular word (or rather, word stem), snify will effectively
fix the list of candidate symbols and ignore all other words.
Afterwards, snify will go back to the place where you started focussing and continue
as usual.
-
[f]ocus on stemsnifywill focus on the word stem until the end of the file. -
[f!]ocus on stem in all remaining filessnifywill focus on the word stem for all remaining files in the session. -
[f!!]ocus on stem in all filessnifywill focus on the word stem in all files in MathHub.
-
[r]eplaceAsks you to enter a new string that should replace the selected range of the document. This is useful to fix typos or poor wording. For more powerful editing capabilities, you should consider[e]. -
[v]iew fileSnify displays the current file in the pager. -
[vπ]view document for πDisplays the document that introduces symbol no. π. -
[e]dit fileOpens the current file in an editor. The editor can be specified in the config file. If no editor is specified,snifywill use theEDITORenvironment variable, and defaults tonano. -
[eπ]edit document for πOpens the document that introduces symbol no. π in an editor (as[e]). -
[ee]dit file with editor 2Like[e], but using editor 2 from the config file. A typical setup is to use a command line editor (vim/emacs/nano/...) a editor 1, and VSCode with the sTeX plugin as editor 2. -
[eeπ]edit document for π with editor 2Like[eπ], but with editor 2.
If you only want annotations from certain archives, you can specify them with
--filter:
# only use symbols from the SMGloM
stextools snify --filter 'smglom/*' path/to/file.tex
# you can use comma-separated lists
stextools snify --filter 'smglom/sets,smglom/mv' path/to/file.texNote: * is a wild card. If you do not use single quotes, you may need to escape the * with a backslash.
You can also ignore certain archives with --ignore (also using wildcards):
stextools snify --ignore 'smglom/experimental' path/to/file.texYou can also combine --filter and --ignore:
stextools snify --filter 'smglom/*' --ignore 'smglom/experimental' path/to/file.texTo make these settings permanent, you can add them to your ~/.config/stextools/config file:
[stextools.snify]
filter = smglom/*
ignore = smglom/experimentalYou can also set the following options in your ~/.config/stextools/config file:
[stextools.snify]
# number of lines to show before and after the current line
context-lines=3
# editor to use for editing files
editor=vim
# alternative editor to use for editing files
editor2=code