An Gramadóir:
Text Editor Support


Interfaces are available for the three most popular editors in the open source community: Vim, Emacs, and OpenOffice. These interfaces are distributed with the Perl module in the share/ directory, but if you prefer you can download them here:

Installation and usage instructions follow.


Martin Gregory has kindly contributed an Emacs interface to An Gramadóir which is very easy to use. Here are his instructions:

"The Emacs interface to An Gramadóir allows you to run An Gramadóir from within an Emacs session and navigate to the locations in the input files where An Gramadóir found problems. The interface is similar to that of the compile or grep commands in Emacs.


Put gramadoir.el in your emacs site lisp directory, often something like:

If you don't have one, put it it ~/lisp or some other directory of your choice and put the following line in your ~/.emacs file
   (load-file "/where/you/put/gramadoir.el")
If you are an experienced Emacs user, you'll probably want to auto load the file.


The interface allows you to specify files in two different ways:

After running one of the above commands, the output of An Gramadóir is written to a new buffer which is displayed in a separate window. Using the gramadoir-next-message command positions the cursor at the location of the first error in the first file. Subsequent use of this command takes you to the locations of subsequent errors. If you reposition the cursor in the output buffer, the command takes you to the location of the next error after that position.


For convenience, you can bind the three commands to keys. These need to be global definitions, for example:

   (global-set-key "\C-cg" 'gramadoir-check-files)
   (global-set-key "\C-cd" 'gramadoir-dired)
   (global-set-key [f3] 'gramadoir-next-message)

If you installed An Gramadóir anywhere other than in /usr/bin you need to tell the interface where to look for it by putting a line similar to the following:

   (setq gramadoir-program-path "/usr/bin/")
in your ~/.emacs, substituting the appropriate path for "/usr/bin" and language code for "xx".

Finally, the interface highlights the error text both in the output buffer and in the buffer of the original file. If you prefer not to highlight the text in the original file, add this:

   (setq gramadoir-highlight-text nil)
to your ~/.emacs."


I've written a script which emulates the behavior of Martin's Emacs interface within Vim. You can download it from the link at the top of this page, or you can get it directly from Vim online. Instructions:

  1. put gramadoir.vim in ~/.vim/plugin. For languages other than Irish, you'll need to change the "" around line 30 to the appropriate script name.
  2. put the following lines in your ~/.vimrc file
    map <F3> <Plug>Gr
    map <F4> <Plug>Neamh
    map <F5> <Plug>Amach
    or choose different hot keys if you want.
  3. open the text file to be checked in Vim.
  4. to check its grammar, press F3; a second buffer, containing the messages from An Gramadóir, will open at the bottom of the screen. The cursor will move to the first error (which is also highlighted in red if you are using a suitable color terminal).
  5. Each successive use of F3 moves to the next error (in both windows, in parallel).
  6. If the current error is a single word (unknown, misspelled, rare, non-standard, etc.), you can insert it into your .neamhshuim (ignore) file by pressing F4.
  7. Pressing F5 exits the grammar checker and resumes normal editing.
  8. Notes: you are free to make edits, corrections, etc. to the main buffer while running the grammar checker. The last error displayed is tracked according to the cursor position in the error buffer, so whenever you press F3 it will correctly take you to the next error. This also means that you can jump to any particular error you'd like: go into the error buffer (with Crtl-w-w), move the cursor to just before the desired error, press F3.


The file gramadoir.sxw is an OpenOffice document that contains an embedded macro allowing An Gramadóir to be called directly from an OpenOffice session. See Russ Phillips' Macro Library How-To for more detailed installation instructions.

  1. Open gramadoir.sxw in OpenOffice.
  2. Go to Tools and select Macros, then Macro....
  3. The "Macro" dialog will appear. Double click "Gramadoir" and then single click the "Gramadoir" underneath.
  4. Now click the Edit button, which will open up the macro source code. The first line points to the file groo-ga.bat; change the "ga" to your ISO-639 language code (if you don't speak Irish), and change the file extension "bat" to "pl" if you're not running Windows. This file will need to be in your path.
  5. Save your changes and close the source code window, which should take you back to the original file. Now reopen the "Macro" dialog as in step 2; this time click on the Organizer button.
  6. The "Macro Organizer" dialog will appear. Click on the Libraries tab at the top left.
  7. Be sure "soffice" appears under "Application/Document", then click Append.
  8. Choose gramadoir.sxw using the file selection dialog that opens.
  9. Make sure only "Gramadoir" is checked in the "Append Libraries" dialog; you may need to uncheck "Standard". Then click OK.
  10. Close the Macro Organizer and then close the Macro dialog.

You should now have the macro installed and ready to use from any OpenOffice session. You can associate a hot key or a toolbar item with the macro via the Tools->Configure dialog.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.