[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 4782667d7b 76/86: Fail gracefully with a message
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 4782667d7b 76/86: Fail gracefully with a message when aspell can't be found |
Date: |
Thu, 7 Jul 2022 12:03:45 -0400 (EDT) |
branch: elpa/spell-fu
commit 4782667d7b6b97658f7649598e47aa6cf4d1bd80
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Fail gracefully with a message when aspell can't be found
Resolve #19
---
spell-fu.el | 105 ++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 63 insertions(+), 42 deletions(-)
diff --git a/spell-fu.el b/spell-fu.el
index 09fd263954..591116c068 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -1010,7 +1010,9 @@ Return t if the file was updated."
(dict-aspell-name (cadr (nth 5 (assoc dict-name
ispell-aspell-dictionary-alist))))
(dict-file (and dict-aspell-name (spell-fu--aspell-find-data-file
dict-name)))
(is-dict-outdated
- (and has-words-file dict-file (spell-fu--file-is-older words-file
dict-file))))
+ (and has-words-file dict-file (spell-fu--file-is-older words-file
dict-file)))
+ ;; Return value, failure to run `aspell' leaves this nil.
+ (updated nil))
(when (or (not has-words-file) is-dict-outdated)
@@ -1028,54 +1030,73 @@ Return t if the file was updated."
(or (and ispell-really-aspell ispell-program-name)
(executable-find "aspell"))))
(cond
+ ((null aspell-bin)
+ (message "\"aspell\" command not found!"))
((string-equal dict-name "default")
- (call-process aspell-bin nil t nil "dump" "master"))
+ (condition-case err
+ (progn
+ (call-process aspell-bin nil t nil "dump" "master")
+ (setq updated t))
+ (error
+ (message
+ "failed to run \"aspell\" with default dictionary with
error: %s"
+ (error-message-string err)))))
(t
- (call-process aspell-bin nil t nil "-d" dict-name "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-name)))
- (unless
- (zerop
- (shell-command-on-region
- (point-min) (point-max)
- (cond
- (lang
- (format "%s -l %s expand" aspell-bin lang))
- (t
- (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)."
+ (condition-case err
+ (progn
+ (call-process aspell-bin nil t nil "-d" dict-name "dump"
"master")
+ (setq updated t))
+ (error
+ (message
+ "failed to run aspell with %S dictionary with error:
%s"
dict-name
- lang)))
- (goto-char (point-min))
- (while (search-forward " " nil t)
- (replace-match "\n")))))
+ (error-message-string err))))))
- (setq word-list (spell-fu--buffer-as-line-list (current-buffer)
word-list)))
+ ;; Check whether the dictionary has affixes, expand if necessary.
+ (when updated
+ (when (re-search-backward "^[[:alpha:]]*/[[:alnum:]]*$" nil t)
+ (let ((lang (spell-fu--aspell-lang-from-dict dict-name)))
+ (unless
+ (zerop
+ (shell-command-on-region
+ (point-min) (point-max)
+ (cond
+ (lang
+ (format "%s -l %s expand" aspell-bin lang))
+ (t
+ (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-name
+ 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)))))
;; Case insensitive sort is important if this is used for
`ispell-complete-word-dict'.
;; Which is a handy double-use for this file.
- (let ((word-list-ncase nil))
- (dolist (word word-list)
- (push (cons (downcase word) word) word-list-ncase))
-
- ;; Sort by the lowercase word.
- (setq word-list-ncase
- (sort word-list-ncase (lambda (a b) (string-lessp (car a) (car
b)))))
-
- ;; Write to 'words-file'.
- (with-temp-buffer
- (dolist (line-cons word-list-ncase)
- (insert (cdr line-cons) "\n"))
- (write-region nil nil words-file nil 0)))))
-
- t)))
+ (when updated
+ (let ((word-list-ncase nil))
+ (dolist (word word-list)
+ (push (cons (downcase word) word) word-list-ncase))
+
+ ;; Sort by the lowercase word.
+ (setq word-list-ncase
+ (sort word-list-ncase (lambda (a b) (string-lessp (car a) (car
b)))))
+
+ ;; Write to 'words-file'.
+ (with-temp-buffer
+ (dolist (line-cons word-list-ncase)
+ (insert (cdr line-cons) "\n"))
+ (write-region nil nil words-file nil 0))))))
+
+ updated)))
;; Word List Initialization
- [nongnu] elpa/spell-fu 143233734a 46/86: Allow global-spell-fu to be ignored per mode or using a function, (continued)
- [nongnu] elpa/spell-fu 143233734a 46/86: Allow global-spell-fu to be ignored per mode or using a function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 103d3a19ce 49/86: Fix checking words that spanned different faces, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1c0424b4c9 55/86: Cleanup: minor tweak to docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu fd27978614 57/86: Update readme.rst, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a7879fe9e7 59/86: Cleanup: over-wide docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a2a0e3b786 60/86: Cleanup: remove redundant group properties, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 570ccd84ed 64/86: Fix spell-fu-goto-{next/prev}-error silently failing, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu b2da2874f3 67/86: Cleanup: use shorter variable names, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 00af362af3 71/86: Add multiple dictionary support, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2ba65de269 74/86: Cleanup: include all arguments in doc-strings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 4782667d7b 76/86: Fail gracefully with a message when aspell can't be found,
ELPA Syncer <=
- [nongnu] elpa/spell-fu 3a19836c69 78/86: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1698c51740 79/86: Store a list of hashes instead of symbol lookups for each word, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 47d92c1989 84/86: Fix wrong function name for multiple languages example, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2590ee3002 80/86: Cleanup: remove cl-remove-if-not, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1299bfca2e 85/86: Merge pull request 'Fix wrong function name for multiple languages example' (#27) from kepi/emacs-spell-fu:master into master, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 907271a557 03/86: Cleanup: unnecessary 'let' nesting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 3898e6f591 04/86: Cleanup: remove use of exception handling, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ae4504f14d 07/86: Fix using hard coded en_US dictionary, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu f2b7d58e87 08/86: Cleanup: correct comment, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1e6928f77d 05/86: Cleanup: add message for generating cache, some comments, ELPA Syncer, 2022/07/07