Showing posts with label emacs. Show all posts
Showing posts with label emacs. Show all posts

Wednesday, March 31, 2010

Configuring GNU Emacs 23 + Ispell + Russian Dictionary + Windows

Emacs ispell package is capable of running both Ispell and Aspell, but
as far as I've tried Aspell, it gives some nonsensical results. Maybe this
was due to some misconfiguration, but I wasn't eager to sort it out.

So I went with Ispell. Configuring it is also a bit of obscure process, so
I thought it would be good to have an installation guide step by step:


  1. Download Ispell from here.


  2. You should have Cygwin installed on your machine. Let's say, it is in folder c:\Programs\Cygwin.


  3. Unpack aforementioned Ispell to your Cygwin directory.


  4. Go to c:\Programs\Cygwin\usr\local\bin and copy ispell.exe to c:\Programs\Cygwin\bin. This is needed to run ispell directly from Windows, bypassing Cygwin shells.


  5. Download russian dictionaries from here and unpack them to some temporary folder. Let's say it would be d:\temp.


  6. Run Cygwin shell and perform the following commands (modify them appropriately):


    cd /cygdrive/d/temp
    make win
    mv russian.hash russianw.hash
    mv russian.aff russianw.aff
    mv russianw.* /usr/local/lib


    From now on, you sould be able to check files encoded in windows-1251 charset directly under Cygwin, like that:


    LANG=ru_RU ispell -drussianw file.txt


    Or, under cmd.exe:


    set LANG=ru_RU.CP1251
    c:\Programs\Cygwin\bin\ispell.exe -drussianw file.txt




  7. Now all we need to do is to configure Emacs correctly. Add the following lines to your dotemacs:


    (setq ispell-program-name "c:\\Programs\\cygwin\\bin\\ispell.exe")
    (setq ispell-dictionary "russianw")




  8. This should do the task. Now restart emacs and try running ispell on some file.


Friday, July 4, 2008

Disable arrow keys in Emacs

So for this habit is ineradicable by will and my hands a little ache after hour or two of code surfing, I've decided just to disable this keys in my .emacs. Here we go:

(global-unset-key [(up)])
(global-unset-key [(down)])
(global-unset-key [(left)])
(global-unset-key [(right)])
(global-unset-key [(prior)])
(global-unset-key [(next)])
(global-unset-key [(home)])
(global-unset-key [(next)])

Monday, February 12, 2007

Integrating Emacs kill-ring and Windows clipboard

Since I've started using Emacs on Windows, there was one little problem irritating my mind everyday -- by default, GNU Emacs 22 separates kill-ring and Windows clipboard contents, making it REALLY hard to use clipboard -- you can paste text by only pressing mouse-3 (the wheel) on editor window, and you can copy text only by selecting it with your mouse -- no handy C-y, no integration with kill ring.

So I did a little "investigation". There are two variables controlling mentioned integration -- interprogram-cut-function and interprogram-paste-function (described in emacs online documentation, which see). First of which holds function used to send killed text to clipboard, and the second one holds function used to get fresh clipboard text back from clipboard and put it to kill-ring. More to that, file w32-fns.el in your emacs site-lisp tree contains the next (as well as definitions for those functions -- x-select-text and x-get-selection-value):

(setq interprogram-cut-function 'x-select-text)
(setq interprogram-paste-function 'x-get-selection-value)


But for some reason this file isn't loaded on Emacs startup. So, what should we do is to add some loading code to our dotemacs file (do not forget to wrap-n-protect it with some kind of Win32-only conditional -- `(Windows body ...)' macro in my case):

(Windows
(load "w32-fns"))

Voila! Now text from clipboard goes right to the kill-ring and vice versa.