714 |
(defun check-ispell-version (&optional interactivep) |
(defun check-ispell-version (&optional interactivep) |
715 |
"Ensure that `ispell-program-name' is valid and the correct version. |
"Ensure that `ispell-program-name' is valid and the correct version. |
716 |
Returns version number if called interactively. |
Returns version number if called interactively. |
717 |
Otherwise returns the library path if defined." |
Otherwise returns the library directory name, if that is defined." |
718 |
;; This is a little wasteful as we actually launch ispell twice: once |
;; This is a little wasteful as we actually launch ispell twice: once |
719 |
;; to make sure it's the right version, and once for real. But people |
;; to make sure it's the right version, and once for real. But people |
720 |
;; get confused by version mismatches *all* the time (and I've got the |
;; get confused by version mismatches *all* the time (and I've got the |
748 |
", " |
", " |
749 |
ispell-version)) |
ispell-version)) |
750 |
(message result)) |
(message result)) |
751 |
;; return library path. |
;; return library directory. |
752 |
(if (re-search-forward "LIBDIR = \\\"\\([^ \t\n]*\\)\\\"" nil t) |
(if (re-search-forward "LIBDIR = \\\"\\([^ \t\n]*\\)\\\"" nil t) |
753 |
(setq result (buffer-substring (match-beginning 1) (match-end 1))))) |
(setq result (buffer-substring (match-beginning 1) (match-end 1))))) |
754 |
(goto-char (point-min)) |
(goto-char (point-min)) |
810 |
(not xemacsp) |
(not xemacsp) |
811 |
'reload)) |
'reload)) |
812 |
|
|
813 |
(defvar ispell-library-path (if (or (not (fboundp 'byte-compiling-files-p)) |
(defvar ispell-library-directory (condition-case () |
814 |
(not (byte-compiling-files-p))) |
(check-ispell-version) |
815 |
(check-ispell-version)) |
(error nil)) |
816 |
"The directory where ispell dictionaries reside.") |
"Directory where ispell dictionaries reside.") |
817 |
|
|
818 |
(defvar ispell-process nil |
(defvar ispell-process nil |
819 |
"The process object for Ispell.") |
"The process object for Ispell.") |
828 |
"Non-nil means that the OS supports asynchronous processes.") |
"Non-nil means that the OS supports asynchronous processes.") |
829 |
|
|
830 |
;;;###autoload |
;;;###autoload |
831 |
(if (and ispell-menu-map-needed |
(if ispell-menu-map-needed |
|
(or (not (fboundp 'byte-compiling-files-p)) |
|
|
(not (byte-compiling-files-p)))) |
|
832 |
(let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist))) |
(let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist))) |
833 |
;; `ispell-library-path' intentionally not defined in autoload |
(dir ispell-library-directory) |
|
(path (and (boundp 'ispell-library-path) ispell-library-path)) |
|
834 |
name load-dict) |
name load-dict) |
835 |
(setq ispell-menu-map (make-sparse-keymap "Spell")) |
(setq ispell-menu-map (make-sparse-keymap "Spell")) |
836 |
;; add the dictionaries to the bottom of the list. |
;; add the dictionaries to the bottom of the list. |
845 |
(list 'lambda () '(interactive) |
(list 'lambda () '(interactive) |
846 |
(list |
(list |
847 |
'ispell-change-dictionary "default")))))) |
'ispell-change-dictionary "default")))))) |
848 |
((or (not path) ; load all if library dir not defined |
((or (not dir) ; load all if library dir not defined |
849 |
(file-exists-p (concat path "/" name ".hash")) |
(file-exists-p (concat dir "/" name ".hash")) |
850 |
(file-exists-p (concat path "/" name ".has")) |
(file-exists-p (concat dir "/" name ".has")) |
851 |
(and load-dict |
(and load-dict |
852 |
(or (file-exists-p(concat path "/" load-dict ".hash")) |
(or (file-exists-p (concat dir "/" load-dict ".hash")) |
853 |
(file-exists-p(concat path "/" load-dict ".has"))))) |
(file-exists-p (concat dir "/" load-dict ".has"))))) |
854 |
(define-key ispell-menu-map (vector (intern name)) |
(define-key ispell-menu-map (vector (intern name)) |
855 |
(cons (concat "Select " (capitalize name) " Dict") |
(cons (concat "Select " (capitalize name) " Dict") |
856 |
(list 'lambda () '(interactive) |
(list 'lambda () '(interactive) |
859 |
|
|
860 |
;;; define commands in menu in opposite order you want them to appear. |
;;; define commands in menu in opposite order you want them to appear. |
861 |
;;;###autoload |
;;;###autoload |
862 |
(if (and ispell-menu-map-needed |
(if ispell-menu-map-needed |
|
(or (not (fboundp 'byte-compiling-files-p)) |
|
|
(not (byte-compiling-files-p)))) |
|
863 |
(progn |
(progn |
864 |
(define-key ispell-menu-map [ispell-change-dictionary] |
(define-key ispell-menu-map [ispell-change-dictionary] |
865 |
'(menu-item "Change Dictionary..." ispell-change-dictionary |
'(menu-item "Change Dictionary..." ispell-change-dictionary |
866 |
:help "Supply explicit path to dictionary")) |
:help "Supply explicit dictionary file name")) |
867 |
(define-key ispell-menu-map [ispell-kill-ispell] |
(define-key ispell-menu-map [ispell-kill-ispell] |
868 |
'(menu-item "Kill Process" ispell-kill-ispell |
'(menu-item "Kill Process" ispell-kill-ispell |
869 |
:enable (and (boundp 'ispell-process) ispell-process |
:enable (and (boundp 'ispell-process) ispell-process |
895 |
:help "Complete word fragment at cursor")))) |
:help "Complete word fragment at cursor")))) |
896 |
|
|
897 |
;;;###autoload |
;;;###autoload |
898 |
(if (and ispell-menu-map-needed |
(if ispell-menu-map-needed |
|
(or (not (fboundp 'byte-compiling-files-p)) |
|
|
(not (byte-compiling-files-p)))) |
|
899 |
(progn |
(progn |
900 |
(define-key ispell-menu-map [ispell-continue] |
(define-key ispell-menu-map [ispell-continue] |
901 |
'(menu-item "Continue Spell-Checking" ispell-continue |
'(menu-item "Continue Spell-Checking" ispell-continue |
912 |
:help "Spell-check only comments and strings")))) |
:help "Spell-check only comments and strings")))) |
913 |
|
|
914 |
;;;###autoload |
;;;###autoload |
915 |
(if (and ispell-menu-map-needed |
(if ispell-menu-map-needed |
|
(or (not (fboundp 'byte-compiling-files-p)) |
|
|
(not (byte-compiling-files-p)))) |
|
916 |
(progn |
(progn |
917 |
(define-key ispell-menu-map [ispell-region] |
(define-key ispell-menu-map [ispell-region] |
918 |
'(menu-item "Spell-Check Region" ispell-region |
'(menu-item "Spell-Check Region" ispell-region |
955 |
(setq name (car (car dicts)) |
(setq name (car (car dicts)) |
956 |
load-dict (car (cdr (member "-d" (nth 5 (car dicts))))) |
load-dict (car (cdr (member "-d" (nth 5 (car dicts))))) |
957 |
dicts (cdr dicts)) |
dicts (cdr dicts)) |
958 |
;; Include if the dictionary is in the library, or path not defined. |
;; Include if the dictionary is in the library, or dir not defined. |
959 |
(if (and (stringp name) |
(if (and (stringp name) |
960 |
(or (not ispell-library-path) |
(or (not ispell-library-directory) |
961 |
(file-exists-p (concat ispell-library-path "/" |
(file-exists-p (concat ispell-library-directory "/" |
962 |
name ".hash")) |
name ".hash")) |
963 |
(file-exists-p (concat ispell-library-path "/" |
(file-exists-p (concat ispell-library-directory "/" |
964 |
name ".has")) |
name ".has")) |
965 |
(and load-dict |
(and load-dict |
966 |
(or (file-exists-p (concat ispell-library-path "/" |
(or (file-exists-p (concat ispell-library-directory "/" |
967 |
load-dict ".hash")) |
load-dict ".hash")) |
968 |
(file-exists-p (concat ispell-library-path "/" |
(file-exists-p (concat ispell-library-directory "/" |
969 |
load-dict ".has")))))) |
load-dict ".has")))))) |
970 |
(setq menu (append menu |
(setq menu (append menu |
971 |
(list |
(list |