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

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

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

revision 1.64 by monnier, Fri Jun 3 15:02:44 2005 UTC revision 1.65 by monnier, Mon Jun 6 21:06:19 2005 UTC
# Line 268  If `flyspell-large-region' is nil, all r Line 268  If `flyspell-large-region' is nil, all r
268    :type 'boolean)    :type 'boolean)
269    
270  (defcustom flyspell-auto-correct-binding  (defcustom flyspell-auto-correct-binding
271    (cond    [(control ?\;)]
    ((eq flyspell-emacs 'xemacs)  
     [(control \;)])  
    (t  
     [?\C-\;]))  
272    "The key binding for flyspell auto correction."    "The key binding for flyspell auto correction."
273    :group 'flyspell)    :group 'flyspell)
274    
# Line 425  property of the major mode name.") Line 421  property of the major mode name.")
421      (define-key map [(control \.)] 'flyspell-auto-correct-word)      (define-key map [(control \.)] 'flyspell-auto-correct-word)
422      map))      map))
423    
424  ;;;###autoload  (defvar flyspell-mode-map
425  (defvar flyspell-mode-map (make-sparse-keymap))    (let ((map (make-sparse-keymap)))
426        ;; mouse, keyboard bindings and misc definition
427  ;; mouse, keyboard bindings and misc definition      (if flyspell-use-meta-tab
428  (when (or (assoc 'flyspell-mode minor-mode-map-alist)        (define-key map "\M-\t" 'flyspell-auto-correct-word))
429            (setq minor-mode-map-alist      (cond
430                  (cons (cons 'flyspell-mode flyspell-mode-map)       ;; I don't understand this test, so I left it as is.  --Stef
431                        minor-mode-map-alist)))       ((or (featurep 'xemacs) flyspell-use-local-map)
432    (if flyspell-use-meta-tab        (define-key map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word)
433        (define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word))        (define-key map [(control ?\,)] 'flyspell-goto-next-error)
434    (cond        (define-key map [(control ?\.)] 'flyspell-auto-correct-word)))
435     ((eq flyspell-emacs 'xemacs)      map))
     (define-key flyspell-mode-map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word)  
     (define-key flyspell-mode-map [(control \,)] 'flyspell-goto-next-error)  
     (define-key flyspell-mode-map [(control \.)] 'flyspell-auto-correct-word))  
    (flyspell-use-local-map  
     (define-key flyspell-mode-map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word)  
     (define-key flyspell-mode-map [?\C-\,] 'flyspell-goto-next-error)  
     (define-key flyspell-mode-map [?\C-\.] 'flyspell-auto-correct-word))))  
   
436    
437  ;; the name of the overlay property that defines the keymap  ;; the name of the overlay property that defines the keymap
438  (defvar flyspell-overlay-keymap-property-name 'keymap)  (defvar flyspell-overlay-keymap-property-name 'keymap)
# Line 462  property of the major mode name.") Line 450  property of the major mode name.")
450  ;*    Highlighting                                                     */  ;*    Highlighting                                                     */
451  ;*---------------------------------------------------------------------*/  ;*---------------------------------------------------------------------*/
452  (defface flyspell-incorrect-face  (defface flyspell-incorrect-face
453    (if (eq flyspell-emacs 'xemacs)    '((((class color)) (:foreground "OrangeRed" :bold t :underline t))
454        '((((class color)) (:foreground "OrangeRed" :bold t :underline t))      (t (:bold t)))
         (t (:bold t)))  
     '((((class color)) (:foreground "OrangeRed" :weight bold :underline t))  
       (t (:weight bold))))  
455    "Face used for marking a misspelled word in Flyspell."    "Face used for marking a misspelled word in Flyspell."
456    :group 'flyspell)    :group 'flyspell)
457    
458  (defface flyspell-duplicate-face  (defface flyspell-duplicate-face
459    (if (eq flyspell-emacs 'xemacs)    '((((class color)) (:foreground "Gold3" :bold t :underline t))
460        '((((class color)) (:foreground "Gold3" :bold t :underline t))      (t (:bold t)))
         (t (:bold t)))  
     '((((class color)) (:foreground "Gold3" :weight bold :underline t))  
       (t (:weight bold))))  
461    "Face used for marking a misspelled word that appears twice in the buffer.    "Face used for marking a misspelled word that appears twice in the buffer.
462  See also `flyspell-duplicate-distance'."  See also `flyspell-duplicate-distance'."
463    :group 'flyspell)    :group 'flyspell)
# Line 1057  Mostly we check word delimiters." Line 1039  Mostly we check word delimiters."
1039            (cond            (cond
1040             ((and (or (not (eq ispell-parser 'tex))             ((and (or (not (eq ispell-parser 'tex))
1041                       (and (> start (point-min))                       (and (> start (point-min))
1042                            (not (eq (char-after (1- start)) ?}))                            (not (memq (char-after (1- start)) '(?\} ?\\)))))
                           (not (eq (char-after (1- start)) ?\\))))  
1043                   flyspell-mark-duplications-flag                   flyspell-mark-duplications-flag
1044                   (save-excursion                   (save-excursion
1045                     (goto-char (1- start))                     (goto-char (1- start))
# Line 1181  Mostly we check word delimiters." Line 1162  Mostly we check word delimiters."
1162  ;*    time that function is called.                                    */  ;*    time that function is called.                                    */
1163  ;*---------------------------------------------------------------------*/  ;*---------------------------------------------------------------------*/
1164  (defun flyspell-math-tex-command-p ()  (defun flyspell-math-tex-command-p ()
1165    (cond    (when (fboundp 'texmathp)
1166     (flyspell-check-tex-math-command      (cond
1167      nil)       (flyspell-check-tex-math-command
1168     ((eq flyspell-tex-math-initialized t)        nil)
1169      (texmathp))       ((eq flyspell-tex-math-initialized t)
1170     ((eq flyspell-tex-math-initialized 'error)        (texmathp))
1171      nil)       ((eq flyspell-tex-math-initialized 'error)
1172     (t        nil)
1173      (setq flyspell-tex-math-initialized t)       (t
1174      (condition-case nil        (setq flyspell-tex-math-initialized t)
1175          (texmathp)        (condition-case nil
1176        (error (progn            (texmathp)
1177                 (setq flyspell-tex-math-initialized 'error)          (error (progn
1178                 nil))))))                   (setq flyspell-tex-math-initialized 'error)
1179                     nil)))))))
1180    
1181  ;*---------------------------------------------------------------------*/  ;*---------------------------------------------------------------------*/
1182  ;*    flyspell-tex-command-p ...                                       */  ;*    flyspell-tex-command-p ...                                       */
# Line 1381  Word syntax described by `flyspell-dicti Line 1363  Word syntax described by `flyspell-dicti
1363    (let ((buffer flyspell-external-ispell-buffer))    (let ((buffer flyspell-external-ispell-buffer))
1364      (set-buffer buffer)      (set-buffer buffer)
1365      (goto-char (point-min))      (goto-char (point-min))
1366      (let ((size (- flyspell-large-region-end flyspell-large-region-beg))      (let ((pword "")
           (start flyspell-large-region-beg)  
           (pword "")  
1367            (pcount 1))            (pcount 1))
1368        ;; now we are done with ispell, we have to find the word in        ;; now we are done with ispell, we have to find the word in
1369        ;; the initial buffer        ;; the initial buffer
# Line 1954  The word checked is the word at the mous Line 1934  The word checked is the word at the mous
1934            (let ((start (car (cdr word)))            (let ((start (car (cdr word)))
1935                  (end (car (cdr (cdr word))))                  (end (car (cdr (cdr word))))
1936                  (word (car word))                  (word (car word))
1937                  poss replace)                  poss)
1938              ;; now check spelling of word.              ;; now check spelling of word.
1939              (process-send-string ispell-process "%\n") ;put in verbose mode              (process-send-string ispell-process "%\n") ;put in verbose mode
1940              (process-send-string ispell-process (concat "^" word "\n"))              (process-send-string ispell-process (concat "^" word "\n"))
# Line 1972  The word checked is the word at the mous Line 1952  The word checked is the word at the mous
1952               ((null poss)               ((null poss)
1953                ;; ispell error                ;; ispell error
1954                (error "Ispell: error in Ispell process"))                (error "Ispell: error in Ispell process"))
1955               ((string-match "GNU" (emacs-version))               ((featurep 'xemacs)
               ;; the word is incorrect, we have to propose a replacement  
               (setq replace (flyspell-emacs-popup event poss word))  
               (cond ((eq replace 'ignore)  
                      (goto-char save)  
                      nil)  
                     ((eq replace 'save)  
                      (goto-char save)  
                      (process-send-string ispell-process  
                                           (concat "*" word "\n"))  
                      (flyspell-unhighlight-at cursor-location)  
                      (setq ispell-pdict-modified-p '(t)))  
                     ((or (eq replace 'buffer) (eq replace 'session))  
                      (process-send-string ispell-process  
                                           (concat "@" word "\n"))  
                      (if (null ispell-pdict-modified-p)  
                          (setq ispell-pdict-modified-p  
                                (list ispell-pdict-modified-p)))  
                      (flyspell-unhighlight-at cursor-location)  
                      (goto-char save)  
                      (if (eq replace 'buffer)  
                          (ispell-add-per-file-word-list word)))  
                     (replace  
                      (flyspell-unhighlight-at cursor-location)  
                      (let ((new-word (if (atom replace)  
                                          replace  
                                        (car replace)))  
                            (cursor-location  
                             (+ (- (length word) (- end start))  
                                cursor-location)))  
                        (if (not (equal new-word (car poss)))  
                            (let ((old-max (point-max)))  
                              (delete-region start end)  
                              (funcall flyspell-insert-function new-word)  
                              (if flyspell-abbrev-p  
                                  (flyspell-define-abbrev word new-word))  
                              (flyspell-ajust-cursor-point save  
                                                           cursor-location  
                                                           old-max)))))  
                     (t  
                      (goto-char save)  
                      nil)))  
              ((eq flyspell-emacs 'xemacs)  
1956                (flyspell-xemacs-popup                (flyspell-xemacs-popup
1957                 event poss word cursor-location start end save)                 event poss word cursor-location start end save))
1958                (goto-char save)))               (t
1959                  ;; The word is incorrect, we have to propose a replacement.
1960                  (flyspell-do-correct (flyspell-emacs-popup event poss word)
1961                                       poss word cursor-location start end save)))
1962              (ispell-pdict-save t))))))              (ispell-pdict-save t))))))
1963    
1964  ;*---------------------------------------------------------------------*/  ;*---------------------------------------------------------------------*/
1965  ;*    flyspell-xemacs-correct ...                                      */  ;*    flyspell-do-correct ...                                      */
1966  ;*---------------------------------------------------------------------*/  ;*---------------------------------------------------------------------*/
1967  (defun flyspell-xemacs-correct (replace poss word cursor-location start end save)  (defun flyspell-do-correct (replace poss word cursor-location start end save)
1968    "The xemacs popup menu callback."    "The popup menu callback."
1969      ;; Originally, the XEmacs code didn't do the (goto-char save) here and did
1970      ;; it instead right after calling the function.
1971    (cond ((eq replace 'ignore)    (cond ((eq replace 'ignore)
1972             (goto-char save)
1973           nil)           nil)
1974          ((eq replace 'save)          ((eq replace 'save)
1975           (process-send-string ispell-process (concat "*" word "\n"))           (goto-char save)
1976           (process-send-string ispell-process "#\n")           (ispell-send-string (concat "*" word "\n"))
1977             ;; This was added only to the XEmacs side in revision 1.18 of
1978             ;; flyspell.  I assume its absence on the Emacs side was an
1979             ;; oversight.  --Stef
1980             (ispell-send-string "#\n")
1981           (flyspell-unhighlight-at cursor-location)           (flyspell-unhighlight-at cursor-location)
1982           (setq ispell-pdict-modified-p '(t)))           (setq ispell-pdict-modified-p '(t)))
1983          ((or (eq replace 'buffer) (eq replace 'session))          ((or (eq replace 'buffer) (eq replace 'session))
1984           (process-send-string ispell-process (concat "@" word "\n"))           (ispell-send-string (concat "@" word "\n"))
1985           (flyspell-unhighlight-at cursor-location)           (flyspell-unhighlight-at cursor-location)
1986           (if (null ispell-pdict-modified-p)           (if (null ispell-pdict-modified-p)
1987               (setq ispell-pdict-modified-p               (setq ispell-pdict-modified-p
1988                     (list ispell-pdict-modified-p)))                     (list ispell-pdict-modified-p)))
1989             (goto-char save)
1990           (if (eq replace 'buffer)           (if (eq replace 'buffer)
1991               (ispell-add-per-file-word-list word)))               (ispell-add-per-file-word-list word)))
1992          (replace          (replace
1993             ;; This was added only to the Emacs side.  I assume its absence on
1994             ;; the XEmacs side was an oversight.  --Stef
1995             (flyspell-unhighlight-at cursor-location)
1996           (let ((old-max (point-max))           (let ((old-max (point-max))
1997                 (new-word (if (atom replace)                 (new-word (if (atom replace)
1998                               replace                               replace
1999                             (car replace)))                             (car replace)))
2000                 (cursor-location (+ (- (length word) (- end start))                 (cursor-location (+ (- (length word) (- end start))
2001                                     cursor-location)))                                     cursor-location)))
2002             (if (not (equal new-word (car poss)))             (unless (equal new-word (car poss))
2003                 (progn               (delete-region start end)
2004                   (delete-region start end)               (goto-char start)
2005                   (goto-char start)               (funcall flyspell-insert-function new-word)
2006                   (funcall flyspell-insert-function new-word)               (if flyspell-abbrev-p
2007                   (if flyspell-abbrev-p                   (flyspell-define-abbrev word new-word)))
2008                       (flyspell-define-abbrev word new-word))))             ;; In the original Emacs code, this was only called in the body
2009             (flyspell-ajust-cursor-point save cursor-location old-max)))))             ;; of the if.  I arbitrarily kept the XEmacs behavior instead.
2010               (flyspell-ajust-cursor-point save cursor-location old-max)))
2011            (t
2012             (goto-char save)
2013             nil)))
2014    
2015  ;*---------------------------------------------------------------------*/  ;*---------------------------------------------------------------------*/
2016  ;*    flyspell-ajust-cursor-point ...                                  */  ;*    flyspell-ajust-cursor-point ...                                  */
# Line 2123  The word checked is the word at the mous Line 2079  The word checked is the word at the mous
2079           (cor-menu   (if (consp corrects)           (cor-menu   (if (consp corrects)
2080                           (mapcar (lambda (correct)                           (mapcar (lambda (correct)
2081                                     (vector correct                                     (vector correct
2082                                             (list 'flyspell-xemacs-correct                                             (list 'flyspell-do-correct
2083                                                   correct                                                   correct
2084                                                   (list 'quote poss)                                                   (list 'quote poss)
2085                                                   word                                                   word
# Line 2138  The word checked is the word at the mous Line 2094  The word checked is the word at the mous
2094           (menu       (let ((save (if (consp affix)           (menu       (let ((save (if (consp affix)
2095                                       (vector                                       (vector
2096                                        (concat "Save affix: " (car affix))                                        (concat "Save affix: " (car affix))
2097                                        (list 'flyspell-xemacs-correct                                        (list 'flyspell-do-correct
2098                                              ''save                                              ''save
2099                                              (list 'quote poss)                                              (list 'quote poss)
2100                                              word                                              word
# Line 2149  The word checked is the word at the mous Line 2105  The word checked is the word at the mous
2105                                        t)                                        t)
2106                                     (vector                                     (vector
2107                                      "Save word"                                      "Save word"
2108                                      (list 'flyspell-xemacs-correct                                      (list 'flyspell-do-correct
2109                                            ''save                                            ''save
2110                                            (list 'quote poss)                                            (list 'quote poss)
2111                                            word                                            word
# Line 2159  The word checked is the word at the mous Line 2115  The word checked is the word at the mous
2115                                            save)                                            save)
2116                                      t)))                                      t)))
2117                             (session (vector "Accept (session)"                             (session (vector "Accept (session)"
2118                                              (list 'flyspell-xemacs-correct                                              (list 'flyspell-do-correct
2119                                                    ''session                                                    ''session
2120                                                    (list 'quote poss)                                                    (list 'quote poss)
2121                                                    word                                                    word
# Line 2169  The word checked is the word at the mous Line 2125  The word checked is the word at the mous
2125                                                    save)                                                    save)
2126                                              t))                                              t))
2127                             (buffer  (vector "Accept (buffer)"                             (buffer  (vector "Accept (buffer)"
2128                                              (list 'flyspell-xemacs-correct                                              (list 'flyspell-do-correct
2129                                                    ''buffer                                                    ''buffer
2130                                                    (list 'quote poss)                                                    (list 'quote poss)
2131                                                    word                                                    word

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65

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