(provide (quote ispell)) (defconst ispell-out-name " *ispell*" "\ Name of the buffer that is associated with the 'ispell' process") (defconst ispell-temp-name " *ispell-temp*" "\ Name of the temporary buffer that 'ispell-region' uses to hold the filtered region") (defvar ispell-program-name "ispell" "\ Program invoked by ispell-word and ispell-region commands.") (defvar ispell-dictionary nil "\ Personal dictionary file containing a list of words, one to a line. If nil, defaults to ispell's normal default (usually ~/.ispell_words).") (defvar ispell-words-have-boundaries t "\ If nil, a misspelled word matches embedded words too. This is useful in nroff/troff, where a misspelled word may be hidded (e.g., Iword B), and a pain otherwise.") (defvar ispell-syntax-table nil) (if (null ispell-syntax-table) (progn (setq ispell-syntax-table (make-syntax-table)) (modify-syntax-entry 48 ". " ispell-syntax-table) (modify-syntax-entry 49 ". " ispell-syntax-table) (modify-syntax-entry 50 ". " ispell-syntax-table) (modify-syntax-entry 51 ". " ispell-syntax-table) (modify-syntax-entry 52 ". " ispell-syntax-table) (modify-syntax-entry 53 ". " ispell-syntax-table) (modify-syntax-entry 54 ". " ispell-syntax-table) (modify-syntax-entry 55 ". " ispell-syntax-table) (modify-syntax-entry 56 ". " ispell-syntax-table) (modify-syntax-entry 57 ". " ispell-syntax-table) (modify-syntax-entry 36 ". " ispell-syntax-table) (modify-syntax-entry 37 ". " ispell-syntax-table))) (defun ispell-word (&optional quietly) "\ Check spelling of word at or before dot. If word not found in dictionary, display possible corrections in a window and let user select." (interactive) (byte-code "Lj ͎!!?#e#e##5!!! \"))  U !\" q P\"dbh\"u !ceb` `\"!) = !\" ; ! !# \" b \" ! ." [current-syntax start end word poss replace ispell-syntax-table nil t quietly ispell-out-name ispell-process syntax-table ((byte-code "!" [current-syntax set-syntax-table] 2)) set-syntax-table looking-at "\\w" re-search-backward stay "\\W" re-search-forward "\\w+" error "No word to check." match-beginning 0 match-end buffer-substring ispell-init-process message "Checking spelling of %s..." upcase send-string " " /= 10 accept-process-output ispell-parse-output end-of-line "Checking spelling of %s... correct" "Checking spelling of %s... correct (from %s)" ispell-choose delete-region insert-string] 28)) (defun ispell-choose (choices word) "\ Display possible corrections from list CHOICES. Return chosen word if one is chosen, or nil to keep original WORD." (byte-code "Ύϋ)" [count line words choices window-min-height char num result mode-line-format word nil t ispell-process help-char ((byte-code "!" [bury-buffer "*Choices*"] 2)) ((byte-code " !q  !Q Wi @G# X9ʂ@c T\\ @% AT$U`c) !! ! !\"r Z U U !ʂ2 U  Q\"  Q\" !ʂ2 U  Q\" !ʂ2 U ! !\"\"2YW ! 82 U )˂2  U U.!!˂2 ˉ=>ʈo." [count line words choices window-min-height char num result mode-line-format word nil t ispell-process help-char 0 2 get-buffer-create "*Choices*" erase-buffer "-- %b (Type number to select replacement for " upcase ") --" + 7 window-width " " insert "(" 48 ") " " " "(none)" overlay-window switch-to-buffer select-window next-window message "%s: a(dd), c(orrect), r(eplace), space or s(kip) [default], ? (help)" 32 115 ispell-ignore-later-occurrences 97 send-string "*" "@" 99 114 read-string format "Replacement for %s: " 18 recursive-edit 63 "a(dd to dict), c(orrect for this session), r(eplace with your word), or number of replacement" sit-for 3 ding] 30))] 1)) (defun ispell-ignore-later-occurrences (word) (byte-code "!q Q P\"))" [ispell-temp-name word get-buffer replace-regexp "^" "$" "+"] 5)) (defun overlay-window (height) "\ Create a (usually small) window with HEIGHT lines and avoid recentering." (byte-code " `) !`) W ! \"+)" [oldot top height newin beginning-of-line move-to-window-line nil split-window-vertically set-window-start] 6)) (defvar ispell-process nil "\ Holds the process object for 'ispell'") (defun ispell-parse-output (output) "\ Parse the OUTPUT string of 'ispell' and return either t for an exact match, a string containing the root word for a match via suffix removal, a list of possible correct spellings, or nil for a complete miss." (byte-code "\" X\"‚XO\"'OX\"?U\" # H O B TO*) )" [output t nil choice-list start end string= "*" "#" 0 1 "+" 2 "" string-match "[A-z]" " \\|$"] 10)) (defun ispell-init-process nil "\ Check status of 'ispell' process and start if necessary." (byte-code " != q )A! !# ! 4 E6C%!!" [ispell-process ispell-out-name ispell-program-name ispell-dictionary process-status run erase-buffer message "Starting new ispell process..." get-buffer kill-buffer apply start-process "ispell" "-p" "-A" process-kill-without-query sit-for 3] 13)) (defvar ispell-filter-hook "tr" "\ Filter to pass a region through before sending it to ispell. Must produce output one word per line. Typically this is set to tr, deroff, detex, etc.") (make-variable-buffer-local (quote ispell-filter-hook)) (defvar ispell-filter-hook-args (quote ("-cs" "A-Za-z" " ")) "Argument LIST to pass to ispell-filter-hook") (make-variable-buffer-local (quote ispell-filter-hook-args)) (defun ispell-latex-mode nil "\ Function that can be called from LaTeX-mode-hook to reset some ispell buffer-specific variables to the proper values for LaTeX files (in particular the two variables ispell-filter-hook and ispell-filter-hook-args are reset)." (byte-code "‰É" [ispell-filter-hook ispell-filter-hook-args "sh" ("-c" "detex -w | tr -cs A-Za-z ' '")] 2)) (defun ispell-region (start end) "\ Check a region for spelling errors interactively. The variable which should be buffer or mode specific ispell-filter-hook is called to filter out text processing commands." (interactive "r") (byte-code "Јp! !     ! ݎ!  \"!! q q   &\"\" b qh\"pcebgU!ted % Q\"!\"!m?!= qdb ` b #? `\"` q!!\" !` `\"! q` `\"!!`qS$@O\">AO#TBC!BQZC!#` D#` EFG \"!!H\"))IBC!BQC!\"))ށJ\"r!\"! q))). " [this-buf spell-file spell-buf ispell-temp-name current-syntax tracker word poss replace endbound ispell-out ispell-out-name start end ispell-syntax-table ispell-filter-hook nil ispell-filter-hook-args ispell-process count t ispell-words-have-boundaries make-temp-name "/tmp/ispell" get-buffer-create syntax-table 1 ispell-init-process get-buffer ((byte-code "!=!!\" ! !\" !" [ispell-process current-syntax spell-file process-status run message "Done." "Warning - ispell process died (%s)." set-syntax-table file-exists-p delete-file] 8)) message "Prefrobnicating..." narrow-to-region sit-for 0 set-syntax-table erase-buffer apply call-process-region append list /= 10 " " delete-char write-region send-string "&Include_File&" "Looking for a misspelled word... (status: %s)" process-status run beginning-of-line re-search-forward "^[#&]" count-lines forward-line accept-process-output 2 buffer-substring end-of-line forward-char ispell-parse-output "\\W*\\(\\w+\\)" string= "+" search-forward "\\b" regexp-quote search-backward recenter / window-height ispell-choose query-replace-regexp "Can't find %s in original text -- Any key to continue"] 58)) (defun ispell-buffer nil "\ Check the current buffer for spelling errors interactively. The variable which should be buffer or mode specific ispell-filter-hook is called to filter out text processing commands." (interactive) (byte-code "ed\"" [nil ispell-region] 3)) (defvar ispell-words-file "/usr/dict/words" "\ *File used for ispell-complete-word command. On 4.3bsd systems, try using \"/usr/dict/web2\" for a larger selection. Apollo users may want to try \"/sys/dict\".") (defun ispell-complete-word nil "\ Look up word before point in dictionary (see the variable ispell-words-file) and try to complete it. If in the middle of a word, replace the entire word." (interactive) (byte-code "ĈȊ!`)`\"! !q & V4 !5) \"R I!!!," [current-word in-word possibilities ispell-temp-name nil t ispell-words-file replacement buffer-substring backward-word 1 looking-at "\\w" get-buffer-create erase-buffer call-process "look" "-df" buffer-size 0 ispell-parse-output buffer-string ispell-choose kill-wor search-backward replace-match] 14))