emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/spell-fu ddad489f2c 43/86: Adds affix dict support via asp


From: ELPA Syncer
Subject: [nongnu] elpa/spell-fu ddad489f2c 43/86: Adds affix dict support via aspell expand cmd
Date: Thu, 7 Jul 2022 12:03:42 -0400 (EDT)

branch: elpa/spell-fu
commit ddad489f2c87467480520502a93e682f81bfac18
Author: Hanno Perrey <hanno@hoowl.se>
Commit: Campbell Barton <ideasman42@gmail.com>

    Adds affix dict support via aspell expand cmd
    
    aspell supports dictionaries with affixes which determine the
    grammatically valid expansions for each word. Affixes are separated from
    the individual word via a forward slash. If such slash is found, the
    word list has to be expanded. This is done via piping the word list
    through aspell' 'expand' command with the language of the dictionary
    given as parameter (if not set to "default").
---
 changelog.rst |  5 +++--
 readme.rst    |  1 -
 spell-fu.el   | 26 ++++++++++++++++++++++++--
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/changelog.rst b/changelog.rst
index 2e61a47fea..c1822d03db 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,9 +3,10 @@
 Change Log
 ##########
 
-- In development
+- Version 0.3 (2021-03-28)
 
-  - <none>
+  - Support affix expansion when calling ``aspell`` (some non English 
dictionaries use this).
+  - Use explicit ``utf-8`` encoding, (fixes issue #8).
 
 - Version 0.2 (2020-04-26)
 
diff --git a/readme.rst b/readme.rst
index 286f7022ce..ec1a7adf10 100644
--- a/readme.rst
+++ b/readme.rst
@@ -189,6 +189,5 @@ TODO
 
 - Support alternates to ``aspell`` for generating word lists.
 - Support a custom command for generating a word list.
-- Support affix expansion when calling aspell (some non English dictionaries 
use this).
 - Support refreshing the word list at run-time when ispell updates the 
personal dictionary
   *(currently updates require re-enabling the mode).*
diff --git a/spell-fu.el b/spell-fu.el
index 0afc332e30..e52da2a361 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -6,7 +6,7 @@
 
 ;; URL: https://gitlab.com/ideasman42/emacs-spell-fu
 ;; Keywords: convenience
-;; Version: 0.2
+;; Version: 0.3
 ;; Package-Requires: ((emacs "26.2"))
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -354,7 +354,29 @@ Argument WORDS-FILE the file to write the word list into."
                 ((string-equal dict "default")
                   (call-process aspell-bin nil t nil "dump" "master"))
                 (t
-                  (call-process aspell-bin nil t nil "-d" dict "dump" 
"master"))))
+                  (call-process aspell-bin nil t nil "-d" dict "dump" 
"master")))
+
+              ;; Check whether the dictionary has affixes, expand if necessary.
+              (when (re-search-backward "^[[:alpha:]]*/[[:alnum:]]*$" nil t)
+                (let ((lang (spell-fu--aspell-lang-from-dict dict)))
+                  (unless
+                    (zerop
+                      (shell-command-on-region
+                        (point-min) (point-max)
+                        (if lang
+                          (format "%s -l %s expand" aspell-bin lang)
+                          (format "%s expand" aspell-bin))
+                        t t
+                        ;; Output any errors into the message buffer instead 
of the word-list.
+                        "*spell-fu word generation errors*"))
+                    (message
+                      (format
+                        "spell-fu: affix extension for dictionary '%s' failed 
(with language: %S)."
+                        dict
+                        lang)))
+                  (goto-char (point-min))
+                  (while (search-forward " " nil t)
+                    (replace-match "\n")))))
 
             (setq word-list (spell-fu--buffer-as-line-list (current-buffer) 
word-list)))
 



reply via email to

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