github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/user-guide/spellcheck.md (about)

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