[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jinx

From: Emanuel Berg
Subject: Re: jinx
Date: Sat, 01 Apr 2023 10:25:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii wrote:

> We cannot assume that "jinx is always available", since it
> requires Emacs to be linked against the enchant library.
> Anyway, after looking at jinx, I must say that I don't see
> why we should replace ispell and flyspell with jinx. From my
> POV, ispell and flyspell provide all the required
> spell-checking functionalities:
>   . spell-check a word
>   . spell-check a region
>   . spell-check the entire buffer
>   . spell-check comments and strings in a prog-mode buffer
>   . spell-check as you type

Had to do some work on some of that back when I set it up,
don't know if that has since then been moved into vanilla
Emacs - here is the file anyway

;;; -*- lexical-binding: t -*-
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/spell.el
;; Debian bug:
;;   ispell-init-process: Illegal format hash table
;;   /usr/lib/ispell/svenska.hash - expected magic2 0x9602, got 0x414c
;;   $ sudo buildhash /usr/share/dict/svenska /usr/lib/ispell/svenska.aff 

(require 'ispell)

(when (eq system-type 'gnu/linux)
  (load-file "/usr/share/dictionaries-common/site-elisp/debian-ispell.el")
  (load-file "/var/cache/dictionaries-common/emacsen-ispell-dicts.el") )

(setq ispell-program-name   "ispell")
(setq ispell-silently-savep t)

;; single word

(defun spell-word (word)
      (insert word) )
    (condition-case nil
        (not (ispell-word))
      (error nil) )))
;; (spell-word "length") ; t
;; (spell-word "lenght") ; nil

(defun spell-this-word (dict)
  "`ispell-word' the preceding word with DICT."
  (ispell-change-dictionary dict)
  (ispell-word) )

(let ((eng-dict "american-insane"))
  (defun spell-english ()
    (spell eng-dict) )

  (defun word ()
    (spell-this-word eng-dict) ))
;; test: hello / hxllo

(let ((swe-dict "svenska"))
  (defun spell-swedish ()
    (spell swe-dict) )

  (defun ord ()
    (spell-this-word swe-dict) ))
;; test: hej / hxj

;; buffer / whole / dwim

(defun is-code ()
  (member major-mode '(c++-mode
                       Shell-script-mode) )) ; add more ...

(defun is-message ()
  (eq major-mode 'message-mode) )

(defun spell (dict)
  "Spell with DICT.
If region is active, use `ispell-region';
if editing code, `ispell-comments-and-strings';
if writing a message, `ispell-message';
else, `ispell-buffer'"
  (ispell-change-dictionary dict)
       ((use-region-p) (ispell-region (region-beginning) (region-end)))
       ((is-message)   (ispell-message))
       ((is-code)      (ispell-comments-and-strings))
       (t              (ispell-buffer)) ))))

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]