aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes/flyspell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/flyspell.el')
-rw-r--r--lisp/textmodes/flyspell.el292
1 files changed, 114 insertions, 178 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 0b65993df3c..8c2d0937a5a 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -94,7 +94,7 @@ Non-nil means use highlight, nil means use minibuffer messages."
94 "*The maximum distance for finding duplicates of unrecognized words. 94 "*The maximum distance for finding duplicates of unrecognized words.
95This applies to the feature that when a word is not found in the dictionary, 95This applies to the feature that when a word is not found in the dictionary,
96if the same spelling occurs elsewhere in the buffer, 96if the same spelling occurs elsewhere in the buffer,
97Flyspell uses a different face (`flyspell-duplicate-face') to highlight it. 97Flyspell uses a different face (`flyspell-duplicate') to highlight it.
98This variable specifies how far to search to find such a duplicate. 98This variable specifies how far to search to find such a duplicate.
99-1 means no limit (search the whole buffer). 99-1 means no limit (search the whole buffer).
1000 means do not search for duplicate unrecognized spellings." 1000 means do not search for duplicate unrecognized spellings."
@@ -172,7 +172,7 @@ command was not the very same command."
172 "*List of functions to be called when incorrect words are encountered. 172 "*List of functions to be called when incorrect words are encountered.
173Each function is given three arguments: the beginning and the end 173Each function is given three arguments: the beginning and the end
174of the incorrect region. The third is either the symbol 'doublon' or the list 174of the incorrect region. The third is either the symbol 'doublon' or the list
175of possible corrections as returned by 'ispell-parse-output'. 175of possible corrections as returned by `ispell-parse-output'.
176 176
177If any of the functions return non-Nil, the word is not highlighted as 177If any of the functions return non-Nil, the word is not highlighted as
178incorrect." 178incorrect."
@@ -228,7 +228,6 @@ http://strw.leidenuniv.nl/~dominik/Tools"
228 :version "21.1" 228 :version "21.1"
229 :type 'boolean) 229 :type 'boolean)
230 230
231;;;###autoload
232(defcustom flyspell-mode-line-string " Fly" 231(defcustom flyspell-mode-line-string " Fly"
233 "*String displayed on the modeline when flyspell is active. 232 "*String displayed on the modeline when flyspell is active.
234Set this to nil if you don't want a modeline indicator." 233Set this to nil if you don't want a modeline indicator."
@@ -268,11 +267,7 @@ If `flyspell-large-region' is nil, all regions are treated as small."
268 :type 'boolean) 267 :type 'boolean)
269 268
270(defcustom flyspell-auto-correct-binding 269(defcustom flyspell-auto-correct-binding
271 (cond 270 [(control ?\;)]
272 ((eq flyspell-emacs 'xemacs)
273 [(control \;)])
274 (t
275 [?\C-\;]))
276 "The key binding for flyspell auto correction." 271 "The key binding for flyspell auto correction."
277 :group 'flyspell) 272 :group 'flyspell)
278 273
@@ -410,10 +405,6 @@ property of the major mode name.")
410;*---------------------------------------------------------------------*/ 405;*---------------------------------------------------------------------*/
411(eval-when-compile (defvar flyspell-local-mouse-map)) 406(eval-when-compile (defvar flyspell-local-mouse-map))
412 407
413;;;###autoload
414(defvar flyspell-mode nil)
415(make-variable-buffer-local 'flyspell-mode)
416
417(defvar flyspell-mouse-map 408(defvar flyspell-mouse-map
418 (let ((map (make-sparse-keymap))) 409 (let ((map (make-sparse-keymap)))
419 (if flyspell-use-meta-tab 410 (if flyspell-use-meta-tab
@@ -425,26 +416,18 @@ property of the major mode name.")
425 (define-key map [(control \.)] 'flyspell-auto-correct-word) 416 (define-key map [(control \.)] 'flyspell-auto-correct-word)
426 map)) 417 map))
427 418
428;;;###autoload 419(defvar flyspell-mode-map
429(defvar flyspell-mode-map (make-sparse-keymap)) 420 (let ((map (make-sparse-keymap)))
430 421 ;; mouse, keyboard bindings and misc definition
431;; mouse, keyboard bindings and misc definition 422 (if flyspell-use-meta-tab
432(when (or (assoc 'flyspell-mode minor-mode-map-alist) 423 (define-key map "\M-\t" 'flyspell-auto-correct-word))
433 (setq minor-mode-map-alist 424 (cond
434 (cons (cons 'flyspell-mode flyspell-mode-map) 425 ;; I don't understand this test, so I left it as is. --Stef
435 minor-mode-map-alist))) 426 ((or (featurep 'xemacs) flyspell-use-local-map)
436 (if flyspell-use-meta-tab 427 (define-key map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word)
437 (define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word)) 428 (define-key map [(control ?\,)] 'flyspell-goto-next-error)
438 (cond 429 (define-key map [(control ?\.)] 'flyspell-auto-correct-word)))
439 ((eq flyspell-emacs 'xemacs) 430 map))
440 (define-key flyspell-mode-map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word)
441 (define-key flyspell-mode-map [(control \,)] 'flyspell-goto-next-error)
442 (define-key flyspell-mode-map [(control \.)] 'flyspell-auto-correct-word))
443 (flyspell-use-local-map
444 (define-key flyspell-mode-map flyspell-auto-correct-binding 'flyspell-auto-correct-previous-word)
445 (define-key flyspell-mode-map [?\C-\,] 'flyspell-goto-next-error)
446 (define-key flyspell-mode-map [?\C-\.] 'flyspell-auto-correct-word))))
447
448 431
449;; the name of the overlay property that defines the keymap 432;; the name of the overlay property that defines the keymap
450(defvar flyspell-overlay-keymap-property-name 'keymap) 433(defvar flyspell-overlay-keymap-property-name 'keymap)
@@ -461,24 +444,22 @@ property of the major mode name.")
461;*---------------------------------------------------------------------*/ 444;*---------------------------------------------------------------------*/
462;* Highlighting */ 445;* Highlighting */
463;*---------------------------------------------------------------------*/ 446;*---------------------------------------------------------------------*/
464(defface flyspell-incorrect-face 447(defface flyspell-incorrect
465 (if (eq flyspell-emacs 'xemacs) 448 '((((class color)) (:foreground "OrangeRed" :bold t :underline t))
466 '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) 449 (t (:bold t)))
467 (t (:bold t)))
468 '((((class color)) (:foreground "OrangeRed" :weight bold :underline t))
469 (t (:weight bold))))
470 "Face used for marking a misspelled word in Flyspell." 450 "Face used for marking a misspelled word in Flyspell."
471 :group 'flyspell) 451 :group 'flyspell)
452;; backward-compatibility alias
453(put 'flyspell-incorrect-face 'face-alias 'flyspell-incorrect)
472 454
473(defface flyspell-duplicate-face 455(defface flyspell-duplicate
474 (if (eq flyspell-emacs 'xemacs) 456 '((((class color)) (:foreground "Gold3" :bold t :underline t))
475 '((((class color)) (:foreground "Gold3" :bold t :underline t)) 457 (t (:bold t)))
476 (t (:bold t)))
477 '((((class color)) (:foreground "Gold3" :weight bold :underline t))
478 (t (:weight bold))))
479 "Face used for marking a misspelled word that appears twice in the buffer. 458 "Face used for marking a misspelled word that appears twice in the buffer.
480See also `flyspell-duplicate-distance'." 459See also `flyspell-duplicate-distance'."
481 :group 'flyspell) 460 :group 'flyspell)
461;; backward-compatibility alias
462(put 'flyspell-duplicate-face 'face-alias 'flyspell-duplicate)
482 463
483(defvar flyspell-overlay nil) 464(defvar flyspell-overlay nil)
484 465
@@ -486,7 +467,7 @@ See also `flyspell-duplicate-distance'."
486;* flyspell-mode ... */ 467;* flyspell-mode ... */
487;*---------------------------------------------------------------------*/ 468;*---------------------------------------------------------------------*/
488;;;###autoload 469;;;###autoload
489(defun flyspell-mode (&optional arg) 470(define-minor-mode flyspell-mode
490 "Minor mode performing on-the-fly spelling checking. 471 "Minor mode performing on-the-fly spelling checking.
491This spawns a single Ispell process and checks each word. 472This spawns a single Ispell process and checks each word.
492The default flyspell behavior is to highlight incorrect words. 473The default flyspell behavior is to highlight incorrect words.
@@ -514,28 +495,12 @@ in your .emacs file.
514 495
515\\[flyspell-region] checks all words inside a region. 496\\[flyspell-region] checks all words inside a region.
516\\[flyspell-buffer] checks the whole buffer." 497\\[flyspell-buffer] checks the whole buffer."
517 (interactive "P") 498 :lighter flyspell-mode-line-string
518 (let ((old-flyspell-mode flyspell-mode)) 499 :keymap flyspell-mode-map
519 ;; Mark the mode as on or off. 500 :group 'flyspell
520 (setq flyspell-mode (not (or (and (null arg) flyspell-mode) 501 (if flyspell-mode
521 (<= (prefix-numeric-value arg) 0)))) 502 (flyspell-mode-on)
522 ;; Do the real work. 503 (flyspell-mode-off)))
523 (unless (eq flyspell-mode old-flyspell-mode)
524 (if flyspell-mode
525 (flyspell-mode-on)
526 (flyspell-mode-off))
527 ;; Force modeline redisplay.
528 (set-buffer-modified-p (buffer-modified-p)))))
529
530;*---------------------------------------------------------------------*/
531;* Autoloading */
532;*---------------------------------------------------------------------*/
533;;;###autoload
534(add-minor-mode 'flyspell-mode
535 'flyspell-mode-line-string
536 flyspell-mode-map
537 nil
538 'flyspell-mode)
539 504
540;*---------------------------------------------------------------------*/ 505;*---------------------------------------------------------------------*/
541;* flyspell-buffers ... */ 506;* flyspell-buffers ... */
@@ -579,7 +544,7 @@ in your .emacs file.
579;*---------------------------------------------------------------------*/ 544;*---------------------------------------------------------------------*/
580(defun flyspell-mode-on () 545(defun flyspell-mode-on ()
581 "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead." 546 "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead."
582 (setq ispell-highlight-face 'flyspell-incorrect-face) 547 (setq ispell-highlight-face 'flyspell-incorrect)
583 ;; local dictionaries setup 548 ;; local dictionaries setup
584 (or ispell-local-dictionary ispell-dictionary 549 (or ispell-local-dictionary ispell-dictionary
585 (if flyspell-default-dictionary 550 (if flyspell-default-dictionary
@@ -830,9 +795,7 @@ Mostly we check word delimiters."
830 ((get this-command 'flyspell-delayed) 795 ((get this-command 'flyspell-delayed)
831 ;; the current command is not delayed, that 796 ;; the current command is not delayed, that
832 ;; is that we must check the word now 797 ;; is that we must check the word now
833 (if (fboundp 'about-xemacs) 798 (sit-for flyspell-delay))
834 (sit-for flyspell-delay nil)
835 (sit-for flyspell-delay 0 nil)))
836 (t t))) 799 (t t)))
837 (t t))) 800 (t t)))
838 801
@@ -1019,7 +982,7 @@ Mostly we check word delimiters."
1019 (setq r p) 982 (setq r p)
1020 (goto-char p)))) 983 (goto-char p))))
1021 r))) 984 r)))
1022 985
1023;*---------------------------------------------------------------------*/ 986;*---------------------------------------------------------------------*/
1024;* flyspell-word-search-forward ... */ 987;* flyspell-word-search-forward ... */
1025;*---------------------------------------------------------------------*/ 988;*---------------------------------------------------------------------*/
@@ -1033,7 +996,7 @@ Mostly we check word delimiters."
1033 (setq r p) 996 (setq r p)
1034 (goto-char (1+ p))))) 997 (goto-char (1+ p)))))
1035 r))) 998 r)))
1036 999
1037;*---------------------------------------------------------------------*/ 1000;*---------------------------------------------------------------------*/
1038;* flyspell-word ... */ 1001;* flyspell-word ... */
1039;*---------------------------------------------------------------------*/ 1002;*---------------------------------------------------------------------*/
@@ -1059,12 +1022,11 @@ Mostly we check word delimiters."
1059 (cond 1022 (cond
1060 ((and (or (not (eq ispell-parser 'tex)) 1023 ((and (or (not (eq ispell-parser 'tex))
1061 (and (> start (point-min)) 1024 (and (> start (point-min))
1062 (not (eq (char-after (1- start)) ?})) 1025 (not (memq (char-after (1- start)) '(?\} ?\\)))))
1063 (not (eq (char-after (1- start)) ?\\))))
1064 flyspell-mark-duplications-flag 1026 flyspell-mark-duplications-flag
1065 (save-excursion 1027 (save-excursion
1066 (goto-char (1- start)) 1028 (goto-char (1- start))
1067 (let ((p (flyspell-word-search-backward 1029 (let ((p (flyspell-word-search-backward
1068 word 1030 word
1069 (- start (1+ (- end start)))))) 1031 (- start (1+ (- end start))))))
1070 (and p (/= p (1- start)))))) 1032 (and p (/= p (1- start))))))
@@ -1164,7 +1126,7 @@ Mostly we check word delimiters."
1164 (flyspell-notify-misspell start end word poss)) 1126 (flyspell-notify-misspell start end word poss))
1165 nil)))) 1127 nil))))
1166 ;; return to original location 1128 ;; return to original location
1167 (goto-char cursor-location) 1129 (goto-char cursor-location)
1168 (if ispell-quit (setq ispell-quit nil)) 1130 (if ispell-quit (setq ispell-quit nil))
1169 res)))))))) 1131 res))))))))
1170 1132
@@ -1183,20 +1145,21 @@ Mostly we check word delimiters."
1183;* time that function is called. */ 1145;* time that function is called. */
1184;*---------------------------------------------------------------------*/ 1146;*---------------------------------------------------------------------*/
1185(defun flyspell-math-tex-command-p () 1147(defun flyspell-math-tex-command-p ()
1186 (cond 1148 (when (fboundp 'texmathp)
1187 (flyspell-check-tex-math-command 1149 (cond
1188 nil) 1150 (flyspell-check-tex-math-command
1189 ((eq flyspell-tex-math-initialized t) 1151 nil)
1190 (texmathp)) 1152 ((eq flyspell-tex-math-initialized t)
1191 ((eq flyspell-tex-math-initialized 'error) 1153 (texmathp))
1192 nil) 1154 ((eq flyspell-tex-math-initialized 'error)
1193 (t 1155 nil)
1194 (setq flyspell-tex-math-initialized t) 1156 (t
1195 (condition-case nil 1157 (setq flyspell-tex-math-initialized t)
1196 (texmathp) 1158 (condition-case nil
1197 (error (progn 1159 (texmathp)
1198 (setq flyspell-tex-math-initialized 'error) 1160 (error (progn
1199 nil)))))) 1161 (setq flyspell-tex-math-initialized 'error)
1162 nil)))))))
1200 1163
1201;*---------------------------------------------------------------------*/ 1164;*---------------------------------------------------------------------*/
1202;* flyspell-tex-command-p ... */ 1165;* flyspell-tex-command-p ... */
@@ -1383,9 +1346,7 @@ Word syntax described by `flyspell-dictionary-alist' (which see)."
1383 (let ((buffer flyspell-external-ispell-buffer)) 1346 (let ((buffer flyspell-external-ispell-buffer))
1384 (set-buffer buffer) 1347 (set-buffer buffer)
1385 (goto-char (point-min)) 1348 (goto-char (point-min))
1386 (let ((size (- flyspell-large-region-end flyspell-large-region-beg)) 1349 (let ((pword "")
1387 (start flyspell-large-region-beg)
1388 (pword "")
1389 (pcount 1)) 1350 (pcount 1))
1390 ;; now we are done with ispell, we have to find the word in 1351 ;; now we are done with ispell, we have to find the word in
1391 ;; the initial buffer 1352 ;; the initial buffer
@@ -1613,7 +1574,7 @@ for the overlay."
1613 (overlay-put flyspell-overlay 1574 (overlay-put flyspell-overlay
1614 flyspell-overlay-keymap-property-name 1575 flyspell-overlay-keymap-property-name
1615 flyspell-mouse-map)) 1576 flyspell-mouse-map))
1616 (when (eq face 'flyspell-incorrect-face) 1577 (when (eq face 'flyspell-incorrect)
1617 (and (stringp flyspell-before-incorrect-word-string) 1578 (and (stringp flyspell-before-incorrect-word-string)
1618 (overlay-put flyspell-overlay 'before-string 1579 (overlay-put flyspell-overlay 'before-string
1619 flyspell-before-incorrect-word-string)) 1580 flyspell-before-incorrect-word-string))
@@ -1653,7 +1614,7 @@ for the overlay."
1653 ;; now we can use a new overlay 1614 ;; now we can use a new overlay
1654 (setq flyspell-overlay 1615 (setq flyspell-overlay
1655 (make-flyspell-overlay 1616 (make-flyspell-overlay
1656 beg end 'flyspell-incorrect-face 'highlight))))))) 1617 beg end 'flyspell-incorrect 'highlight)))))))
1657 1618
1658;*---------------------------------------------------------------------*/ 1619;*---------------------------------------------------------------------*/
1659;* flyspell-highlight-duplicate-region ... */ 1620;* flyspell-highlight-duplicate-region ... */
@@ -1679,7 +1640,7 @@ for the overlay."
1679 ;; now we can use a new overlay 1640 ;; now we can use a new overlay
1680 (setq flyspell-overlay 1641 (setq flyspell-overlay
1681 (make-flyspell-overlay beg end 1642 (make-flyspell-overlay beg end
1682 'flyspell-duplicate-face 1643 'flyspell-duplicate
1683 'highlight))))))) 1644 'highlight)))))))
1684 1645
1685;*---------------------------------------------------------------------*/ 1646;*---------------------------------------------------------------------*/
@@ -1741,8 +1702,7 @@ misspelled words backwards."
1741 (let ((num (car pos))) 1702 (let ((num (car pos)))
1742 (put-text-property num 1703 (put-text-property num
1743 (+ num (length flyspell-auto-correct-word)) 1704 (+ num (length flyspell-auto-correct-word))
1744 'face 1705 'face 'flyspell-incorrect
1745 'flyspell-incorrect-face
1746 string)) 1706 string))
1747 (setq pos (cdr pos))) 1707 (setq pos (cdr pos)))
1748 (if (fboundp 'display-message) 1708 (if (fboundp 'display-message)
@@ -1879,7 +1839,7 @@ This command proposes various successive corrections for the current word."
1879(defun flyspell-auto-correct-previous-hook () 1839(defun flyspell-auto-correct-previous-hook ()
1880 "Hook to track successive calls to `flyspell-auto-correct-previous-word'. 1840 "Hook to track successive calls to `flyspell-auto-correct-previous-word'.
1881Sets `flyspell-auto-correct-previous-pos' to nil" 1841Sets `flyspell-auto-correct-previous-pos' to nil"
1882 (interactive) 1842 (interactive)
1883 (remove-hook 'pre-command-hook (function flyspell-auto-correct-previous-hook) t) 1843 (remove-hook 'pre-command-hook (function flyspell-auto-correct-previous-hook) t)
1884 (unless (eq this-command (function flyspell-auto-correct-previous-word)) 1844 (unless (eq this-command (function flyspell-auto-correct-previous-word))
1885 (setq flyspell-auto-correct-previous-pos nil))) 1845 (setq flyspell-auto-correct-previous-pos nil)))
@@ -1887,7 +1847,7 @@ Sets `flyspell-auto-correct-previous-pos' to nil"
1887;*---------------------------------------------------------------------*/ 1847;*---------------------------------------------------------------------*/
1888;* flyspell-auto-correct-previous-word ... */ 1848;* flyspell-auto-correct-previous-word ... */
1889;*---------------------------------------------------------------------*/ 1849;*---------------------------------------------------------------------*/
1890(defun flyspell-auto-correct-previous-word (position) 1850(defun flyspell-auto-correct-previous-word (position)
1891 "*Auto correct the first mispelled word that occurs before point. 1851 "*Auto correct the first mispelled word that occurs before point.
1892But don't look beyond what's visible on the screen." 1852But don't look beyond what's visible on the screen."
1893 (interactive "d") 1853 (interactive "d")
@@ -1903,29 +1863,29 @@ But don't look beyond what's visible on the screen."
1903 (narrow-to-region top bot) 1863 (narrow-to-region top bot)
1904 (overlay-recenter (point)) 1864 (overlay-recenter (point))
1905 1865
1906 (add-hook 'pre-command-hook 1866 (add-hook 'pre-command-hook
1907 (function flyspell-auto-correct-previous-hook) t t) 1867 (function flyspell-auto-correct-previous-hook) t t)
1908 1868
1909 (unless flyspell-auto-correct-previous-pos 1869 (unless flyspell-auto-correct-previous-pos
1910 ;; only reset if a new overlay exists 1870 ;; only reset if a new overlay exists
1911 (setq flyspell-auto-correct-previous-pos nil) 1871 (setq flyspell-auto-correct-previous-pos nil)
1912 1872
1913 (let ((overlay-list (overlays-in (point-min) position)) 1873 (let ((overlay-list (overlays-in (point-min) position))
1914 (new-overlay 'dummy-value)) 1874 (new-overlay 'dummy-value))
1915 1875
1916 ;; search for previous (new) flyspell overlay 1876 ;; search for previous (new) flyspell overlay
1917 (while (and new-overlay 1877 (while (and new-overlay
1918 (or (not (flyspell-overlay-p new-overlay)) 1878 (or (not (flyspell-overlay-p new-overlay))
1919 ;; check if its face has changed 1879 ;; check if its face has changed
1920 (not (eq (get-char-property 1880 (not (eq (get-char-property
1921 (overlay-start new-overlay) 'face) 1881 (overlay-start new-overlay) 'face)
1922 'flyspell-incorrect-face)))) 1882 'flyspell-incorrect))))
1923 (setq new-overlay (car-safe overlay-list)) 1883 (setq new-overlay (car-safe overlay-list))
1924 (setq overlay-list (cdr-safe overlay-list))) 1884 (setq overlay-list (cdr-safe overlay-list)))
1925 1885
1926 ;; if nothing new exits new-overlay should be nil 1886 ;; if nothing new exits new-overlay should be nil
1927 (if new-overlay ;; the length of the word may change so go to the start 1887 (if new-overlay ;; the length of the word may change so go to the start
1928 (setq flyspell-auto-correct-previous-pos 1888 (setq flyspell-auto-correct-previous-pos
1929 (overlay-start new-overlay))))) 1889 (overlay-start new-overlay)))))
1930 1890
1931 (when flyspell-auto-correct-previous-pos 1891 (when flyspell-auto-correct-previous-pos
@@ -1956,7 +1916,7 @@ The word checked is the word at the mouse position."
1956 (let ((start (car (cdr word))) 1916 (let ((start (car (cdr word)))
1957 (end (car (cdr (cdr word)))) 1917 (end (car (cdr (cdr word))))
1958 (word (car word)) 1918 (word (car word))
1959 poss replace) 1919 poss)
1960 ;; now check spelling of word. 1920 ;; now check spelling of word.
1961 (process-send-string ispell-process "%\n") ;put in verbose mode 1921 (process-send-string ispell-process "%\n") ;put in verbose mode
1962 (process-send-string ispell-process (concat "^" word "\n")) 1922 (process-send-string ispell-process (concat "^" word "\n"))
@@ -1974,89 +1934,65 @@ The word checked is the word at the mouse position."
1974 ((null poss) 1934 ((null poss)
1975 ;; ispell error 1935 ;; ispell error
1976 (error "Ispell: error in Ispell process")) 1936 (error "Ispell: error in Ispell process"))
1977 ((string-match "GNU" (emacs-version)) 1937 ((featurep 'xemacs)
1978 ;; the word is incorrect, we have to propose a replacement
1979 (setq replace (flyspell-emacs-popup event poss word))
1980 (cond ((eq replace 'ignore)
1981 (goto-char save)
1982 nil)
1983 ((eq replace 'save)
1984 (goto-char save)
1985 (process-send-string ispell-process
1986 (concat "*" word "\n"))
1987 (flyspell-unhighlight-at cursor-location)
1988 (setq ispell-pdict-modified-p '(t)))
1989 ((or (eq replace 'buffer) (eq replace 'session))
1990 (process-send-string ispell-process
1991 (concat "@" word "\n"))
1992 (if (null ispell-pdict-modified-p)
1993 (setq ispell-pdict-modified-p
1994 (list ispell-pdict-modified-p)))
1995 (flyspell-unhighlight-at cursor-location)
1996 (goto-char save)
1997 (if (eq replace 'buffer)
1998 (ispell-add-per-file-word-list word)))
1999 (replace
2000 (flyspell-unhighlight-at cursor-location)
2001 (let ((new-word (if (atom replace)
2002 replace
2003 (car replace)))
2004 (cursor-location
2005 (+ (- (length word) (- end start))
2006 cursor-location)))
2007 (if (not (equal new-word (car poss)))
2008 (let ((old-max (point-max)))
2009 (delete-region start end)
2010 (funcall flyspell-insert-function new-word)
2011 (if flyspell-abbrev-p
2012 (flyspell-define-abbrev word new-word))
2013 (flyspell-ajust-cursor-point save
2014 cursor-location
2015 old-max)))))
2016 (t
2017 (goto-char save)
2018 nil)))
2019 ((eq flyspell-emacs 'xemacs)
2020 (flyspell-xemacs-popup 1938 (flyspell-xemacs-popup
2021 event poss word cursor-location start end save) 1939 event poss word cursor-location start end save))
2022 (goto-char save))) 1940 (t
1941 ;; The word is incorrect, we have to propose a replacement.
1942 (flyspell-do-correct (flyspell-emacs-popup event poss word)
1943 poss word cursor-location start end save)))
2023 (ispell-pdict-save t)))))) 1944 (ispell-pdict-save t))))))
2024 1945
2025;*---------------------------------------------------------------------*/ 1946;*---------------------------------------------------------------------*/
2026;* flyspell-xemacs-correct ... */ 1947;* flyspell-do-correct ... */
2027;*---------------------------------------------------------------------*/ 1948;*---------------------------------------------------------------------*/
2028(defun flyspell-xemacs-correct (replace poss word cursor-location start end save) 1949(defun flyspell-do-correct (replace poss word cursor-location start end save)
2029 "The xemacs popup menu callback." 1950 "The popup menu callback."
1951 ;; Originally, the XEmacs code didn't do the (goto-char save) here and did
1952 ;; it instead right after calling the function.
2030 (cond ((eq replace 'ignore) 1953 (cond ((eq replace 'ignore)
1954 (goto-char save)
2031 nil) 1955 nil)
2032 ((eq replace 'save) 1956 ((eq replace 'save)
2033 (process-send-string ispell-process (concat "*" word "\n")) 1957 (goto-char save)
2034 (process-send-string ispell-process "#\n") 1958 (ispell-send-string (concat "*" word "\n"))
1959 ;; This was added only to the XEmacs side in revision 1.18 of
1960 ;; flyspell. I assume its absence on the Emacs side was an
1961 ;; oversight. --Stef
1962 (ispell-send-string "#\n")
2035 (flyspell-unhighlight-at cursor-location) 1963 (flyspell-unhighlight-at cursor-location)
2036 (setq ispell-pdict-modified-p '(t))) 1964 (setq ispell-pdict-modified-p '(t)))
2037 ((or (eq replace 'buffer) (eq replace 'session)) 1965 ((or (eq replace 'buffer) (eq replace 'session))
2038 (process-send-string ispell-process (concat "@" word "\n")) 1966 (ispell-send-string (concat "@" word "\n"))
2039 (flyspell-unhighlight-at cursor-location) 1967 (flyspell-unhighlight-at cursor-location)
2040 (if (null ispell-pdict-modified-p) 1968 (if (null ispell-pdict-modified-p)
2041 (setq ispell-pdict-modified-p 1969 (setq ispell-pdict-modified-p
2042 (list ispell-pdict-modified-p))) 1970 (list ispell-pdict-modified-p)))
1971 (goto-char save)
2043 (if (eq replace 'buffer) 1972 (if (eq replace 'buffer)
2044 (ispell-add-per-file-word-list word))) 1973 (ispell-add-per-file-word-list word)))
2045 (replace 1974 (replace
1975 ;; This was added only to the Emacs side. I assume its absence on
1976 ;; the XEmacs side was an oversight. --Stef
1977 (flyspell-unhighlight-at cursor-location)
2046 (let ((old-max (point-max)) 1978 (let ((old-max (point-max))
2047 (new-word (if (atom replace) 1979 (new-word (if (atom replace)
2048 replace 1980 replace
2049 (car replace))) 1981 (car replace)))
2050 (cursor-location (+ (- (length word) (- end start)) 1982 (cursor-location (+ (- (length word) (- end start))
2051 cursor-location))) 1983 cursor-location)))
2052 (if (not (equal new-word (car poss))) 1984 (unless (equal new-word (car poss))
2053 (progn 1985 (delete-region start end)
2054 (delete-region start end) 1986 (goto-char start)
2055 (goto-char start) 1987 (funcall flyspell-insert-function new-word)
2056 (funcall flyspell-insert-function new-word) 1988 (if flyspell-abbrev-p
2057 (if flyspell-abbrev-p 1989 (flyspell-define-abbrev word new-word)))
2058 (flyspell-define-abbrev word new-word)))) 1990 ;; In the original Emacs code, this was only called in the body
2059 (flyspell-ajust-cursor-point save cursor-location old-max))))) 1991 ;; of the if. I arbitrarily kept the XEmacs behavior instead.
1992 (flyspell-ajust-cursor-point save cursor-location old-max)))
1993 (t
1994 (goto-char save)
1995 nil)))
2060 1996
2061;*---------------------------------------------------------------------*/ 1997;*---------------------------------------------------------------------*/
2062;* flyspell-ajust-cursor-point ... */ 1998;* flyspell-ajust-cursor-point ... */
@@ -2125,7 +2061,7 @@ The word checked is the word at the mouse position."
2125 (cor-menu (if (consp corrects) 2061 (cor-menu (if (consp corrects)
2126 (mapcar (lambda (correct) 2062 (mapcar (lambda (correct)
2127 (vector correct 2063 (vector correct
2128 (list 'flyspell-xemacs-correct 2064 (list 'flyspell-do-correct
2129 correct 2065 correct
2130 (list 'quote poss) 2066 (list 'quote poss)
2131 word 2067 word
@@ -2140,7 +2076,7 @@ The word checked is the word at the mouse position."
2140 (menu (let ((save (if (consp affix) 2076 (menu (let ((save (if (consp affix)
2141 (vector 2077 (vector
2142 (concat "Save affix: " (car affix)) 2078 (concat "Save affix: " (car affix))
2143 (list 'flyspell-xemacs-correct 2079 (list 'flyspell-do-correct
2144 ''save 2080 ''save
2145 (list 'quote poss) 2081 (list 'quote poss)
2146 word 2082 word
@@ -2151,7 +2087,7 @@ The word checked is the word at the mouse position."
2151 t) 2087 t)
2152 (vector 2088 (vector
2153 "Save word" 2089 "Save word"
2154 (list 'flyspell-xemacs-correct 2090 (list 'flyspell-do-correct
2155 ''save 2091 ''save
2156 (list 'quote poss) 2092 (list 'quote poss)
2157 word 2093 word
@@ -2161,7 +2097,7 @@ The word checked is the word at the mouse position."
2161 save) 2097 save)
2162 t))) 2098 t)))
2163 (session (vector "Accept (session)" 2099 (session (vector "Accept (session)"
2164 (list 'flyspell-xemacs-correct 2100 (list 'flyspell-do-correct
2165 ''session 2101 ''session
2166 (list 'quote poss) 2102 (list 'quote poss)
2167 word 2103 word
@@ -2171,7 +2107,7 @@ The word checked is the word at the mouse position."
2171 save) 2107 save)
2172 t)) 2108 t))
2173 (buffer (vector "Accept (buffer)" 2109 (buffer (vector "Accept (buffer)"
2174 (list 'flyspell-xemacs-correct 2110 (list 'flyspell-do-correct
2175 ''buffer 2111 ''buffer
2176 (list 'quote poss) 2112 (list 'quote poss)
2177 word 2113 word
@@ -2198,9 +2134,9 @@ Ispell, after transposing two adjacent characters, correct the text,
2198and return t. 2134and return t.
2199 2135
2200The third arg POSS is either the symbol 'doublon' or a list of 2136The third arg POSS is either the symbol 'doublon' or a list of
2201possible corrections as returned by 'ispell-parse-output'. 2137possible corrections as returned by `ispell-parse-output'.
2202 2138
2203This function is meant to be added to 'flyspell-incorrect-hook'." 2139This function is meant to be added to `flyspell-incorrect-hook'."
2204 (when (consp poss) 2140 (when (consp poss)
2205 (catch 'done 2141 (catch 'done
2206 (let ((str (buffer-substring beg end)) 2142 (let ((str (buffer-substring beg end))
@@ -2228,9 +2164,9 @@ Ispell, after removing a pair of doubled characters, correct the text,
2228and return t. 2164and return t.
2229 2165
2230The third arg POSS is either the symbol 'doublon' or a list of 2166The third arg POSS is either the symbol 'doublon' or a list of
2231possible corrections as returned by 'ispell-parse-output'. 2167possible corrections as returned by `ispell-parse-output'.
2232 2168
2233This function is meant to be added to 'flyspell-incorrect-hook'." 2169This function is meant to be added to `flyspell-incorrect-hook'."
2234 (when (consp poss) 2170 (when (consp poss)
2235 (catch 'done 2171 (catch 'done
2236 (let ((str (buffer-substring beg end)) 2172 (let ((str (buffer-substring beg end))