/[emacs]/emacs/lisp/textmodes/ispell.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/ispell.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.137 by lektu, Tue Feb 4 13:30:44 2003 UTC revision 1.138 by monnier, Wed May 14 01:54:28 2003 UTC
# Line 1  Line 1 
1  ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2  ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2
2    
3  ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.  ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4    
5  ;; Author:           Ken Stevens <k.stevens@ieee.org>  ;; Author:           Ken Stevens <k.stevens@ieee.org>
6  ;; Maintainer:       Ken Stevens <k.stevens@ieee.org>  ;; Maintainer:       Ken Stevens <k.stevens@ieee.org>
# Line 203  Line 203 
203      (defun buffer-substring-no-properties (start end)      (defun buffer-substring-no-properties (start end)
204        (buffer-substring start end)))        (buffer-substring start end)))
205    
 ;;;###autoload  
 (defconst xemacsp (string-match "Lucid\\|XEmacs" emacs-version)  
   "Non nil if using XEmacs.")  
   
 (defconst ispell-graphic-p  
   (if (fboundp 'display-graphic-p)  
       (display-graphic-p)  
     xemacsp)  
   "True if running on a `graphics capable' display.")  
   
206  (defalias 'ispell-check-version 'check-ispell-version)  (defalias 'ispell-check-version 'check-ispell-version)
207    
208  ;;; **********************************************************************  ;;; **********************************************************************
# Line 813  and added as a submenu of the \"Edit\" m Line 803  and added as a submenu of the \"Edit\" m
803  (defvar ispell-menu-map-needed  (defvar ispell-menu-map-needed
804    ;; only needed when not version 18 and not XEmacs.    ;; only needed when not version 18 and not XEmacs.
805    (and (not ispell-menu-map)    (and (not ispell-menu-map)
806         (not xemacsp)         (not (featurep 'xemacs))
807         'reload))         'reload))
808    
809  (defvar ispell-library-directory (condition-case ()  (defvar ispell-library-directory (condition-case ()
# Line 841  and added as a submenu of the \"Edit\" m Line 831  and added as a submenu of the \"Edit\" m
831            name load-dict)            name load-dict)
832        (setq ispell-menu-map (make-sparse-keymap "Spell"))        (setq ispell-menu-map (make-sparse-keymap "Spell"))
833        ;; add the dictionaries to the bottom of the list.        ;; add the dictionaries to the bottom of the list.
834        (dolist (dict dicts)        (define-key ispell-menu-map [default]
835          (setq name (car dict)          '("Select Default Dict"
836                load-dict (car (cdr (member "-d" (nth 5 dict)))))            "Dictionary for which Ispell was configured"
837          (unless (stringp name)            . (lambda () (interactive)
838            (define-key ispell-menu-map [default]                (ispell-change-dictionary "default"))))
             '("Select Default Dict"  
               "Dictionary for which Ispell was configured"  
               . (lambda () (interactive)  
                   (ispell-change-dictionary "default"))))))  
839        (fset 'ispell-dict-map dict-map)        (fset 'ispell-dict-map dict-map)
840        (define-key ispell-menu-map [dictionaries]        (define-key ispell-menu-map [dictionaries]
841          `(menu-item "Select Dict" ispell-dict-map))          `(menu-item "Select Dict" ispell-dict-map))
# Line 940  and added as a submenu of the \"Edit\" m Line 926  and added as a submenu of the \"Edit\" m
926        (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))        (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))
927    
928  ;;; XEmacs versions 19 & 20  ;;; XEmacs versions 19 & 20
929  (if (and xemacsp  (if (and (featurep 'xemacs)
930           (featurep 'menubar)           (featurep 'menubar)
931           (null ispell-menu-xemacs)           (null ispell-menu-xemacs)
932           (not (and (boundp 'infodock-version) infodock-version)))           (not (and (boundp 'infodock-version) infodock-version)))
# Line 991  and added as a submenu of the \"Edit\" m Line 977  and added as a submenu of the \"Edit\" m
977              (add-menu '("Edit") "Spell" ispell-menu-xemacs)))))              (add-menu '("Edit") "Spell" ispell-menu-xemacs)))))
978    
979  ;;; Allow incrementing characters as integers in XEmacs 20  ;;; Allow incrementing characters as integers in XEmacs 20
980  (if (and xemacsp  (if (and (featurep 'xemacs)
981           (fboundp 'int-char))           (fboundp 'int-char))
982      (fset 'ispell-int-char 'int-char)      (fset 'ispell-int-char 'int-char)
983    ;; Emacs and XEmacs 19 or earlier    ;; Emacs and XEmacs 19 or earlier
# Line 1014  used as key in `ispell-dictionary-alist' Line 1000  used as key in `ispell-dictionary-alist'
1000  (defun ispell-decode-string (str)  (defun ispell-decode-string (str)
1001    "Decodes multibyte character strings.    "Decodes multibyte character strings.
1002  Protects against bogus binding of `enable-multibyte-characters' in XEmacs."  Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
1003    (if (and (or xemacsp    (if (and (or (featurep 'xemacs)
1004                 (and (boundp 'enable-multibyte-characters)                 (and (boundp 'enable-multibyte-characters)
1005                      enable-multibyte-characters))                      enable-multibyte-characters))
1006             (fboundp 'decode-coding-string)             (fboundp 'decode-coding-string)
# Line 1189  Currently the only other valid parser is Line 1175  Currently the only other valid parser is
1175    
1176  You can set this variable in hooks in your init file -- eg:  You can set this variable in hooks in your init file -- eg:
1177    
1178  (add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))")  \(add-hook 'tex-mode-hook (lambda () (setq ispell-parser 'tex)))")
1179    
1180  (defvar ispell-region-end (make-marker)  (defvar ispell-region-end (make-marker)
1181    "Marker that allows spelling continuations.")    "Marker that allows spelling continuations.")
# Line 1255  pass it the output of the last ispell in Line 1241  pass it the output of the last ispell in
1241          (insert string)          (insert string)
1242          (if (not (memq cmd cmds-to-defer))          (if (not (memq cmd cmds-to-defer))
1243              (let (coding-system-for-read coding-system-for-write status)              (let (coding-system-for-read coding-system-for-write status)
1244                (if (or xemacsp                (if (or (featurep 'xemacs)
1245                        (and (boundp 'enable-multibyte-characters)                        (and (boundp 'enable-multibyte-characters)
1246                             enable-multibyte-characters))                             enable-multibyte-characters))
1247                    (setq coding-system-for-read (ispell-get-coding-system)                    (setq coding-system-for-read (ispell-get-coding-system)
# Line 2059  The variable `ispell-highlight-face' sel Line 2045  The variable `ispell-highlight-face' sel
2045    
2046  (defun ispell-highlight-spelling-error (start end &optional highlight refresh)  (defun ispell-highlight-spelling-error (start end &optional highlight refresh)
2047    (cond    (cond
2048     (xemacsp     ((featurep 'xemacs)
2049      (ispell-highlight-spelling-error-xemacs start end highlight))      (ispell-highlight-spelling-error-xemacs start end highlight))
2050     ((and (featurep 'faces)     ((and (featurep 'faces)
2051           (or (and (fboundp 'display-color-p) (display-color-p))           (or (and (fboundp 'display-color-p) (display-color-p))
# Line 2076  text line, the returned value may be sma Line 2062  text line, the returned value may be sma
2062  `window-height'."  `window-height'."
2063    (cond ((fboundp 'window-text-height)    (cond ((fboundp 'window-text-height)
2064           (1+ (window-text-height window)))           (1+ (window-text-height window)))
2065          (ispell-graphic-p          ((if (fboundp 'display-graphic-p)
2066                 (display-graphic-p)
2067               (featurep 'xemacs))
2068           (1- (window-height window)))           (1- (window-height window)))
2069          (t          (t
2070           (window-height window))))           (window-height window))))
# Line 2128  Optional third arg SHIFT is an offset to Line 2116  Optional third arg SHIFT is an offset to
2116     ((string= output "") t)              ; for startup with pipes...     ((string= output "") t)              ; for startup with pipes...
2117     ((string= output "*") t)             ; exact match     ((string= output "*") t)             ; exact match
2118     ((string= output "-") t)             ; compound word match     ((string= output "-") t)             ; compound word match
2119     ((string= (substring output 0 1) "+") ; found because of root word     ((eq (aref output 0) ?+)             ; found because of root word
2120      (substring output 2))               ; return root word      (substring output 2))               ; return root word
2121     ((equal 0 (string-match "[\ra-zA-Z]" output))     ((equal 0 (string-match "[\ra-zA-Z]" output))
2122      (ding)                              ; error message from ispell!      (ding)                              ; error message from ispell!
# Line 2136  Optional third arg SHIFT is an offset to Line 2124  Optional third arg SHIFT is an offset to
2124      (sit-for 5)      (sit-for 5)
2125      nil)      nil)
2126     (t                                   ; need to process &, ?, and #'s     (t                                   ; need to process &, ?, and #'s
2127      (let ((type (substring output 0 1)) ; &, ?, or #      (let ((type (aref output 0))        ; &, ?, or #
2128            (original-word (substring output 2 (string-match " " output 2)))            (original-word (substring output 2 (string-match " " output 2)))
2129            (cur-count 0)                 ; contains number of misses + guesses            (cur-count 0)                 ; contains number of misses + guesses
2130            count miss-list guess-list offset)            count miss-list guess-list offset)
2131        (setq output (substring output (match-end 0))) ; skip over misspelling        (setq output (substring output (match-end 0))) ; skip over misspelling
2132        (if (string= type "#")        (if (eq type ?#)
2133            (setq count 0)                ; no misses for type #            (setq count 0)                ; no misses for type #
2134          (setq count (string-to-int output) ; get number of misses.          (setq count (string-to-int output) ; get number of misses.
2135                output (substring output (1+ (string-match " " output 1)))))                output (substring output (1+ (string-match " " output 1)))))
2136        (setq offset (string-to-int output))        (setq offset (string-to-int output))
2137        (if (string= type "#")            ; No miss or guess list.        (if (eq type ?#)                  ; No miss or guess list.
2138            (setq output nil)            (setq output nil)
2139          (setq output (substring output (1+ (string-match " " output 1)))))          (setq output (substring output (1+ (string-match " " output 1)))))
2140        (while output        (while output
# Line 2229  Keeps argument list for future ispell in Line 2217  Keeps argument list for future ispell in
2217      (if ispell-async-processp      (if ispell-async-processp
2218          (set-process-filter ispell-process 'ispell-filter))          (set-process-filter ispell-process 'ispell-filter))
2219      ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs      ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs
2220      (if (and (or xemacsp      (if (and (or (featurep 'xemacs)
2221                   (and (boundp 'enable-multibyte-characters)                   (and (boundp 'enable-multibyte-characters)
2222                        enable-multibyte-characters))                        enable-multibyte-characters))
2223               (fboundp 'set-process-coding-system))               (fboundp 'set-process-coding-system))
# Line 2411  Return nil if spell session is quit, Line 2399  Return nil if spell session is quit,
2399                                (marker-position ispell-region-end)))                                (marker-position ispell-region-end)))
2400                (let* ((start (point))                (let* ((start (point))
2401                       (end (save-excursion (end-of-line) (min (point) reg-end)))                       (end (save-excursion (end-of-line) (min (point) reg-end)))
2402                       (string (ispell-get-line start end reg-end)))                       (string (ispell-get-line start end)))
2403                  (setq end (point))      ; "end" tracks region retrieved.                  (setq end (point))      ; "end" tracks region retrieved.
2404                  (if string              ; there is something to spell check!                  (if string              ; there is something to spell check!
2405                      ;; (special start end)                      ;; (special start end)
# Line 2582  otherwise, the current line is skipped." Line 2570  otherwise, the current line is skipped."
2570    
2571  ;;; Grab the next line of data.  ;;; Grab the next line of data.
2572  ;;; Returns a string with the line data  ;;; Returns a string with the line data
2573  (defun ispell-get-line (start end reg-end)  (defun ispell-get-line (start end)
2574    (let ((ispell-casechars (ispell-get-casechars))    (let ((ispell-casechars (ispell-get-casechars))
2575          string)          string)
2576      (cond                               ; LOOK AT THIS LINE AND SKIP OR PROCESS      (cond                               ; LOOK AT THIS LINE AND SKIP OR PROCESS
# Line 2845  Standard ispell choices are then availab Line 2833  Standard ispell choices are then availab
2833             (cond             (cond
2834              ((string-equal (upcase word) word)              ((string-equal (upcase word) word)
2835               (setq possibilities (mapcar 'upcase possibilities)))               (setq possibilities (mapcar 'upcase possibilities)))
2836              ((string-equal (upcase (substring word 0 1)) (substring word 0 1))              ((eq (upcase (aref word 0)) (aref word 0))
2837               (setq possibilities (mapcar (function               (setq possibilities (mapcar (function
2838                                            (lambda (pos)                                            (lambda (pos)
2839                                              (if (string-equal                                              (if (eq (aref word 0) (aref pos 0))
                                                  (substring word 0 1)  
                                                  (substring pos 0 1))  
2840                                                  pos                                                  pos
2841                                                (capitalize pos))))                                                (capitalize pos))))
2842                                           possibilities))))                                           possibilities))))

Legend:
Removed from v.1.137  
changed lines
  Added in v.1.138

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26