unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* set dictionary for a file
@ 2005-10-12 17:28 Fabian Braennstroem
  2005-10-12 18:38 ` Kevin Rodgers
       [not found] ` <mailman.11056.1129142547.20277.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Fabian Braennstroem @ 2005-10-12 17:28 UTC (permalink / raw)


Hi,

I would like to set/change dictionary for certain files,
which I would declare in .emacs. I tried the
ispell-multi.el, but it somehow didn't work for me. In my
Gnus I had

   (add-hook 'gnus-select-group-hook
    (lambda ()
     (cond
      ((string-match
        "^de\\." (gnus-group-real-name gnus-newsgroup-name))
       (ispell-change-dictionary "deutsch8"))

which worked a while ago. 
Does something similar (file-load-hook?) exist for ordinary files?

Greetings, Fabian

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

* Re: set dictionary for a file
  2005-10-12 17:28 set dictionary for a file Fabian Braennstroem
@ 2005-10-12 18:38 ` Kevin Rodgers
       [not found] ` <mailman.11056.1129142547.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2005-10-12 18:38 UTC (permalink / raw)


Fabian Braennstroem wrote:
 > I would like to set/change dictionary for certain files,
 > which I would declare in .emacs. I tried the
 > ispell-multi.el, but it somehow didn't work for me. In my
 > Gnus I had
 >
 >    (add-hook 'gnus-select-group-hook
 >     (lambda ()
 >      (cond
 >       ((string-match
 >         "^de\\." (gnus-group-real-name gnus-newsgroup-name))
 >        (ispell-change-dictionary "deutsch8"))
 >
 > which worked a while ago.

Here's what ispell.el itself says:

;; Buffer-Local features:
;; There are a number of buffer-local features that can be used to customize
;;  ispell for the current buffer.  This includes language dictionaries,
;;  personal dictionaries, parsing, and local word spellings.  Each of these
;;  local customizations are done either through local variables, or by
;;  including the keyword and argument(s) at the end of the buffer (usually
;;  prefixed by the comment characters).  See the end of this file for
;;  examples.  The local keywords and variables are:

;;  ispell-dictionary-keyword   language-dictionary
;;      uses local variable ispell-local-dictionary
;;  ispell-pdict-keyword        personal-dictionary
;;      uses local variable ispell-local-pdict
;;  ispell-parsing-keyword      mode-arg extended-char-arg
;;  ispell-words-keyword        any number of local word spellings

And:

,----[ C-h v ispell-local-dictionary RET ]
| ispell-local-dictionary's value is nil
|
| Documentation:
| If non-nil, the dictionary to be used for Ispell commands.
| The value must be a string dictionary name in `ispell-dictionary-alist'.
| This variable becomes buffer-local when set in any fashion.
|
| Setting `ispell-local-dictionary' to a value has the same effect as
| calling M-x ispell-change-dictionary with that value.  This variable
| is automatically set when defined in the file with either
| `ispell-dictionary-keyword' or the Local Variable syntax.
|
| To create a non-standard default dictionary (not from 
`ispell-dictionary-alist')
| call function `set-default' with the new dictionary name.
|
| You can customize this variable.
|
| Defined in `ispell'.
`----

So try (setq ispell-local-dictionary "deutsch8") in your hook.

 > Does something similar (file-load-hook?) exist for ordinary files?

,----[ C-h v find-file-hooks RET ]
| find-file-hooks's value is
| (vc-find-file-hook)
|
|
| Documentation:
| List of functions to be called after a buffer is loaded from a file.
| The buffer's local variables (if any) will have been processed before the
| functions are called.
|
| Defined in `files'.
`----

-- 
Kevin Rodgers

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

* Re: set dictionary for a file
       [not found] ` <mailman.11056.1129142547.20277.help-gnu-emacs@gnu.org>
@ 2005-10-13  4:40   ` Fabian Braennstroem
  2005-10-13 16:58     ` Kevin Rodgers
       [not found]     ` <mailman.11235.1129223467.20277.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Fabian Braennstroem @ 2005-10-13  4:40 UTC (permalink / raw)


Hi Kevin,

thanks for the tips!

On 2005-10-12, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>  Fabian Braennstroem wrote:
>  > I would like to set/change dictionary for certain files,
>  > which I would declare in .emacs. I tried the
>  > ispell-multi.el, but it somehow didn't work for me. In my
>  > Gnus I had
>  >
>  >    (add-hook 'gnus-select-group-hook
>  >     (lambda ()
>  >      (cond
>  >       ((string-match
>  >         "^de\\." (gnus-group-real-name gnus-newsgroup-name))
>  >        (ispell-change-dictionary "deutsch8"))
>  >
>  > which worked a while ago.
> 
>  Here's what ispell.el itself says:
> 
>  ;; Buffer-Local features:
>  ;; There are a number of buffer-local features that can be used to customize
>  ;;  ispell for the current buffer.  This includes language dictionaries,
>  ;;  personal dictionaries, parsing, and local word spellings.  Each of these
>  ;;  local customizations are done either through local variables, or by
>  ;;  including the keyword and argument(s) at the end of the buffer (usually
>  ;;  prefixed by the comment characters).  See the end of this file for
>  ;;  examples.  The local keywords and variables are:
> 
>  ;;  ispell-dictionary-keyword   language-dictionary
>  ;;      uses local variable ispell-local-dictionary
>  ;;  ispell-pdict-keyword        personal-dictionary
>  ;;      uses local variable ispell-local-pdict
>  ;;  ispell-parsing-keyword      mode-arg extended-char-arg
>  ;;  ispell-words-keyword        any number of local word spellings
> 
>  And:
> 
>  ,----[ C-h v ispell-local-dictionary RET ]
> | ispell-local-dictionary's value is nil
> |
> | Documentation:
> | If non-nil, the dictionary to be used for Ispell commands.
> | The value must be a string dictionary name in `ispell-dictionary-alist'.
> | This variable becomes buffer-local when set in any fashion.
> |
> | Setting `ispell-local-dictionary' to a value has the same effect as
> | calling M-x ispell-change-dictionary with that value.  This variable
> | is automatically set when defined in the file with either
> | `ispell-dictionary-keyword' or the Local Variable syntax.
> |
> | To create a non-standard default dictionary (not from 
>  `ispell-dictionary-alist')
> | call function `set-default' with the new dictionary name.
> |
> | You can customize this variable.
> |
> | Defined in `ispell'.
>  `----
> 
>  So try (setq ispell-local-dictionary "deutsch8") in your hook.
> 
>  > Does something similar (file-load-hook?) exist for ordinary files?
> 
>  ,----[ C-h v find-file-hooks RET ]
> | find-file-hooks's value is
> | (vc-find-file-hook)
> |
> |
> | Documentation:
> | List of functions to be called after a buffer is loaded from a file.
> | The buffer's local variables (if any) will have been processed before the
> | functions are called.
> |
> | Defined in `files'.
>  `----

I am not sure, if I understood that correctly. Customizing
the find-file-hook I get a list of functions which are
called when a buffer gets loaded; e.g.  vc-find-file-hook
gets loaded. So something like could work when I open
'test.tex':

    (add-hook 'vc-find-file-hook
     (lambda ()
      (cond
       ((string-match "test.tex" )
    (setq ispell-local-dictionary "deutsch8")))))

Somehow it doesn't work!?
 
Now,I just tried to use:

 (if (eq buffer-file-name "article.tex" )
 (setq ispell-local-dictionary "deutsch8"))

which doesn't work either!?

Greetings!
Fabian

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

* Re: set dictionary for a file
  2005-10-13  4:40   ` Fabian Braennstroem
@ 2005-10-13 16:58     ` Kevin Rodgers
       [not found]     ` <mailman.11235.1129223467.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2005-10-13 16:58 UTC (permalink / raw)


Fabian Braennstroem wrote:
 > On 2005-10-12, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
 >> So try (setq ispell-local-dictionary "deutsch8") in your hook.

Did you try:

(add-hook 'gnus-select-group-hook
           (lambda ()
             (when (string-match "^de\\."
                                 (gnus-group-real-name gnus-newsgroup-name))
               (setq ispell-local-dictionary "deutsch8"))))

 >> ,----[ C-h v find-file-hooks RET ]
 >>| find-file-hooks's value is
 >>| (vc-find-file-hook)
 >>|
 >>|
 >>| Documentation:
 >>| List of functions to be called after a buffer is loaded from a file.
 >>| The buffer's local variables (if any) will have been processed 
before the
 >>| functions are called.
 >>|
 >>| Defined in `files'.
 >> `----
 >
 > I am not sure, if I understood that correctly. Customizing
 > the find-file-hook I get a list of functions which are
 > called when a buffer gets loaded; e.g.  vc-find-file-hook
 > gets loaded.
 > So something like could work when I open
 > 'test.tex':
 >
 >     (add-hook 'vc-find-file-hook
 >      (lambda ()
 >       (cond
 >        ((string-match "test.tex" )
 >     (setq ispell-local-dictionary "deutsch8")))))
 >
 > Somehow it doesn't work!?

vc-find-file-hook is a function that gets called (via the
find-file-hooks variable) when a file is visited; it is not a hook
variable itself.  You want to add another function to find-file-hooks:

(add-hook 'find-file-hooks
           (lambda ()
             (when (equal (file-name-nondirectory buffer-file-name) 
"test.tex")
               (setq ispell-local-dictionary "deutsch8"))))

But I suspect what you really want is:

(add-hook 'text-mode-hook
           (lambda ()
             (setq ispell-local-dictionary "deutsch8")))

Under what circumstances do you want to use any other dictionary than
deutsch8?

 > Now,I just tried to use:
 >
 >  (if (eq buffer-file-name "article.tex" )
 >  (setq ispell-local-dictionary "deutsch8"))
 >
 > which doesn't work either!?

`C-h v buffer-file-name' in the article.tex buffer will answer that.

-- 
Kevin Rodgers

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

* Re: set dictionary for a file
       [not found]     ` <mailman.11235.1129223467.20277.help-gnu-emacs@gnu.org>
@ 2005-10-13 19:29       ` Fabian Braennstroem
  0 siblings, 0 replies; 5+ messages in thread
From: Fabian Braennstroem @ 2005-10-13 19:29 UTC (permalink / raw)


Hi Kevin,

On 2005-10-13, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>  Fabian Braennstroem wrote:
>  > On 2005-10-12, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>  >> So try (setq ispell-local-dictionary "deutsch8") in your hook.
> 
>  Did you try:
> 
>  (add-hook 'gnus-select-group-hook
>             (lambda ()
>               (when (string-match "^de\\."
>                                   (gnus-group-real-name gnus-newsgroup-name))
>                 (setq ispell-local-dictionary "deutsch8"))))

I did use that before, now I don't use Gnus any more.

> 
>  >> ,----[ C-h v find-file-hooks RET ]
>  >>| find-file-hooks's value is
>  >>| (vc-find-file-hook)
>  >>|
>  >>|
>  >>| Documentation:
>  >>| List of functions to be called after a buffer is loaded from a file.
>  >>| The buffer's local variables (if any) will have been processed 
>  before the
>  >>| functions are called.
>  >>|
>  >>| Defined in `files'.
>  >> `----
>  >
>  > I am not sure, if I understood that correctly. Customizing
>  > the find-file-hook I get a list of functions which are
>  > called when a buffer gets loaded; e.g.  vc-find-file-hook
>  > gets loaded.
>  > So something like could work when I open
>  > 'test.tex':
>  >
>  >     (add-hook 'vc-find-file-hook
>  >      (lambda ()
>  >       (cond
>  >        ((string-match "test.tex" )
>  >     (setq ispell-local-dictionary "deutsch8")))))
>  >
>  > Somehow it doesn't work!?
> 
>  vc-find-file-hook is a function that gets called (via the
>  find-file-hooks variable) when a file is visited; it is not a hook
>  variable itself.  You want to add another function to find-file-hooks:
> 
>  (add-hook 'find-file-hooks
>             (lambda ()
>               (when (equal (file-name-nondirectory buffer-file-name) 
>  "test.tex")
>                 (setq ispell-local-dictionary "deutsch8"))))

Thanks! That is exactly what I need.

> 
>  But I suspect what you really want is:
> 
>  (add-hook 'text-mode-hook
>             (lambda ()
>               (setq ispell-local-dictionary "deutsch8")))
> 
>  Under what circumstances do you want to use any other dictionary than
>  deutsch8?

I need the german dictionary just for a couple texts;
actually I don't know which I need before I get started to
write anything. So I think the best way to set the dictinary
is to explicitly define the name of the file.


Greetings, Fabian

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

end of thread, other threads:[~2005-10-13 19:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-12 17:28 set dictionary for a file Fabian Braennstroem
2005-10-12 18:38 ` Kevin Rodgers
     [not found] ` <mailman.11056.1129142547.20277.help-gnu-emacs@gnu.org>
2005-10-13  4:40   ` Fabian Braennstroem
2005-10-13 16:58     ` Kevin Rodgers
     [not found]     ` <mailman.11235.1129223467.20277.help-gnu-emacs@gnu.org>
2005-10-13 19:29       ` Fabian Braennstroem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).