diff options
Diffstat (limited to 'lisp/textmodes/ispell.el')
-rw-r--r-- | lisp/textmodes/ispell.el | 184 |
1 files changed, 89 insertions, 95 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 9789968b15c..6408f3876f2 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -320,18 +320,21 @@ The following values are supported: :type 'boolean :group 'ispell) +(defvaralias 'ispell-format-word 'ispell-format-word-function) + (defcustom ispell-format-word-function (function upcase) "Formatting function for displaying word being spell checked. The function must take one string argument and return a string." :type 'function :group 'ispell) -(defvaralias 'ispell-format-word 'ispell-format-word-function) +;; FIXME framepop.el last updated c 2003 (?), +;; probably something else replaces it these days. (defcustom ispell-use-framepop-p nil "When non-nil ispell uses framepop to display choices in a dedicated frame. You can set this variable to dynamically use framepop if you are in a window system by evaluating the following on startup to set this variable: - (and window-system (condition-case () (require \\='framepop) (error nil)))" + (and (display-graphic-p) (require \\='framepop nil t))" :type 'boolean :group 'ispell) @@ -814,16 +817,6 @@ See `ispell-buffer-with-debug' for an example of use." ;; because otherwise this file gets autoloaded every time Emacs starts ;; so that it can set up the menus and determine keyboard equivalents. -;;;###autoload -(defvar ispell-menu-map nil "Key map for ispell menu.") -;; Redo menu when loading ispell to get dictionary modifications -(setq ispell-menu-map nil) - -;;; Set up dictionary -;;;###autoload -(defvar ispell-menu-map-needed - (unless ispell-menu-map 'reload)) - (defvar ispell-library-directory (condition-case () (ispell-check-version) (error nil)) @@ -1185,6 +1178,12 @@ dictionary from that list was found." ;; Parse and set values for default dictionary. (setq hunspell-default-dict (or hunspell-multi-dict (car hunspell-default-dict))) + ;; If hunspell-default-dict is nil, ispell-parse-hunspell-affix-file + ;; will barf with an error message that doesn't help users figure + ;; out what is wrong. Produce an error message that points to the + ;; root cause of the problem. + (or hunspell-default-dict + (error "Can't find Hunspell dictionary with a .aff affix file")) (setq hunspell-default-dict-entry (ispell-parse-hunspell-affix-file hunspell-default-dict)) ;; Create an alist of found dicts with only names, except for default dict. @@ -1207,9 +1206,11 @@ Internal use.") (with-output-to-string (with-current-buffer standard-output - (apply 'ispell-call-process - (replace-regexp-in-string "enchant\\(-[0-9]\\)?$" "enchant-lsmod\\1" - ispell-program-name) nil t nil args)))) + (apply #'ispell-call-process + (replace-regexp-in-string "enchant\\(-[0-9]\\)?\\'" + "enchant-lsmod\\1" + ispell-program-name) + nil t nil args)))) (defun ispell--get-extra-word-characters (&optional lang) "Get the extra word characters for LANG as a character class. @@ -1417,80 +1418,78 @@ The variable `ispell-library-directory' defines their location." (push name dict-list))) dict-list)) -;; Define commands in menu in opposite order you want them to appear. ;;;###autoload -(if ispell-menu-map-needed - (progn - (setq ispell-menu-map (make-sparse-keymap "Spell")) - (define-key ispell-menu-map [ispell-change-dictionary] - `(menu-item ,(purecopy "Change Dictionary...") ispell-change-dictionary - :help ,(purecopy "Supply explicit dictionary file name"))) - (define-key ispell-menu-map [ispell-kill-ispell] - `(menu-item ,(purecopy "Kill Process") - (lambda () (interactive) (ispell-kill-ispell nil 'clear)) - :enable (and (boundp 'ispell-process) ispell-process - (eq (ispell-process-status) 'run)) - :help ,(purecopy "Terminate Ispell subprocess"))) - (define-key ispell-menu-map [ispell-pdict-save] - `(menu-item ,(purecopy "Save Dictionary") - (lambda () (interactive) (ispell-pdict-save t t)) - :help ,(purecopy "Save personal dictionary"))) - (define-key ispell-menu-map [ispell-customize] - `(menu-item ,(purecopy "Customize...") - (lambda () (interactive) (customize-group 'ispell)) - :help ,(purecopy "Customize spell checking options"))) - (define-key ispell-menu-map [ispell-help] - ;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ? - `(menu-item ,(purecopy "Help") - (lambda () (interactive) (describe-function 'ispell-help)) - :help ,(purecopy "Show standard Ispell keybindings and commands"))) - (define-key ispell-menu-map [flyspell-mode] - `(menu-item ,(purecopy "Automatic spell checking (Flyspell)") - flyspell-mode - :help ,(purecopy "Check spelling while you edit the text") - :button (:toggle . (bound-and-true-p flyspell-mode)))) - (define-key ispell-menu-map [ispell-complete-word] - `(menu-item ,(purecopy "Complete Word") ispell-complete-word - :help ,(purecopy "Complete word at cursor using dictionary"))) - (define-key ispell-menu-map [ispell-complete-word-interior-frag] - `(menu-item ,(purecopy "Complete Word Fragment") - ispell-complete-word-interior-frag - :help ,(purecopy "Complete word fragment at cursor"))))) - -;;;###autoload -(if ispell-menu-map-needed - (progn - (define-key ispell-menu-map [ispell-continue] - `(menu-item ,(purecopy "Continue Spell-Checking") ispell-continue - :enable (and (boundp 'ispell-region-end) - (marker-position ispell-region-end) - (equal (marker-buffer ispell-region-end) - (current-buffer))) - :help ,(purecopy "Continue spell checking last region"))) - (define-key ispell-menu-map [ispell-word] - `(menu-item ,(purecopy "Spell-Check Word") ispell-word - :help ,(purecopy "Spell-check word at cursor"))) - (define-key ispell-menu-map [ispell-comments-and-strings] - `(menu-item ,(purecopy "Spell-Check Comments") - ispell-comments-and-strings - :help ,(purecopy "Spell-check only comments and strings"))))) - +(defconst ispell-menu-map + ;; Use `defconst' so as to redo the menu when loading ispell, like the + ;; previous code did. + + ;; Define commands in menu in opposite order you want them to appear. + (let ((map (make-sparse-keymap "Spell"))) + (define-key map [ispell-change-dictionary] + `(menu-item ,(purecopy "Change Dictionary...") ispell-change-dictionary + :help ,(purecopy "Supply explicit dictionary file name"))) + (define-key map [ispell-kill-ispell] + `(menu-item ,(purecopy "Kill Process") + (lambda () (interactive) (ispell-kill-ispell nil 'clear)) + :enable (and (boundp 'ispell-process) ispell-process + (eq (ispell-process-status) 'run)) + :help ,(purecopy "Terminate Ispell subprocess"))) + (define-key map [ispell-pdict-save] + `(menu-item ,(purecopy "Save Dictionary") + (lambda () (interactive) (ispell-pdict-save t t)) + :help ,(purecopy "Save personal dictionary"))) + (define-key map [ispell-customize] + `(menu-item ,(purecopy "Customize...") + (lambda () (interactive) (customize-group 'ispell)) + :help ,(purecopy "Customize spell checking options"))) + (define-key map [ispell-help] + ;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ? + `(menu-item ,(purecopy "Help") + (lambda () (interactive) (describe-function 'ispell-help)) + :help ,(purecopy "Show standard Ispell keybindings and commands"))) + (define-key map [flyspell-mode] + `(menu-item ,(purecopy "Automatic spell checking (Flyspell)") + flyspell-mode + :help ,(purecopy "Check spelling while you edit the text") + :button (:toggle . (bound-and-true-p flyspell-mode)))) + (define-key map [ispell-complete-word] + `(menu-item ,(purecopy "Complete Word") ispell-complete-word + :help ,(purecopy "Complete word at cursor using dictionary"))) + (define-key map [ispell-complete-word-interior-frag] + `(menu-item ,(purecopy "Complete Word Fragment") + ispell-complete-word-interior-frag + :help ,(purecopy "Complete word fragment at cursor"))) + + (define-key map [ispell-continue] + `(menu-item ,(purecopy "Continue Spell-Checking") ispell-continue + :enable (and (boundp 'ispell-region-end) + (marker-position ispell-region-end) + (equal (marker-buffer ispell-region-end) + (current-buffer))) + :help ,(purecopy "Continue spell checking last region"))) + (define-key map [ispell-word] + `(menu-item ,(purecopy "Spell-Check Word") ispell-word + :help ,(purecopy "Spell-check word at cursor"))) + (define-key map [ispell-comments-and-strings] + `(menu-item ,(purecopy "Spell-Check Comments") + ispell-comments-and-strings + :help ,(purecopy "Spell-check only comments and strings"))) + + (define-key map [ispell-region] + `(menu-item ,(purecopy "Spell-Check Region") ispell-region + :enable mark-active + :help ,(purecopy "Spell-check text in marked region"))) + (define-key map [ispell-message] + `(menu-item ,(purecopy "Spell-Check Message") ispell-message + :visible (eq major-mode 'mail-mode) + :help ,(purecopy "Skip headers and included message text"))) + (define-key map [ispell-buffer] + `(menu-item ,(purecopy "Spell-Check Buffer") ispell-buffer + :help ,(purecopy "Check spelling of selected buffer"))) + map) + "Key map for ispell menu.") ;;;###autoload -(if ispell-menu-map-needed - (progn - (define-key ispell-menu-map [ispell-region] - `(menu-item ,(purecopy "Spell-Check Region") ispell-region - :enable mark-active - :help ,(purecopy "Spell-check text in marked region"))) - (define-key ispell-menu-map [ispell-message] - `(menu-item ,(purecopy "Spell-Check Message") ispell-message - :visible (eq major-mode 'mail-mode) - :help ,(purecopy "Skip headers and included message text"))) - (define-key ispell-menu-map [ispell-buffer] - `(menu-item ,(purecopy "Spell-Check Buffer") ispell-buffer - :help ,(purecopy "Check spelling of selected buffer"))) - (fset 'ispell-menu-map (symbol-value 'ispell-menu-map)))) - +(fset 'ispell-menu-map (symbol-value 'ispell-menu-map)) ;;; ********************************************************************** @@ -1832,11 +1831,9 @@ Only works for Aspell and Enchant." (setq default-directory defdir) (insert string) (if (not (memq cmd cmds-to-defer)) - (let (coding-system-for-read coding-system-for-write status) - (if (and (boundp 'enable-multibyte-characters) - enable-multibyte-characters) - (setq coding-system-for-read (ispell-get-coding-system) - coding-system-for-write (ispell-get-coding-system))) + (let* ((coding-system-for-read (ispell-get-coding-system)) + (coding-system-for-write coding-system-for-read) + status) (set-buffer output-buf) (erase-buffer) (set-buffer session-buf) @@ -3710,9 +3707,6 @@ available on the net." ;;;###autoload (define-minor-mode ispell-minor-mode "Toggle last-word spell checking (Ispell minor mode). -With a prefix argument ARG, enable Ispell minor mode if ARG is -positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil. Ispell minor mode is a buffer-local minor mode. When enabled, typing SPC or RET warns you if the previous word is incorrectly |