So in my last post about esperanto inside emacs, I added a way to write the special characters, but as I said in that post, I wanted a way to search a dictionary for the meaning of esperanto words. Finding such a dictionary I could actually download and have as a single file on my computer was much more difficult than I thought it strictly should be. After much searching yesterday I managed to find one, can be gotten from dict. Having found this I managed to figure out how I can search this file
I started by figuring out how to do this with the shell.
cat esperantowords.txt | grep day | cut -f1,2
Okay before you attack me for doing this in a bad way, piping cat into grep, just be aware that I tried to do it the 'right' way, but that did not do the thing, so I just did it this way. Also I don't really care very much due to my intention being to do it in emacs.
So I decided to work out how to do this in emacs, right now I have a reasonable thing.
(defun tsl/search-esperanto-word (word) (interactive "sWord?") (progn (find-file-other-window "~/Downloads/dict/esperantowords.txt") (beginning-of-buffer) (search-forward word) (beginning-of-line) (kill-line) (yank) (delete-window)))(global-set-key (kbd "C-c e l") 'tsl/search-esperanto-word)
This opens a new 'window', which in emacs terminology is not what you think, since what you would call a 'window' emacs refers to as a frame. Inside this window I open up the esperanto wordlist I managed to find searching for the word or sentence I type in, kill the line yank it back and close the window, and all before it is visible, this has the effect of putting the line I was looking for in my kill-ring so when I need it I simply yank it. yank in emacs is to paste and done with the keybinding <C-y>.
I had another implementation, that did something alike, but my ability to do programmatical things with that implementation was way less, so I scrapped it in favor of this way. If you want to see the other thing I wrote, I will leave it here just in case it might be useful, you can take it and use for something else where it might prove more useful.
(defun lookup-esperanto (word) (interactive "sWord?") (rgrep word file directory))
replace file and directory to suitable places, though both are optional. If neither is supplied it will search files in the current directory matching the current files ending.
Though I am happy with the first implementation, rgrep had the unfortunate side effect of forcing open a new window being very disruptive.
So if you found this useful do leave me with one of those ups.