all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* flyspell: local abbrev in different languages
@ 2007-09-26  8:31 Uwe Brauer
  2007-09-26 16:28 ` Andreas Röhler
       [not found] ` <mailman.1324.1190824116.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-26  8:31 UTC (permalink / raw)
  To: help-gnu-emacs



Hello

Some time ago I asked this the maintainer of flyspell. Alas flyspell
is no longer maintained. But may be someone with a good understanding
of the abbrev mechanism could answer the following question:


I am using flyspell for quite a time and like it very much. However
there is a small inconvenience.

I prefer to have flyspell-use-global-abbrev-table-p set to nil, in
order to have the abbrev saved in the local abbrev table. 

However I use 3 languages, english, german and spanish.

Take the word region:

In spanish it is región but in english it is region.
In order  that the word is corrected  according to the  language used,
using the abbrev table, the only possibility would be to have
a english, a spanish and a german abbrev table.

Could that be included in flyspell?

Thanks and regards

Uwe Brauer

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

* Re: flyspell: local abbrev in different languages
  2007-09-26  8:31 flyspell: local abbrev in different languages Uwe Brauer
@ 2007-09-26 16:28 ` Andreas Röhler
       [not found] ` <mailman.1324.1190824116.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Andreas Röhler @ 2007-09-26 16:28 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: help-gnu-emacs

Am Mittwoch, 26. September 2007 10:31 schrieb Uwe Brauer:
> Hello
>
> Some time ago I asked this the maintainer of flyspell. Alas flyspell
> is no longer maintained. But may be someone with a good understanding
> of the abbrev mechanism could answer the following question:
>
>
> I am using flyspell for quite a time and like it very much. However
> there is a small inconvenience.
>
> I prefer to have flyspell-use-global-abbrev-table-p set to nil, in
> order to have the abbrev saved in the local abbrev table.
>
> However I use 3 languages, english, german and spanish.
>
> Take the word region:
>
> In spanish it is región but in english it is region.
> In order  that the word is corrected  according to the  language used,
> using the abbrev table, the only possibility would be to have
> a english, a spanish and a german abbrev table.
>
> Could that be included in flyspell?
>
> Thanks and regards
>
> Uwe Brauer


I created an English-mode for this occasion - my common
text-mode is used for abbrevs in German. With
`englisch-mode' abbrevs are locally stored with this
mode without further precautions. Flyspell works too.

You could do the respective thing for Spanish.

(defun englisch-mode ()
  "Major mode for editing englisch written for humans to read.
In this mode, paragraphs are delimited only by blank or white lines.
You can thus get the full benefit of adaptive filling
 (see the variable `adaptive-fill-mode').
\\{englisch-mode-map}
Turning on Text mode runs the normal hook `englisch-mode-hook'."
  (interactive)
  (kill-all-local-variables)
  (use-local-map englisch-mode-map)
  (setq local-abbrev-table englisch-mode-abbrev-table)
  (set-syntax-table englisch-mode-syntax-table)
  (make-local-variable 'paragraph-start)
  (setq paragraph-start (concat page-delimiter "\\|[ \t]*$"))
  (if (eq ?^ (aref paragraph-start 0))
      (setq paragraph-start (substring paragraph-start 1)))
  (make-local-variable 'paragraph-separate)
  (setq paragraph-separate paragraph-start)
  (make-local-variable 'indent-line-function)
  (setq indent-line-function 'indent-relative-maybe)
  (setq mode-name "Englisch")
  (setq major-mode 'englisch-mode)
  (ispell-change-dictionary "english")
  (setq common-abbrevs-list 'common-english-abbrevs)
  (abbrev-mode 1)
  (run-hooks 'englisch-mode-hook))

HTH

Andreas Röhler

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

* Re: flyspell: local abbrev in different languages
       [not found] ` <mailman.1324.1190824116.18990.help-gnu-emacs@gnu.org>
@ 2007-09-26 18:24   ` Uwe Brauer
  2007-09-27 13:24     ` Andreas Röhler
       [not found]     ` <mailman.1393.1190899494.18990.help-gnu-emacs@gnu.org>
  2007-09-27  9:51   ` flyspell: local abbrev in different languages Uwe Brauer
  1 sibling, 2 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-26 18:24 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Andreas" == Andreas Röhler <andreas.roehler@online.de> writes:

   > Am Mittwoch, 26. September 2007 10:31 schrieb Uwe Brauer:
   >> Hello
   >> 

[snip]


   > I created an English-mode for this occasion - my common
   > text-mode is used for abbrevs in German. With
   > `englisch-mode' abbrevs are locally stored with this
   > mode without further precautions. Flyspell works too.

   > You could do the respective thing for Spanish.

Well a mayor mode, I guess that is. The problem with this approach is 
that my favorite modes are message  and LaTeX two mayor modes. So the
logical step would be to use a minor mode, as far as I know it is not
possible to have a abbrev table for that sort of mode.

May be I  could use indirect buffer or region? I have to think about
that.


Uwe 

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

* Re: flyspell: local abbrev in different languages
       [not found] ` <mailman.1324.1190824116.18990.help-gnu-emacs@gnu.org>
  2007-09-26 18:24   ` Uwe Brauer
@ 2007-09-27  9:51   ` Uwe Brauer
  2007-09-27 10:27     ` Uwe Brauer
  1 sibling, 1 reply; 13+ messages in thread
From: Uwe Brauer @ 2007-09-27  9:51 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Andreas" == Andreas Röhler <andreas.roehler@online.de> writes:


   > (defun englisch-mode ()

I had to add some variables in order to make that work.

I am pretty confident that this will work with indirect buffers. 
However when I use your code and make a correction with
flyspell the corresponding abbrev is not written in the table. 

Lets say I write helo, then flyspell offers to use hello which is
correct,  but at the same time defines hello as an abbreviation for 
helo. 

This is recognized while I type but then when I close emacs, the
abbrev file is written but alas not that abbreviation.

That is restarting xemacs opening a file in english mode helo is not
expanded as hello.

Is there something missing in the definition of the 
englisch-mode?


Uwe 

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

* Re: flyspell: local abbrev in different languages
  2007-09-27  9:51   ` flyspell: local abbrev in different languages Uwe Brauer
@ 2007-09-27 10:27     ` Uwe Brauer
  0 siblings, 0 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-27 10:27 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Uwe" == Uwe Brauer <oub@mat.ucm.es> writes:

   > That is restarting xemacs opening a file in english mode helo is not
   > expanded as hello.

   > Is there something missing in the definition of the 
   > englisch-mode?

Ok I checked my fault. For some mysterious reason it was written to
the global abbrev table. So I just add the corresponding lines to your
code and it works like charm

Uwe 

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

* Re: flyspell: local abbrev in different languages
  2007-09-26 18:24   ` Uwe Brauer
@ 2007-09-27 13:24     ` Andreas Röhler
       [not found]     ` <mailman.1393.1190899494.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Andreas Röhler @ 2007-09-27 13:24 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: help-gnu-emacs

Am Mittwoch, 26. September 2007 20:24 schrieb Uwe Brauer:
> >>>>> "Andreas" == Andreas Röhler <andreas.roehler@online.de> writes:
>    >
>    > Am Mittwoch, 26. September 2007 10:31 schrieb Uwe Brauer:
>    >> Hello
>
> [snip]
>
>    > I created an English-mode for this occasion - my common
>    > text-mode is used for abbrevs in German. With
>    > `englisch-mode' abbrevs are locally stored with this
>    > mode without further precautions. Flyspell works too.
>    >
>    > You could do the respective thing for Spanish.
>
> Well a mayor mode, I guess that is. The problem with this approach is
> that my favorite modes are message  and LaTeX two mayor modes. So the
> logical step would be to use a minor mode, as far as I know it is not
> possible to have a abbrev table for that sort of mode.
>
...

Don't think so.

With both functions below I'm able to expand `tx' to
`texto' as shown (extrait from .abbrev_defs). Inserted
this by hand first, maybe "(copy-abbrev-table
text-mode-abbrev-table)" in my function didn't had the
effect.

HTH

Andreas Röhler


;;; (define-abbrev-table 'spanish-minor-mode-abbrev-table '(
;;;     ("tx" "texto" nil 0)
;;;     ))

(define-minor-mode spanish-minor-mode
  "Switch Spanish minor mode on."
  nil nil nil
  (set (make-local-variable 'spanish-minor-mode) t)
  (unless (memq 'spanish-minor-mode-abbrev-table abbrev-table-name-list)
    (setq spanish-minor-mode-abbrev-table
	  (copy-abbrev-table text-mode-abbrev-table))
    (add-to-list 'abbrev-table-name-list 'spanish-minor-mode-abbrev-table))
  (setq local-abbrev-table spanish-minor-mode-abbrev-table))

(defun disable-spanish-minor-mode ()
  " "
  (interactive)
  (setq spanish-minor-mode nil)
  (setq local-abbrev-table text-mode-abbrev-table))

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

* Re: flyspell: local abbrev in different languages
       [not found]     ` <mailman.1393.1190899494.18990.help-gnu-emacs@gnu.org>
@ 2007-09-27 14:01       ` Uwe Brauer
  2007-09-28  6:28         ` Andreas Röhler
       [not found]         ` <mailman.1416.1190960922.18990.help-gnu-emacs@gnu.org>
  2007-09-28 15:12       ` flyspell: local abbrev in different languages Stefan Monnier
  1 sibling, 2 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-27 14:01 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Andreas" == Andreas Röhler <andreas.roehler@online.de> writes:
   >> 
   > ...

   > Don't think so.

   > With both functions below I'm able to expand `tx' to
   > `texto' as shown (extrait from .abbrev_defs). Inserted
   > this by hand first, maybe "(copy-abbrev-table
   > text-mode-abbrev-table)" in my function didn't had the
   > effect.

Hm now  I am really confused.
Your function copies an existing table into a new one. But what I
would like to do is to have in LaTeX mode, either spanish-minor mode
or german-minor-mode or english-minor-mode turn on.

Then according to this minor mode flyspell should write in the
corresponding (minor) mode tables. I don't see how your code does
this.

As I understand it, you can define some abbrevs in say your
english-mayor-mode and then with your function copy it into
minor-mode-table.

Do I understand that correctly?

Unfortunately I could no test your codes since it contains some emacs
specific functions namely copy-abbrev-table for which no equivalent
seems to exit in XEmacs.

Uwe 

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

* Re: flyspell: local abbrev in different languages
  2007-09-27 14:01       ` Uwe Brauer
@ 2007-09-28  6:28         ` Andreas Röhler
       [not found]         ` <mailman.1416.1190960922.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Andreas Röhler @ 2007-09-28  6:28 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: help-gnu-emacs

Am Donnerstag, 27. September 2007 16:01 schrieb Uwe Brauer:
> >>>>> "Andreas" == Andreas Röhler <andreas.roehler@online.de> writes:
>    >
>    > ...
>    >
>    > Don't think so.
>    >
>    > With both functions below I'm able to expand `tx' to
>    > `texto' as shown (extrait from .abbrev_defs). Inserted
>    > this by hand first, maybe "(copy-abbrev-table
>    > text-mode-abbrev-table)" in my function didn't had the
>    > effect.
>
> Hm now  I am really confused.
> Your function copies an existing table into a new one. But what I
> would like to do is to have in LaTeX mode, either spanish-minor mode
> or german-minor-mode or english-minor-mode turn on.
>
> Then according to this minor mode flyspell should write in the
> corresponding (minor) mode tables. I don't see how your code does
> this.
>
> As I understand it, you can define some abbrevs in say your
> english-mayor-mode and then with your function copy it into
> minor-mode-table.
>
> Do I understand that correctly?
>
> Unfortunately I could no test your codes since it contains some emacs
> specific functions namely copy-abbrev-table for which no equivalent
> seems to exit in XEmacs.
>
> Uwe


I've dropped this copy-function, whose intention was a
side-effect, not needed as it turns out.

Spanish minor-mode works here as shown below. Should it not
work with XEmacs now, please send a notice.

To install further language-tables it might be
necessary to edit `.abbrev_defs' by hand inserting
something like

(define-abbrev-table 'MY-minor-mode-abbrev-table '(
     ))

Thats all AFAIS

Andreas Röhler


;;; (define-abbrev-table 'spanish-minor-mode-abbrev-table '(
;;;     ("tx" "texto" nil 0)
;;;     ))

(define-minor-mode spanish-minor-mode
  "Switch on Spanish minor mode."
  nil nil nil
  (set (make-local-variable 'spanish-minor-mode) t)
  (unless (memq 'spanish-minor-mode-abbrev-table abbrev-table-name-list)
    (add-to-list 'abbrev-table-name-list 'spanish-minor-mode-abbrev-table))
  (setq local-abbrev-table spanish-minor-mode-abbrev-table))

(defun disable-spanish-minor-mode ()
  "Disable Spanish minor-mode. "
  (interactive)
  (setq spanish-minor-mode nil)
  (setq local-abbrev-table text-mode-abbrev-table))

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

* (inverse)-add-local-mode-abbrev (was: flyspell: local abbrev in different languages)
       [not found]         ` <mailman.1416.1190960922.18990.help-gnu-emacs@gnu.org>
@ 2007-09-28  8:31           ` Uwe Brauer
  0 siblings, 0 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-28  8:31 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Andreas" == Andreas Röhler <andreas.roehler@online.de> writes:
   >> 
   >> Uwe


   > I've dropped this copy-function, whose intention was a
   > side-effect, not needed as it turns out.

   > Spanish minor-mode works here as shown below. Should it not
   > work with XEmacs now, please send a notice.

   > To install further language-tables it might be
   > necessary to edit `.abbrev_defs' by hand inserting
   > something like

   > (define-abbrev-table 'MY-minor-mode-abbrev-table '(
   >      ))

   > Thats all AFAIS

   > Andreas Röhler

Ok I see this works. However the main question is how to add 
entries to
(define-abbrev-table 'spanish-minor-mode-abbrev-table '(
     ("tx" "texto" nil 0)
     ))

There are only two functions I know of namely 


(inverse)-add-mode-abbrev which adds to a global-mode-abbrev-table
and 
inverse-add-global-abbrev
which adds to the global-abbrev-table

And flyspell makes use of one of them.

So what would be needed is a 
 (inverse)-add-local-mode-abbrev 
which adds to a
 local-mode-abbrev-table

And then to include that into the flyspell code.

I just tested the interaction between a global-mode-abbrev-table and a
local-mode-abbrev-table.

I had in an emacs-lisp file I defined tx as text and in the minor mode
tx as texto. When turning the minor mode on and off, the abbrev of the
minor mode was used not that of the global mode, as it should be 

Uwe 

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

* Re: flyspell: local abbrev in different languages
       [not found]     ` <mailman.1393.1190899494.18990.help-gnu-emacs@gnu.org>
  2007-09-27 14:01       ` Uwe Brauer
@ 2007-09-28 15:12       ` Stefan Monnier
  2007-09-28 15:40         ` Uwe Brauer
  2007-09-28 16:29         ` prbl msg mode (was: flyspell: local abbrev in different languages) Uwe Brauer
  1 sibling, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 2007-09-28 15:12 UTC (permalink / raw)
  To: help-gnu-emacs

> (define-minor-mode spanish-minor-mode
>   "Switch Spanish minor mode on."
>   nil nil nil
>   (set (make-local-variable 'spanish-minor-mode) t)
>   (unless (memq 'spanish-minor-mode-abbrev-table abbrev-table-name-list)
>     (setq spanish-minor-mode-abbrev-table
> 	  (copy-abbrev-table text-mode-abbrev-table))
>     (add-to-list 'abbrev-table-name-list 'spanish-minor-mode-abbrev-table))
>   (setq local-abbrev-table spanish-minor-mode-abbrev-table))

> (defun disable-spanish-minor-mode ()
>   " "
>   (interactive)
>   (setq spanish-minor-mode nil)
>   (setq local-abbrev-table text-mode-abbrev-table))

Looks like you slightly misunderstood what define-minor-mode does.
The following might be a good starting point (the spanish-minor-mode
covers both enable and disable, as ):

  (define-minor-mode spanish-minor-mode
    nil nil nil nil
    (setq local-abbrev-table
          (if spanish-minor-mode
              spanish-minor-mode-abbrev-table
            text-mode-abbrev-table)))


-- Stefan

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

* Re: flyspell: local abbrev in different languages
  2007-09-28 15:12       ` flyspell: local abbrev in different languages Stefan Monnier
@ 2007-09-28 15:40         ` Uwe Brauer
  2007-09-28 16:29         ` prbl msg mode (was: flyspell: local abbrev in different languages) Uwe Brauer
  1 sibling, 0 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-28 15:40 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

   >   (define-minor-mode spanish-minor-mode
   >     nil nil nil nil
   >     (setq local-abbrev-table
   >           (if spanish-minor-mode
   >               spanish-minor-mode-abbrev-table
   >             text-mode-abbrev-table)))

Well I just checked that. It seems to do *precisely* what I was
looking for.
When that mode is turned on  inverse-add-mode-abbrev adds to the table
of that minor mode and *not* to the text-mode table.

Since flyspell uses (inverse-add-mode-abbrev) or the like, flyspell
now does precisely what I want. This looks really great.

Thanks a _lot_

Uwe 

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

* prbl msg mode (was: flyspell: local abbrev in different languages)
  2007-09-28 15:12       ` flyspell: local abbrev in different languages Stefan Monnier
  2007-09-28 15:40         ` Uwe Brauer
@ 2007-09-28 16:29         ` Uwe Brauer
  2007-09-28 17:45           ` prbl msg mode Uwe Brauer
  1 sibling, 1 reply; 13+ messages in thread
From: Uwe Brauer @ 2007-09-28 16:29 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

   >   (define-minor-mode spanish-minor-mode
   >     nil nil nil nil
   >     (setq local-abbrev-table
   >           (if spanish-minor-mode
   >               spanish-minor-mode-abbrev-table
   >             text-mode-abbrev-table)))


Well there seems to be a slight problem, while I can use that minor
mode in emacs-lisp-mode or in latex mode, it seems that it does not
work in message mode. That is even if this mode turned on the expansion
does not work.

Uwe 

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

* Re: prbl msg mode
  2007-09-28 16:29         ` prbl msg mode (was: flyspell: local abbrev in different languages) Uwe Brauer
@ 2007-09-28 17:45           ` Uwe Brauer
  0 siblings, 0 replies; 13+ messages in thread
From: Uwe Brauer @ 2007-09-28 17:45 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Uwe" == Uwe Brauer <oub@mat.ucm.es> writes:



   > Well there seems to be a slight problem, while I can use that minor
   > mode in emacs-lisp-mode or in latex mode, it seems that it does not
   > work in message mode. That is even if this mode turned on the expansion
   > does not work.
I tried the following 

(define-minor-mode spanish-minor-mode-2
    nil nil nil nil
    (setq local-abbrev-table
          (if spanish-minor-mode
              spanish-minor-mode-abbrev-table
            message-mode-abbrev-table)))

It seems that I cannot add a local-abbrev-table to message mode, and
as far as I can see inverse-add-mode-abbrev does not work in message
mode.


Uwe 

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

end of thread, other threads:[~2007-09-28 17:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-26  8:31 flyspell: local abbrev in different languages Uwe Brauer
2007-09-26 16:28 ` Andreas Röhler
     [not found] ` <mailman.1324.1190824116.18990.help-gnu-emacs@gnu.org>
2007-09-26 18:24   ` Uwe Brauer
2007-09-27 13:24     ` Andreas Röhler
     [not found]     ` <mailman.1393.1190899494.18990.help-gnu-emacs@gnu.org>
2007-09-27 14:01       ` Uwe Brauer
2007-09-28  6:28         ` Andreas Röhler
     [not found]         ` <mailman.1416.1190960922.18990.help-gnu-emacs@gnu.org>
2007-09-28  8:31           ` (inverse)-add-local-mode-abbrev (was: flyspell: local abbrev in different languages) Uwe Brauer
2007-09-28 15:12       ` flyspell: local abbrev in different languages Stefan Monnier
2007-09-28 15:40         ` Uwe Brauer
2007-09-28 16:29         ` prbl msg mode (was: flyspell: local abbrev in different languages) Uwe Brauer
2007-09-28 17:45           ` prbl msg mode Uwe Brauer
2007-09-27  9:51   ` flyspell: local abbrev in different languages Uwe Brauer
2007-09-27 10:27     ` Uwe Brauer

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.