emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ispell loads dict twice.


From: Michaël Cadilhac
Subject: Ispell loads dict twice.
Date: Mon, 24 Apr 2006 21:36:40 +0200
User-agent: Gnus/5.110005 (No Gnus v0.5) Emacs/22.0.50 (gnu/linux)

  Hi !

  I use the latest CVS version.

  With the following :

$ emacs -Q

C-u M-x ispell-change-dictionary RET francais RET
C-x b test1 RET
M-x ispell-change-dictionary RET english RET
M-x ispell-buffer
C-x b test2 RET
M-x ispell-change-dictionary RET english RET

  The « english » dictionary will be loaded twice: on the
  « ispell-buffer » and on the latest « ispell-change-dictionary ».

  The rest of this message is IMHO :-)

  What happens is the following on the second ispell-change-dictionary:

  - ispell-buffer-local-dict is called,
  - this one calls ispell-internal-change-dictionary,
  - ispell-local-dictionary being nil, and current dictionary
    (« english ») not being equal to default one (« francais »), the
    ispell process is killed.

  So it has to be restarted.

  The call to ispell-buffer-local-dict is mandatory
  (ispell-change-dictionary could be called with "" just to load
  default buffer's one), but it should not call
  ispell-internal-change-dictionary at this time.

  The proposed patch :
  - Delays this call,
  - Makes ispell-internal-change-dictionary checks for pdict,
  - Fixes the bug.
  
  Could someone have a look and install it if needed ?

Index: ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.9435
diff -c -r1.9435 ChangeLog
*** ChangeLog   23 Apr 2006 21:45:28 -0000      1.9435
--- ChangeLog   24 Apr 2006 19:30:55 -0000
***************
*** 1,3 ****
--- 1,14 ----
+ 2006-04-24  Michaël Cadilhac  <address@hidden>
+ 
+       * textmodes/ispell.el (ispell-buffer-local-dict): Add a `no-reload'
+       argument to avoid the call to `ispell-internal-change-dictionary'
+       when not needed.
+       (ispell-change-dictionary): Use this argument and call
+       `ispell-internal-change-dictionary' after the possible change
+       to `ispell-local-dictionary'.
+       (ispell-internal-change-dictionary): Check for a change in
+       personal dictionary use too.
+       
  2006-04-23  Michael Albinus  <address@hidden>
  
        * net/tramp.el (tramp-register-file-name-handlers): New defun.
Index: textmodes/ispell.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/ispell.el,v
retrieving revision 1.197
diff -c -r1.197 ispell.el
*** textmodes/ispell.el 6 Apr 2006 19:20:37 -0000       1.197
--- textmodes/ispell.el 24 Apr 2006 19:30:55 -0000
***************
*** 2607,2621 ****
               (mapcar 'list (ispell-valid-dictionary-list)))
          nil t)
         current-prefix-arg))
!   (unless arg (ispell-buffer-local-dict))
    (if (equal dict "default") (setq dict nil))
    ;; This relies on completing-read's bug of returning "" for no match
    (cond ((equal dict "")
         (message "Using %s dictionary"
                  (or ispell-local-dictionary ispell-dictionary "default")))
        ((equal dict (or ispell-local-dictionary
                         ispell-dictionary "default"))
!        ;; Specified dictionary is the default already.  No-op
         (and (interactive-p)
              (message "No change, using %s dictionary" dict)))
        (t                              ; reset dictionary!
--- 2607,2624 ----
               (mapcar 'list (ispell-valid-dictionary-list)))
          nil t)
         current-prefix-arg))
!   (unless arg (ispell-buffer-local-dict t))
    (if (equal dict "default") (setq dict nil))
    ;; This relies on completing-read's bug of returning "" for no match
    (cond ((equal dict "")
+        (ispell-internal-change-dictionary)
         (message "Using %s dictionary"
                  (or ispell-local-dictionary ispell-dictionary "default")))
        ((equal dict (or ispell-local-dictionary
                         ispell-dictionary "default"))
!        ;; Specified dictionary is the default already. Could reload
!        ;; the dictionaries if needed.
!        (ispell-internal-change-dictionary)
         (and (interactive-p)
              (message "No change, using %s dictionary" dict)))
        (t                              ; reset dictionary!
***************
*** 2634,2646 ****
                  dict))))
  
  (defun ispell-internal-change-dictionary ()
!   "Update the dictionary actually used by Ispell.
  This may kill the Ispell process; if so,
  a new one will be started when needed."
!   (let ((dict (or ispell-local-dictionary ispell-dictionary)))
!     (unless (equal ispell-current-dictionary dict)
        (ispell-kill-ispell t)
!       (setq ispell-current-dictionary dict))))
  
  ;;; Spelling of comments are checked when ispell-check-comments is non-nil.
  
--- 2637,2652 ----
                  dict))))
  
  (defun ispell-internal-change-dictionary ()
!   "Update the dictionary and the personal dictionary used by Ispell.
  This may kill the Ispell process; if so,
  a new one will be started when needed."
!   (let ((dict (or ispell-local-dictionary ispell-dictionary))
!       (pdict (or ispell-local-pdict ispell-personal-dictionary)))
!     (unless (and (equal ispell-current-dictionary dict)
!                (equal ispell-current-personal-dictionary pdict))
        (ispell-kill-ispell t)
!       (setq ispell-current-dictionary dict
!           ispell-current-personal-dictionary pdict))))
  
  ;;; Spelling of comments are checked when ispell-check-comments is non-nil.
  
***************
*** 3667,3674 ****
  
  ;;; Can kill the current ispell process
  
! (defun ispell-buffer-local-dict ()
    "Initializes local dictionary and local personal dictionary.
  When a dictionary is defined in the buffer (see variable
  `ispell-dictionary-keyword'), it will override the local setting
  from \\[ispell-change-dictionary].
--- 3673,3681 ----
  
  ;;; Can kill the current ispell process
  
! (defun ispell-buffer-local-dict (&optional no-reload)
    "Initializes local dictionary and local personal dictionary.
+ If optional NO-RELOAD is non-nil, do not make any dictionary reloading.
  When a dictionary is defined in the buffer (see variable
  `ispell-dictionary-keyword'), it will override the local setting
  from \\[ispell-change-dictionary].
***************
*** 3695,3706 ****
            (if (re-search-forward " *\\([^ \"]+\\)" end t)
                (setq ispell-local-pdict
                      (match-string-no-properties 1)))))))
!   ;; Reload if new personal dictionary defined.
!   (if (not (equal ispell-current-personal-dictionary
!                 (or ispell-local-pdict ispell-personal-dictionary)))
!       (ispell-kill-ispell t))
!   ;; Reload if new dictionary defined.
!   (ispell-internal-change-dictionary))
  
  
  (defun ispell-buffer-local-words ()
--- 3702,3710 ----
            (if (re-search-forward " *\\([^ \"]+\\)" end t)
                (setq ispell-local-pdict
                      (match-string-no-properties 1)))))))
!   (unless no-reload
!     ;; Reload if new dictionary (maybe the personal one) defined.
!     (ispell-internal-change-dictionary)))
  
  
  (defun ispell-buffer-local-words ()
  Thanks.

-- 
 |      Michaël `Micha' Cadilhac   |   Mieux vaut se taire                  |
 |         Epita/LRDE Promo 2007   |    Que de parler trop fort.            |
 | http://www.lrde.org/~cadilh_m   |            -- As de trèfle             |
 `--  -   JID: address@hidden --'                                   -  --'

Attachment: pgpCN03FJ2ucv.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]