X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/14007de1ff72f3cb13b0dcbd6dbf8e80e1c4de51..08fea928870ca809d9d4cae2b6b9f829cb6280b4:/lisp/textmodes/flyspell.el diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 7c1e1566a9..9d5c7868d1 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -11,7 +11,7 @@ ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -67,11 +67,21 @@ Non-nil means use highlight, nil means use minibuffer messages." (defcustom flyspell-mark-duplications-flag t "Non-nil means Flyspell reports a repeated word as an error. +See `flyspell-mark-duplications-exceptions' to add exceptions to this rule. Detection of repeated words is not implemented in \"large\" regions; see `flyspell-large-region'." :group 'flyspell :type 'boolean) +(defcustom flyspell-mark-duplications-exceptions + '(("francais" . ("nous" "vous"))) + "A list of exceptions for duplicated words. +It should be a list of (LANGUAGE . EXCEPTION-LIST). LANGUAGE is matched +against the current dictionary and EXCEPTION-LIST is a list of strings. +The duplicated word is downcased before it is compared with the exceptions." + :group 'flyspell + :type '(alist :key-type string :value-type (repeat string))) + (defcustom flyspell-sort-corrections nil "Non-nil means, sort the corrections alphabetically before popping them." :group 'flyspell @@ -431,7 +441,7 @@ property of the major mode name.") (defface flyspell-incorrect '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) (t (:bold t))) - "Face used to display a misspelled word in Flyspell." + "Face used for marking a misspelled word in Flyspell." :group 'flyspell) ;; backward-compatibility alias (put 'flyspell-incorrect-face 'face-alias 'flyspell-incorrect) @@ -439,7 +449,7 @@ property of the major mode name.") (defface flyspell-duplicate '((((class color)) (:foreground "Gold3" :bold t :underline t)) (t (:bold t))) - "Face used to display subsequent occurrences of a misspelled word. + "Face used for marking a misspelled word that appears twice in the buffer. See also `flyspell-duplicate-distance'." :group 'flyspell) ;; backward-compatibility alias @@ -457,7 +467,8 @@ See also `flyspell-duplicate-distance'." This spawns a single Ispell process and checks each word. The default flyspell behavior is to highlight incorrect words. With no argument, this command toggles Flyspell mode. -With a prefix argument ARG, turn Flyspell minor mode on iff ARG is positive. +With a prefix argument ARG, turn Flyspell minor mode on if ARG is positive, +otherwise turn it off. Bindings: \\[ispell-word]: correct words (using Ispell). @@ -1021,6 +1032,13 @@ Mostly we check word delimiters." (and (> start (point-min)) (not (memq (char-after (1- start)) '(?\} ?\\))))) flyspell-mark-duplications-flag + (not (catch 'exception + (dolist (except flyspell-mark-duplications-exceptions) + (and (string= (or ispell-local-dictionary + ispell-dictionary) + (car except)) + (member (downcase word) (cdr except)) + (throw 'exception t))))) (save-excursion (goto-char start) (let* ((bound @@ -1621,7 +1639,7 @@ FLYSPELL-BUFFER." ;;* flyspell-overlay-p ... */ ;;*---------------------------------------------------------------------*/ (defun flyspell-overlay-p (o) - "A predicate that return true iff O is an overlay used by flyspell." + "Return true if O is an overlay used by flyspell." (and (overlayp o) (overlay-get o 'flyspell-overlay))) ;;*---------------------------------------------------------------------*/ @@ -1827,7 +1845,7 @@ misspelled words backwards." (defun flyspell-define-abbrev (name expansion) (let ((table (flyspell-abbrev-table))) (when table - (define-abbrev table name expansion)))) + (define-abbrev table (downcase name) expansion)))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-auto-correct-word ... */ @@ -1961,12 +1979,8 @@ Sets `flyspell-auto-correct-previous-pos' to nil" But don't look beyond what's visible on the screen." (interactive "d") - (let (top bot) - (save-excursion - (move-to-window-line 0) - (setq top (point)) - (move-to-window-line -1) - (setq bot (point))) + (let ((top (window-start)) + (bot (window-end))) (save-excursion (save-restriction (narrow-to-region top bot) @@ -2029,6 +2043,7 @@ If OPOINT is non-nil, restore point there after adjusting it for replacement." (error "Pop-up menus do not work on this terminal")) ;; use the correct dictionary (flyspell-accept-buffer-local-defs) + (or opoint (setq opoint (point-marker))) (let ((cursor-location (point)) (word (flyspell-get-word nil))) (if (consp word) @@ -2137,6 +2152,8 @@ If OPOINT is non-nil, restore point there after adjusting it for replacement." ;;*---------------------------------------------------------------------*/ (defun flyspell-emacs-popup (event poss word) "The Emacs popup menu." + (unless window-system + (error "This command requires pop-up dialogs")) (if (not event) (let* ((mouse-pos (mouse-position)) (mouse-pos (if (nth 1 mouse-pos)