all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* flyspell doesn't catch local variables?
@ 2006-12-06 18:35 Michaël Cadilhac
  2006-12-06 18:43 ` Stuart D. Herring
  0 siblings, 1 reply; 4+ messages in thread
From: Michaël Cadilhac @ 2006-12-06 18:35 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 187 bytes --]

Try this:

$ emacs -Q

M-: (progn (require 'latex)
           (setq ispell-dictionary "francais")
           (add-hook 'LaTeX-mode-hook 'flyspell-mode))

And now open the following file:

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: test.tex --]
[-- Type: text/x-tex, Size: 112 bytes --]

\section{What is a game?}

%%% Local Variables:
%%% mode: latex
%%% ispell-local-dictionary: "english"
%%% End:

[-- Attachment #1.1.3: Type: text/plain, Size: 95 bytes --]


The dictionary loaded will be the french one, not the english one.

The following fixes that.

[-- Attachment #1.1.4: flyspell.patch --]
[-- Type: text/x-patch, Size: 2648 bytes --]

Index: lisp/textmodes/flyspell.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/flyspell.el,v
retrieving revision 1.112
diff -c -r1.112 flyspell.el
*** lisp/textmodes/flyspell.el	11 Nov 2006 01:00:03 -0000	1.112
--- lisp/textmodes/flyspell.el	6 Dec 2006 17:34:41 -0000
***************
*** 541,546 ****
--- 541,551 ----
              (member (or ispell-local-dictionary ispell-dictionary)
                      flyspell-dictionaries-that-consider-dash-as-word-delimiter)))))
  
+ (defun flyspell-hack-local-variables-hook ()
+   ;; When local variables are loaded, see if the dictionary context
+   ;; has changed.
+   (flyspell-accept-buffer-local-defs 'force))
+ 
  (defun flyspell-kill-ispell-hook ()
    (setq flyspell-last-buffer nil)
    (dolist (buf (buffer-list))
***************
*** 579,584 ****
--- 584,592 ----
    (add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t)
    ;; we bound flyspell action to after-change hook
    (add-hook 'after-change-functions 'flyspell-after-change-function nil t)
+   ;; we bound flyspell action to hack-local-variables-hook
+   (add-hook 'hack-local-variables-hook
+ 	    (function flyspell-hack-local-variables-hook) t t)
    ;; set flyspell-generic-check-word-predicate based on the major mode
    (let ((mode-predicate (get major-mode 'flyspell-mode-predicate)))
      (if mode-predicate
***************
*** 684,689 ****
--- 692,699 ----
    (remove-hook 'post-command-hook (function flyspell-post-command-hook) t)
    (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t)
    (remove-hook 'after-change-functions 'flyspell-after-change-function t)
+   (remove-hook 'hack-local-variables-hook
+ 	       (function flyspell-hack-local-variables-hook) t)
    ;; we remove all the flyspell hilightings
    (flyspell-delete-all-overlays)
    ;; we have to erase pre cache variables
Index: lisp/textmodes/../ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10400
diff -c -0 -r1.10400 ChangeLog
*** lisp/textmodes/../ChangeLog	4 Dec 2006 10:24:04 -0000	1.10400
--- lisp/textmodes/../ChangeLog	6 Dec 2006 17:35:03 -0000
***************
*** 0 ****
--- 1,7 ----
+ 2006-12-06  Michaël Cadilhac  <michael.cadilhac@lrde.org>
+ 
+ 	* textmodes/flyspell.el (flyspell-hack-local-variables-hook): New.
+ 	Force buffer local defs evaluation on local variables loading.
+ 	(flyspell-mode-on, flyspell-mode-off): Use it in
+ 	`hack-local-variables-hook'.
+ 

[-- Attachment #1.1.5: Type: text/plain, Size: 409 bytes --]


TIA!
-- 
/!\ My mail address has changed, please update your files accordingly.
 |      Michaël `Micha' Cadilhac     |  La culture c'est comme la confiture,  |
 |         Epita/LRDE Promo 2007     |      c'est meilleur avec du pain.      |
 |  http://michael.cadilhac.name     |           -- MOI59                     |
 `--JID: michael.cadilhac@gmail.com--'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: flyspell doesn't catch local variables?
  2006-12-06 18:35 flyspell doesn't catch local variables? Michaël Cadilhac
@ 2006-12-06 18:43 ` Stuart D. Herring
  2006-12-06 18:56   ` Michaël Cadilhac
  2006-12-06 19:44   ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Stuart D. Herring @ 2006-12-06 18:43 UTC (permalink / raw)
  Cc: emacs-devel

> The following fixes that.

Out of curiosity more than correction, why use `function' in your calls to
*-hook?  It's not an environment where you could actually inline a
function call or aid compiling in any way that I can see...

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: flyspell doesn't catch local variables?
  2006-12-06 18:43 ` Stuart D. Herring
@ 2006-12-06 18:56   ` Michaël Cadilhac
  2006-12-06 19:44   ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Michaël Cadilhac @ 2006-12-06 18:56 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 809 bytes --]

"Stuart D. Herring" <herring@lanl.gov> writes:

>> The following fixes that.
>
> Out of curiosity more than correction, why use `function' in your calls to
> *-hook?  It's not an environment where you could actually inline a
> function call or aid compiling in any way that I can see...

I was wondering the same.  I just stuck to the convention used in the
rest of the code, for coherence sake.

-- 
/!\ My mail address has changed, please update your files accordingly.
 |      Michaël `Micha' Cadilhac     |  In a World without Walls and Fences,  |
 |         Epita/LRDE Promo 2007     |     who needs Windows and Gates?       |
 |  http://michael.cadilhac.name     |          -- Dino Esposito              |
 `--JID: michael.cadilhac@gmail.com--'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: flyspell doesn't catch local variables?
  2006-12-06 18:43 ` Stuart D. Herring
  2006-12-06 18:56   ` Michaël Cadilhac
@ 2006-12-06 19:44   ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2006-12-06 19:44 UTC (permalink / raw)
  Cc: Michaël Cadilhac, emacs-devel

> Out of curiosity more than correction, why use `function' in your calls to
> *-hook?  It's not an environment where you could actually inline a
> function call or aid compiling in any way that I can see...

You either have to put function' or `quote' (or their respective
shorthand ' or #'), so if it's a function you may as well use `function'.
It's at least harmless and could even be considered better because it gives
more information about the intent.


        Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-12-06 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-06 18:35 flyspell doesn't catch local variables? Michaël Cadilhac
2006-12-06 18:43 ` Stuart D. Herring
2006-12-06 18:56   ` Michaël Cadilhac
2006-12-06 19:44   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.