[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jit-spell 54f6f69401: Support multi-language spellcheck
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jit-spell 54f6f69401: Support multi-language spellchecking (Hunspell only) |
Date: |
Sat, 10 Aug 2024 09:58:24 -0400 (EDT) |
branch: externals/jit-spell
commit 54f6f69401cbaf3b103e5a2ff4bec34498098ef6
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Support multi-language spellchecking (Hunspell only)
---
README.org | 35 +++++++++++++++++++++++++++++------
jit-spell.el | 23 +++++++++++++++++++++--
2 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/README.org b/README.org
index 7f371c2e43..acf54dbbf1 100644
--- a/README.org
+++ b/README.org
@@ -33,14 +33,37 @@ the following to your init file:
(add-hook 'text-mode-hook 'jit-spell-mode)
(add-hook 'prog-mode-hook 'jit-spell-mode)
(with-eval-after-load 'jit-spell
- (define-key jit-spell-mode-map (kbd "C-;") 'jit-spell-correct-word))
+ (keymap-set jit-spell-mode-map "C-;" 'jit-spell-correct-word))
#+end_src
-To pick a spell checker and dictionaries, jit-spell uses Emacs's
-built-in ispell support code. For instance,
-=ispell-change-dictionary= temporarily changes the dictionary of the
-current buffer. Try also =M-x customize-group RET ispell RET= to see
-a listing of all possible settings.
+Try also =M-x customize-group RET jit-spell RET= to see a listing of
+all possible customization options.
+
+Many customization options from the built-in =ispell= library are also
+relevant, notably =ispell-program-name=. Hunspell and Aspell are the
+most common choices. Aspell is faster, but in my experience Hunspell
+has better correction suggestions and is sufficiently performant.
+
+** Language selection
+
+Type =M-x jit-spell-change-dictionary RET= to choose a different
+spelling language. If you use Hunspell, you will be able to select
+multiple languages. Other spellchecking programs are limited to a
+single language.
+
+The default spellchecking language is determined from your system
+settings. To change that, customize the variable =ispell-dictionary=.
+To change the spellchecking language of a specific file, type =M-x
+add-file-local-variable RET ispell-local-dictionary RET= followed by
+the desired language (remember to enclose it in quotation marks, since
+that variable must be a string). Similarly, you can use
+[[https://www.gnu.org/software/emacs/manual/html_node/elisp/Directory-Local-Variables.html][directory-local
variables]] to adjust the spellchecking language for
+collections of files.
+
+When using Hunspell, you can set those variables to a comma-separated
+list of dictionaries for multi-language spellchecking. See the
+explanation of the =-d= switch in Hunspell's man page for more
+information.
** Major mode support
diff --git a/jit-spell.el b/jit-spell.el
index 523814474a..9ebaab8446 100644
--- a/jit-spell.el
+++ b/jit-spell.el
@@ -281,6 +281,8 @@ The process plist includes the following properties:
(unless ispell-async-processp
(error "`jit-spell-mode' requires `ispell-async-processp'"))
(ispell-set-spellchecker-params)
+ (when-let ((dict (and ispell-really-hunspell (cadr params))))
+ (ispell-hunspell-add-multi-dic dict))
(ispell-internal-change-dictionary)
(setq proc (ispell-start-process))
(set-process-query-on-exit-flag proc nil)
@@ -585,7 +587,24 @@ program and there is no reliable way of obtaining it."
(message "\"%s\" removed from %s." word (string-join places " and "))
(jit-lock-refontify))))
-(defalias 'jit-spell-change-dictionary 'ispell-change-dictionary) ;For
discoverability
+(defun jit-spell-change-dictionary (dict &optional arg)
+ "Change to dictionary DICT for Ispell.
+If ARG (interactively, the prefix argument) is non-nil, change globally;
+otherwise change for this buffer only.
+
+This command is like `ispell-change-dictionary', but allows DICT to be a
+comma-separated list of dictionaries when using Hunspell."
+ (interactive
+ (list (let ((cands (ispell-valid-dictionary-list)))
+ (if ispell-really-hunspell
+ (string-join
+ (completing-read-multiple "Use dictionaries: " cands nil t)
+ ",")
+ (completing-read "Use dictionary: " cands nil t)))
+ current-prefix-arg))
+ (when (and ispell-really-hunspell (not (string-empty-p dict)))
+ (ispell-hunspell-add-multi-dic dict))
+ (ispell-change-dictionary dict arg))
;;; Minor mode definition
@@ -630,7 +649,7 @@ It can also be bound to a mouse click to pop up the menu."
(:propertize
(:eval
(let ((s (or ispell-local-dictionary ispell-dictionary)))
- (if s (concat "/" (substring s 0 (string-search "_" s))))))))
+ (and s (concat "/" s))))))
(cond
(jit-spell-mode
;; Major mode support
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/jit-spell 54f6f69401: Support multi-language spellchecking (Hunspell only),
ELPA Syncer <=