diff options
| author | Laimonas VÄ—bra | 2016-10-08 15:15:22 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-10-08 15:15:22 +0300 |
| commit | 2913fa2d478e1c717c15e9a4d978454b7161750d (patch) | |
| tree | 1120f8a7cd3d58a8de6a6256c44c241acd48ee70 | |
| parent | 1686a0cde3d6adced3b5393945d6a9ab71b4a3c9 (diff) | |
| download | emacs-2913fa2d478e1c717c15e9a4d978454b7161750d.tar.gz emacs-2913fa2d478e1c717c15e9a4d978454b7161750d.zip | |
Extend dictionary and library-directory handling for Ispell
* lisp/textmodes/ispell.el (ispell-check-version): Allow
overriding LIBDIR via the variable defined by LIBRARYVAR (usually
ISPELL_DICTDIR).
(ispell-valid-dictionary-list): If the -d option to Ispell
specifies an absolute file name, use that regardless of
ispell-library-directory. (Bug#24439)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/textmodes/ispell.el | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 0ed6c689429..5d5d422937b 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -838,7 +838,12 @@ Otherwise returns the library directory name, if that is defined." | |||
| 838 | (let ((default-directory (or (and (boundp 'temporary-file-directory) | 838 | (let ((default-directory (or (and (boundp 'temporary-file-directory) |
| 839 | temporary-file-directory) | 839 | temporary-file-directory) |
| 840 | default-directory)) | 840 | default-directory)) |
| 841 | result status ispell-program-version) | 841 | (get-config-var |
| 842 | (lambda (var) | ||
| 843 | (when (re-search-forward | ||
| 844 | (concat var " = \\\"\\(.+?\\)\\\"") nil t) | ||
| 845 | (match-string 1)))) | ||
| 846 | result libvar status ispell-program-version) | ||
| 842 | 847 | ||
| 843 | (with-temp-buffer | 848 | (with-temp-buffer |
| 844 | (setq status (ispell-call-process | 849 | (setq status (ispell-call-process |
| @@ -860,9 +865,13 @@ Otherwise returns the library directory name, if that is defined." | |||
| 860 | ", " | 865 | ", " |
| 861 | ispell-version)) | 866 | ispell-version)) |
| 862 | (message "%s" result)) | 867 | (message "%s" result)) |
| 863 | ;; return library directory. | 868 | ;; return LIBDIR or LIBRARYVAR (overrides LIBDIR) env. |
| 864 | (if (re-search-forward "LIBDIR = \\\"\\([^ \t\n]*\\)\\\"" nil t) | 869 | (progn |
| 865 | (setq result (match-string 1)))) | 870 | (setq result (funcall get-config-var "LIBDIR") |
| 871 | libvar (funcall get-config-var "LIBRARYVAR")) | ||
| 872 | (when libvar | ||
| 873 | (setq libvar (getenv libvar)) | ||
| 874 | (unless (member libvar '(nil "")) (setq result libvar))))) | ||
| 866 | (goto-char (point-min)) | 875 | (goto-char (point-min)) |
| 867 | (if (not (memq status '(0 nil))) | 876 | (if (not (memq status '(0 nil))) |
| 868 | (error "%s exited with %s %s" ispell-program-name | 877 | (error "%s exited with %s %s" ispell-program-name |
| @@ -1490,23 +1499,29 @@ The variable `ispell-library-directory' defines their location." | |||
| 1490 | 1499 | ||
| 1491 | (let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist)) | 1500 | (let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist)) |
| 1492 | (dict-list (cons "default" nil)) | 1501 | (dict-list (cons "default" nil)) |
| 1493 | name dict-bname) | 1502 | (dict-locate |
| 1503 | (lambda (dict &optional dir) | ||
| 1504 | (locate-file (file-name-nondirectory dict) | ||
| 1505 | `(,(or dir (file-name-directory dict))) | ||
| 1506 | (unless (file-name-extension dict) '(".hash" ".has"))))) | ||
| 1507 | name dict-explt dict-bname) | ||
| 1494 | (dolist (dict dicts) | 1508 | (dolist (dict dicts) |
| 1495 | (setq name (car dict) | 1509 | (setq name (car dict) |
| 1496 | dict-bname (or (car (cdr (member "-d" (nth 5 dict)))) | 1510 | ;; Explicitly (via ispell-args) specified dictionary. |
| 1497 | name)) | 1511 | dict-explt (car (cdr (member "-d" (nth 5 dict)))) |
| 1498 | ;; Include if the dictionary is in the library, or dir not defined. | 1512 | dict-bname (or dict-explt name)) |
| 1499 | (if (and | 1513 | (if (and name |
| 1500 | name | 1514 | (or |
| 1501 | ;; For Aspell, we already know which dictionaries exist. | 1515 | ;; Include all for Aspell (we already know existing dicts) |
| 1502 | (or ispell-really-aspell | 1516 | ispell-really-aspell |
| 1503 | ;; Include all dictionaries if lib directory not known. | 1517 | ;; Include all if `ispell-library-directory' is nil (Hunspell) |
| 1504 | ;; Same for Hunspell, where ispell-library-directory is nil. | 1518 | (not ispell-library-directory) |
| 1505 | (not ispell-library-directory) | 1519 | ;; If explicit (-d with an absolute path) and existing dict. |
| 1506 | (file-exists-p (concat ispell-library-directory | 1520 | (and dict-explt |
| 1507 | "/" dict-bname ".hash")) | 1521 | (file-name-absolute-p dict-explt) |
| 1508 | (file-exists-p (concat ispell-library-directory | 1522 | (funcall dict-locate dict-explt)) |
| 1509 | "/" dict-bname ".has")))) | 1523 | ;; If dict located in `ispell-library-directory'. |
| 1524 | (funcall dict-locate dict-bname ispell-library-directory))) | ||
| 1510 | (push name dict-list))) | 1525 | (push name dict-list))) |
| 1511 | dict-list)) | 1526 | dict-list)) |
| 1512 | 1527 | ||