all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: Re: auto-detect multiple languages -- ispell-detect.el
Date: Sun, 04 Aug 2024 08:14:10 +0200	[thread overview]
Message-ID: <87h6c0stl9.fsf@dataswamp.org> (raw)
In-Reply-To: 86plqou98v.fsf@gnu.org

Eli Zaretskii wrote:

>> (setq ispell-silently-savep t)
>
> That just sweeps the problem under the carpet, because users
> shouldn't need to save the personal dictionary more than
> once in a session.

Here, "the problem" is spelling multiple languages in the
same buffer.

>> How does Hunspell know vad som är vilket språk if they
>> are intermixed?
>
> It checks the words in all the dictionaries.

Yes, that's the only way to do it?

You can do that with ispell, it is what I did in
ispell-detect.el [1] however that, `ispell-lookup-words',
doesn't use the regular ispell 'i-' dictionaries
"iamerican-insane" and so on, but the 'w-' wordlists
typically installed in /usr/share/dict/ - files that are
uncompressed any without metadata.

You can of course uncompress the ispell files and run some
sed, maybe

  sed -e 's/\/.*$//g' $src > $dst

to remove the metadata but naah, I think ispell should be more
than capable doing this all by itself using its
own dictionaries.

Ispell's code is a complete jungle, I'm not digging into it.
I can see in one second it is written in a style that is,
well, not mine.

I can spell individual words and get the result back, with
this in another file I have [2], this solved a cute little
problem [3].

That code is obviously a joke, here we see Emacs harmful "do
everything in a buffer" policy taken to a degree where a big
program cannot even do its own most basic task
programmatically. The word first has to be inserted! (Perhaps
this has changed since.)

If there was a better such function one could maybe consider
the Hunspell approach for ispell but if one did this for every
word it is out of the question to reload dictionary all
the time.

(defun spell-word (word)
  (with-temp-buffer
    (save-excursion
      (insert word) )
    (condition-case nil
        (not (ispell-word))
      (error nil) )))
      
;; (spell-word "length") ; t
;; (spell-word "lenght") ; nil

Anyway, maybe this should be dropped then and we should
recommend people who want this to use Hunspell?

[1] https://dataswamp.org/~incal/emacs-init/ispell-detect.el
[2] https://dataswamp.org/~incal/emacs-init/spell.el
[3] https://dataswamp.org/~incal/emacs-init/perm.el

-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2024-08-04  6:14 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 11:42 auto-detect multiple languages -- ispell-detect.el Emanuel Berg
2024-08-02  2:53 ` Richard Stallman
2024-08-02  8:06   ` Gregor Zattler
2024-08-02 22:32     ` Emanuel Berg
2024-08-03  2:02     ` Emanuel Berg
2024-08-04  6:52       ` Uwe Brauer via Emacs development discussions.
2024-08-03 13:25     ` Emanuel Berg
2024-08-03 17:14       ` Emanuel Berg
2024-08-03 19:58         ` Emanuel Berg
2024-08-04  5:09           ` Eli Zaretskii
2024-08-04  5:31             ` Emanuel Berg
2024-08-04  5:50               ` Eli Zaretskii
2024-08-04  6:14                 ` Emanuel Berg [this message]
2024-08-04  6:27                   ` Eli Zaretskii
2024-08-04  6:40                     ` Emanuel Berg
2024-08-04  7:08                       ` Eli Zaretskii
2024-08-04 10:30                         ` Stefan Kangas
2024-08-04 15:25                           ` Uwe Brauer via Emacs development discussions.
2024-08-04 15:56                             ` Emanuel Berg
2024-08-04 17:45                               ` tomas
2024-08-04  7:13                     ` Emanuel Berg
2024-08-07 15:41                     ` Björn Bidar
     [not found]                     ` <87wmkspcgn.fsf@>
2024-08-08  2:01                       ` guess-language package Richard Stallman
2024-08-08  6:42                         ` Joost Kremers
2024-08-12  1:47                           ` Richard Stallman
2024-08-08  6:55                       ` auto-detect multiple languages -- ispell-detect.el Joost Kremers
2024-08-12  1:47                       ` Richard Stallman
2024-08-04 11:03                   ` Emanuel Berg
2024-08-04  5:42             ` Emanuel Berg
2024-08-04  5:52               ` Eli Zaretskii
2024-08-04  7:17           ` Uwe Brauer via Emacs development discussions.
2024-08-04  9:30             ` Emanuel Berg
2024-08-04  2:05     ` Richard Stallman
2024-08-07 15:36       ` Björn Bidar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6c0stl9.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.