Mercurial > emacs
changeset 22891:780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
(flyspell-mode-on): Fix the welcome message to deal with
how the binding for flyspell-auto-correct-word is now made.
(flyspell-delay, flyspell-delayed-commands): Doc fixes.
(flyspell-mode-off): Kill Ispell only if it is per-buffer.
(flyspell-mode-map): Explicitly bind M-TAB.
(flyspell-auto-correct-binding): Variable deleted.
(flyspell-incorrect-face, flyspell-duplicate-face): Fix typos.
(flyspell-check-pre-word-p): Check for word syntax in previous char.
(flyspell-word): Set process-kill-without-query for Ispell.
(flyspell-region): Put region args in order; use right percantage.
(flyspell-properties-at-p): Rename arg to POS; doc fix.
(flyspell-highlight-incorrect-region):
Check flyspell-highlight-properties first.
(flyspell-highlight-duplicate-region): Likewise.
(flyspell-auto-correct-word): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 03 Aug 1998 03:27:54 +0000 |
parents | 5044c732dbde |
children | 850946452989 |
files | lisp/textmodes/flyspell.el |
diffstat | 1 files changed, 59 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/flyspell.el Sun Aug 02 02:44:04 1998 +0000 +++ b/lisp/textmodes/flyspell.el Mon Aug 03 03:27:54 1998 +0000 @@ -27,7 +27,8 @@ ;; Flyspell is a minor Emacs mode performing on-the-fly spelling ;; checking. ;; -;; To enter the flyspell minor mode, Meta-x flyspell-mode. +;; To enable Flyspell minor mode, type Meta-x flyspell-mode. +;; This applies only to the current buffer. ;; ;; Note: consider setting the variable ispell-parser to `tex' to ;; avoid TeX command checking; use `(setq ispell-parser 'tex)' @@ -44,6 +45,9 @@ (require 'font-lock) (require 'ispell) +;*---------------------------------------------------------------------*/ +;* Group ... */ +;*---------------------------------------------------------------------*/ (defgroup flyspell nil "Spellchecking on the fly." :tag "FlySpell" @@ -70,26 +74,20 @@ :group 'flyspell :type 'boolean) -(defcustom flyspell-auto-correct-binding "\M-\t" - "*Non-nil means that its value (a binding) will bound to the flyspell -auto-correct." - :group 'flyspell - :type '(choice (const nil) string)) - (defcustom flyspell-command-hook t "*Non-nil means that `post-command-hook' is used to check already-typed words." :group 'flyspell :type 'boolean) -(defcustom flyspell-duplicate-distance -1 - "*The distance from duplication. --1 means no limit. -0 means no window." +(defcustom flyspell-duplicate-distance 10000 + "*The maximum distance between duplicate mispelled words, for flagging them. +-1 means no limit (search the whole buffer). +0 means do not search for duplicate misspelled words." :group 'flyspell :type 'number) (defcustom flyspell-delay 3 - "*The number of seconds to wait before checking words, for a \"delayed\" command." + "*The number of seconds to wait before checking, after a \"delayed\" command." :group 'flyspell :type 'number) @@ -114,12 +112,13 @@ (defcustom flyspell-delayed-commands nil "List of commands that are \"delayed\" for Flyspell mode. -These commands do not activate flyspell checking." +After these commands, Flyspell checking is delayed for a short time, +whose length is specified by `flyspell-delay'." :group 'flyspell :type '(repeat (symbol))) (defcustom flyspell-issue-welcome-flag t - "*Non-nil means that Flyspell issues a welcome message when started." + "*Non-nil means that Flyspell should display a welcome message when started." :group 'flyspell :type 'boolean) @@ -202,7 +201,7 @@ 'xemacs) (t 'emacs)) - "The Emacs we are currently running.") + "The type of Emacs we are currently running.") ;*---------------------------------------------------------------------*/ ;* The minor mode declaration. */ @@ -222,9 +221,8 @@ (cons (cons 'flyspell-mode flyspell-mode-map) minor-mode-map-alist))) -(if flyspell-auto-correct-binding - (define-key flyspell-mode-map flyspell-auto-correct-binding - (function flyspell-auto-correct-word))) +(define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word) + ;; mouse bindings (cond ((eq flyspell-emacs 'xemacs) @@ -239,23 +237,22 @@ (if (string-match "19.*XEmacs" emacs-version) 'keymap 'local-map)) - + ;*---------------------------------------------------------------------*/ ;* Highlighting */ ;*---------------------------------------------------------------------*/ (defface flyspell-incorrect-face - '((((class color)) (:foreround "OrangeRed")) + '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) (t (:bold t))) "Face used for showing misspelled words in Flyspell." :group 'flyspell) (defface flyspell-duplicate-face - '((((class color)) (:foreround "Gold3")) + '((((class color)) (:foreground "Gold3" :bold t :underline t)) (t (:bold t))) "Face used for showing misspelled words in Flyspell." :group 'flyspell) - (defvar flyspell-overlay nil) ;*---------------------------------------------------------------------*/ @@ -315,7 +312,7 @@ (make-variable-buffer-local 'ispell-filter-continue) (make-variable-buffer-local 'ispell-process-directory) (make-variable-buffer-local 'ispell-parser))) - ;; we initialize delayed commands symbol + ;; We put the `flyspel-delayed' property on some commands. (flyspell-delay-commands) ;; we bound flyspell action to post-command hook (if flyspell-command-hook @@ -333,17 +330,21 @@ (function flyspell-pre-command-hook) t t))) + + ;; Set flyspell-generic-check-word-p based on the major mode. (let ((mode-predicate (get major-mode 'flyspell-mode-predicate))) (if mode-predicate (setq flyspell-generic-check-word-p mode-predicate))) ;; the welcome message (if flyspell-issue-welcome-flag - (message - (if flyspell-auto-correct-binding - (format "Welcome to flyspell. Use %S or mouse-2 to correct words." - (key-description flyspell-auto-correct-binding)) - "Welcome to flyspell. Use mouse-2 to correct words."))) + (let ((binding (where-is-internal 'flyspell-auto-correct-word + nil 'non-ascii))) + (message + (if binding + (format "Welcome to flyspell. Use %s or Mouse-2 to correct words." + (key-description binding)) + "Welcome to flyspell. Use Mouse-2 to correct words.")))) ;; we have to kill the flyspell process when the buffer is deleted. ;; (thanks to Jeff Miller and Roland Rosenfeld who sent me this ;; improvement). @@ -423,8 +424,10 @@ ;*---------------------------------------------------------------------*/ (defun flyspell-mode-off () "Turn flyspell mode off. Do not use this--use `flyspell-mode' instead." - ;; we stop the running ispell - (ispell-kill-ispell t) + ;; If we have an Ispell process for each buffer, + ;; kill the one for this buffer. + (if flyspell-multi-language-p + (ispell-kill-ispell t)) ;; we remove the hooks (if flyspell-command-hook (progn @@ -485,7 +488,8 @@ (not (bufferp flyspell-pre-buffer)) (not (buffer-live-p flyspell-pre-buffer))) nil) - ((or (= flyspell-pre-point (- (point) 1)) + ((or (and (= flyspell-pre-point (- (point) 1)) + (eq (char-syntax (char-after flyspell-pre-point)) ?w)) (= flyspell-pre-point (point)) (= flyspell-pre-point (+ (point) 1))) nil) @@ -568,6 +572,10 @@ ;; put in verbose mode (process-send-string ispell-process (concat "^" word "\n")) + ;; we mark the ispell process so it can be killed + ;; when emacs is exited without query + (if (fboundp 'process-kill-without-query) + (process-kill-without-query ispell-process)) ;; wait until ispell has processed word (while (progn (accept-process-output ispell-process) @@ -622,8 +630,7 @@ t))))) (if flyspell-highlight-flag (flyspell-highlight-duplicate-region start end) - (message (format "misspelling duplicate `%s'" - word)))) + (message (format "duplicate `%s'" word)))) (t ;; incorrect highlight the location (if flyspell-highlight-flag @@ -769,13 +776,17 @@ "Flyspell text between BEG and END." (interactive "r") (save-excursion + (if (> beg end) + (let ((old beg)) + (setq beg end) + (setq end old))) (goto-char beg) (let ((count 0)) (while (< (point) end) (if (= count 100) (progn (message "Spell Checking...%d%%" - (* 100 (/ (float (point)) (- end beg)))) + (* 100 (/ (float (- (point) beg)) (- end beg)))) (setq count 0)) (setq count (+ 1 count))) (flyspell-word) @@ -834,9 +845,12 @@ ;* ------------------------------------------------------------- */ ;* Is there an highlight properties at position pos? */ ;*---------------------------------------------------------------------*/ -(defun flyspell-properties-at-p (beg) - "Return the text property at position BEG." - (let ((prop (text-properties-at beg)) +(defun flyspell-properties-at-p (pos) + "Return t if there is a text property at POS, not counting `local-map'. +If variable `flyspell-highlight-properties' is set to nil, +text with properties are not checked. This function is used to discover +if the character at POS has any other property." + (let ((prop (text-properties-at pos)) (keep t)) (while (and keep (consp prop)) (if (and (eq (car prop) 'local-map) (consp (cdr prop))) @@ -867,7 +881,7 @@ (defun flyspell-highlight-incorrect-region (beg end) "Set up an overlay on a misspelled word, in the buffer from BEG to END." (run-hook-with-args 'flyspell-incorrect-hook beg end) - (if (or (not (flyspell-properties-at-p beg)) flyspell-highlight-properties) + (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg))) (progn ;; we cleanup current overlay at the same position (if (and (not flyspell-persistent-highlight) @@ -888,7 +902,7 @@ ;*---------------------------------------------------------------------*/ (defun flyspell-highlight-duplicate-region (beg end) "Set up an overlay on a duplicated word, in the buffer from BEG to END." - (if (or (not (flyspell-properties-at-p beg)) flyspell-highlight-properties) + (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg))) (progn ;; we cleanup current overlay at the same position (if (and (not flyspell-persistent-highlight) @@ -915,7 +929,10 @@ ;* flyspell-auto-correct-word ... */ ;*---------------------------------------------------------------------*/ (defun flyspell-auto-correct-word (pos) - "Auto-correct the word at position POS." + "Correct the word at POS. +This command proposes various successive corrections for the word at POS. +The variable `flyspell-auto-correct-binding' specifies the key to bind +to this command." (interactive "d") ;; use the correct dictionary (ispell-accept-buffer-local-defs) @@ -1135,7 +1152,7 @@ (insert word)))))) ;*---------------------------------------------------------------------*/ -;* flyspell-emacs-popup */ +;* flyspell-emacs-popup ... */ ;*---------------------------------------------------------------------*/ (defun flyspell-emacs-popup (event poss word) "The Emacs popup menu." @@ -1178,7 +1195,7 @@ menu))))) ;*---------------------------------------------------------------------*/ -;* flyspell-xemacs-popup */ +;* flyspell-xemacs-popup ... */ ;*---------------------------------------------------------------------*/ (defun flyspell-xemacs-popup (event poss word cursor-location start end) "The xemacs popup menu."