github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/gen/user-guide/spellcheck_doc.yaml (about) 1 - DocumentID: spellcheck 2 Title: >- 3 Spellcheck 4 CategoryID: user-guide 5 Summary: >- 6 How to enable inline spellchecking 7 Description: |- 8 ## Description 9 10 Murex supports inline spellchecking, where errors are underlined. For example 11 12 [](https://asciinema.org/a/408024) 13 14 However to use this there needs to be a few satisfied prerequisites, not all of 15 which will be enabled by default: 16 17 ## CLI Spellchecker (3rd Party Software) 18 19 A CLI spellchecker needs to be installed. The recommendation is `aspell`. This 20 might already be installed by default with your OS or has been included as a 21 dependency with another application. You can check if `aspell` is installed by 22 running the following: 23 24 ``` 25 which aspell 26 ``` 27 28 If that returns no data, then you will need to install `aspell` yourself. 29 Please consult your OS docs for how to install software. 30 31 For help debugging issues with `aspell`, please see the last section in this 32 document. 33 34 ## Murex Config 35 36 ### ANSI Escape Sequences 37 38 ANSI escape sequences need to be enabled (which they are by default). This 39 option is found in `config` under **shell**, **color**. 40 41 ``` 42 config: set shell color true 43 ``` 44 45 ### Spellcheck Enable 46 47 Spellcheck needs to be enabled. This option can be found in `config` under 48 **shell**, **spellcheck-enabled**. 49 50 To enable this run: 51 52 ``` 53 config set shell spellcheck-enabled true 54 ``` 55 56 ...or add the above line to your Murex profile, `~/.murex_profile` to make 57 the change persistent. 58 59 > Please note that this option will automatically be enabled if `aspell` is 60 > installed. 61 62 ### Spellcheck Murex Code 63 64 This shouldn't need tweaking if you're running `aspell` but other spellcheckers 65 will require updated code. The default will look something like this: 66 67 ``` 68 » config get shell spellcheck-func 69 { -> aspell list } 70 ``` 71 72 The default should be good enough for most people but should you want to run an 73 alternative spellchecker then follow the instructions in the next section: 74 75 ## How To Write Your Own `spellcheck-func` 76 77 You might legitimately want to run a different spellchecker and if so you'll 78 need to write your own **spellcheck-func**. Fortunately this is simple: 79 80 The function reads the command line from STDIN, if the spellchecker reads lines 81 from parameters rather than STDIN you'll need to write something equivalent to 82 the following 83 84 ``` 85 { 86 # This is a theoretical example. It will not work generically. 87 -> set line 88 newspellchecker --check "$line" 89 } 90 ``` 91 92 The output of the function must me an array containing the misspelt words only. 93 That array can be JSON just as long as you have set STDOUT's data type to 94 `json`. Similarly, other supported Murex data types can be used too. However 95 in general you might just want to go with a misspelling per line as it's pretty 96 POSIX friendly and thus most spellcheckers are likely to support it. eg 97 98 ``` 99 » out "a list of misspelt words: qwert fuubar madeupword" -> aspell list 100 qwert 101 fuubar 102 madeupword 103 ``` 104 105 ## User Dictionary 106 107 Murex has it's own user dictionary, which is held as a JSON array: 108 109 ``` 110 » config: get shell spellcheck-user-dictionary 111 ["murex"] 112 ``` 113 114 You can add words to a user dictionary via: 115 116 ``` 117 » config eval shell spellcheck-user-dictionary { -> append "myword" } 118 ``` 119 120 or 121 122 ``` 123 » config eval shell spellcheck-user-dictionary { -> alter --merge / (["word1", "word2", "word3"]) } 124 ``` 125 126 > Don't forget to record these in your Murex profile, `~/.murex_profile` to 127 > make the changes persistent. 128 129 ### Ignored By Default 130 131 Sometimes commands are not valid words in ones native language. Thus any words 132 that fall into the following categories are ignored by default: 133 134 * words that are also the names of commands found in `$PATH` 135 * words that are the names of Murex functions (defined via `function`) 136 * words that are builtins (eg `config` and `jsplit`) 137 * any global aliases 138 * also any words that are also the names of global variables 139 140 ## Common Problems With `aspell` 141 142 ### `Error: No word lists can be found for the language "en_NZ".` 143 144 The `en_NZ` portion of the error will differ depending on your language. 145 146 If this error arises then it means `aspell` is installed but it doesn't have 147 the dictionary for your language. This is an easy fix in most OSs. For example 148 in Ubuntu: 149 150 ``` 151 apt install aspell-en 152 ``` 153 154 (you may need to change `-en` with your specific language code) 155 156 Please consult your operating systems documentation for how to install software 157 and what the package names are for `aspell` and its corresponding dictionaries. 158 Synonyms: 159 Related: 160 - config 161 - append 162 - alter 163 - set 164 - jsplit 165 - code-block 166 - curly-brace 167 - ansi 168 - interactive-shell 169 - profile 170 - json 171 172