comparison lisp/textmodes/flyspell.el @ 68053:5770fac9a117

(flyspell-accept-buffer-local-defs): Add an argument `force' to disable the flyspell-last-buffer optimization. (flyspell-mode-on): Use it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 05 Jan 2006 21:52:16 +0000
parents 35ea50aa6020
children 9b4c8f5efab7
comparison
equal deleted inserted replaced
68052:52ebcbbec4f0 68053:5770fac9a117
1 ;;; flyspell.el --- on-the-fly spell checker 1 ;;; flyspell.el --- on-the-fly spell checker
2 2
3 ;; Copyright (C) 1998, 2000, 2002, 2003, 2004, 3 ;; Copyright (C) 1998, 2000, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc. 4 ;; 2005, 2006 Free Software Foundation, Inc.
5 5
6 ;; Author: Manuel Serrano <Manuel.Serrano@sophia.inria.fr> 6 ;; Author: Manuel Serrano <Manuel.Serrano@sophia.inria.fr>
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 ;; Keywords: convenience 8 ;; Keywords: convenience
9 9
502 ;;* flyspell-accept-buffer-local-defs ... */ 502 ;;* flyspell-accept-buffer-local-defs ... */
503 ;;*---------------------------------------------------------------------*/ 503 ;;*---------------------------------------------------------------------*/
504 (defvar flyspell-last-buffer nil 504 (defvar flyspell-last-buffer nil
505 "The buffer in which the last flyspell operation took place.") 505 "The buffer in which the last flyspell operation took place.")
506 506
507 (defun flyspell-accept-buffer-local-defs () 507 (defun flyspell-accept-buffer-local-defs (&optional force)
508 ;; When flyspell-word is used inside a loop (e.g. when processing 508 ;; When flyspell-word is used inside a loop (e.g. when processing
509 ;; flyspell-changes), the calls to `ispell-accept-buffer-local-defs' end 509 ;; flyspell-changes), the calls to `ispell-accept-buffer-local-defs' end
510 ;; up dwarfing everything else, so only do it when the buffer has changed. 510 ;; up dwarfing everything else, so only do it when the buffer has changed.
511 (unless (eq flyspell-last-buffer (current-buffer)) 511 (when (or force (not (eq flyspell-last-buffer (current-buffer))))
512 (setq flyspell-last-buffer (current-buffer)) 512 (setq flyspell-last-buffer (current-buffer))
513 ;; Strange problem: If buffer in current window has font-lock turned on, 513 ;; Strange problem: If buffer in current window has font-lock turned on,
514 ;; but SET-BUFFER was called to point to an invisible buffer, this ispell 514 ;; but SET-BUFFER was called to point to an invisible buffer, this ispell
515 ;; call will reset the buffer to the buffer in the current window. 515 ;; call will reset the buffer to the buffer in the current window.
516 ;; However, it only happens at startup (fix by Albert L. Ting). 516 ;; However, it only happens at startup (fix by Albert L. Ting).
537 (if flyspell-default-dictionary 537 (if flyspell-default-dictionary
538 (ispell-change-dictionary flyspell-default-dictionary))) 538 (ispell-change-dictionary flyspell-default-dictionary)))
539 ;; we have to force ispell to accept the local definition or 539 ;; we have to force ispell to accept the local definition or
540 ;; otherwise it could be too late, the local dictionary may 540 ;; otherwise it could be too late, the local dictionary may
541 ;; be forgotten! 541 ;; be forgotten!
542 (flyspell-accept-buffer-local-defs) 542 ;; Pass the `force' argument for the case where flyspell was active already
543 ;; but the buffer's local-defs have been edited.
544 (flyspell-accept-buffer-local-defs 'force)
543 ;; we put the `flyspell-delayed' property on some commands 545 ;; we put the `flyspell-delayed' property on some commands
544 (flyspell-delay-commands) 546 (flyspell-delay-commands)
545 ;; we put the `flyspell-deplacement' property on some commands 547 ;; we put the `flyspell-deplacement' property on some commands
546 (flyspell-deplacement-commands) 548 (flyspell-deplacement-commands)
547 ;; we bound flyspell action to post-command hook 549 ;; we bound flyspell action to post-command hook