From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Agustin Martin Newsgroups: gmane.emacs.devel Subject: Re: ispell.el, flyspell.el: better ispell/aspell switching Date: Thu, 17 Apr 2008 19:56:37 +0200 Message-ID: <20080417175637.GA4277@agmartin.aq.upm.es> References: <20080404120217.GA7503@agmartin.aq.upm.es> <20080416094933.GA4876@agmartin.aq.upm.es> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1208457370 25137 80.91.229.12 (17 Apr 2008 18:36:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Apr 2008 18:36:10 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 17 20:36:44 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JmYRn-0007Zk-3N for ged-emacs-devel@m.gmane.org; Thu, 17 Apr 2008 20:02:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmYR8-0005g4-Be for ged-emacs-devel@m.gmane.org; Thu, 17 Apr 2008 14:02:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JmYR4-0005fh-3F for emacs-devel@gnu.org; Thu, 17 Apr 2008 14:02:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JmYR3-0005fV-G6 for emacs-devel@gnu.org; Thu, 17 Apr 2008 14:02:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmYR3-0005fS-Dk for emacs-devel@gnu.org; Thu, 17 Apr 2008 14:02:13 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JmYR2-0001li-Sf for emacs-devel@gnu.org; Thu, 17 Apr 2008 14:02:13 -0400 Original-Received: from euler.ccupm.upm.es ([138.100.4.67] helo=smtp.upm.es) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JmYOl-000168-3P for emacs-devel@gnu.org; Thu, 17 Apr 2008 13:59:51 -0400 Original-Received: from mala.aq.upm.es (Agmartin.aq.upm.es [138.100.41.131]) by smtp.upm.es (8.13.8/8.13.8/euler-005) with ESMTP id m3HHubKF013077; Thu, 17 Apr 2008 19:56:37 +0200 Original-Received: by mala.aq.upm.es (Postfix, from userid 1000) id 9510830A2C; Thu, 17 Apr 2008 19:56:37 +0200 (CEST) Mail-Followup-To: emacs-devel@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-detected-kernel: by mx20.gnu.org: Linux 2.6 (newer, 3) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:95408 Archived-At: On Wed, Apr 16, 2008 at 11:21:33AM -0400, Stefan Monnier wrote: > > > ``distro-override-dicts-alist'' will override even dicts in > > ``found-dicts-alist'' (currently the alist of parsed aspell dicts and > > associated properties if spellchecker is aspell). Put here just in > > case is ever needed, but I am currently not using it in Debian. > > In what kind of circumstance would this be needed? I put this there just for completeness, but I do not think of a particular case where this is actually needed. The only thing I can think of is to work around a bad aspell autodetection for a dict, but in this case is the autodetection what needs a fix. Not a problem to remove it. > > ``distro-fallback-dicts-alist'' will just override (or complement if > > originally not present) initial ``ispell-dictionary-alist'' values > > (those that are in ``base-dicts'' in the function), so an entry can be > > fixed without patching ispell.el or waiting for a new emacs version > > be released. > > Can't this be done by: > 1 - remove autoloads on ispell-dictionary-alist-N > 2 - merge ispell-dictionary-alist-N into ispell-base-dictionary-alist > 3 - let Debian use after-eval-hook to adjust ispell-base-dictionary-alist (I guess you mean after-load-hook instead of after-eval-hook) Note that this will fail if spellchecker is switched after ispell.el is loaded. If so, ispell-base-dictionary-alist will be left with the old values, that might not match what the new available dicts (or new needs) for spellchecker. > > For instance, this is the relevant part in debian-ispell.el > > > --------------------------- > > (defun debian-ispell-initialize-dicts-alist () > > (setq distro-fallback-dicts-alist > > (if ispell-really-aspell > > debian-aspell-only-dictionary-alist > > debian-ispell-only-dictionary-alist))) > > Why does Debian need to do that? I.e. What kind of changes does > this effect? Why doesn't ispell.el get it right on its own? Note that we use the same FSF ispell.el and flyspell.el (with a number of compatibility patches and some known limitations) for emacs21, emacs22 and xemacs, so dictionaries are integrated in a similar way for all emacs flavours. Those are in a package different from the {x}emacs* that get installed along with the ispell or aspell dictionaries. The current way of doing things is that dictionary maintainers provide info that is used to build a dictionary-alist for the really installed dicts after the provided info. That makes debian-aspell-only-dictionary-alist for the aspell dicts and debian-ispell-only-dictionary-alist for the ispell dicts, and that is the info passed to the hook as distro-fallback-dicts-alist. One advantage of this is that there is no need to patch ispell.el each time a new dictionary package is added to Debian or some info is fixed, and the right dictionary-alists are automagically rebuilt every time a dictionary package is installed in the user box. Note that for emacs and aspell this would not be a big problem because of the autodetection, but is a problem for emacs and ispell as well as for xemacs. The other advantage is that we do not try to have ispell.el entries for every language having a dict, so original alist is smaller. > > (add-hook 'ispell-spellchecker-init-pre-hook > > 'debian-ispell-initialize-dicts-alist) > > > ``debian-aspell-only-dictionary-alist'' and > > ``debian-ispell-only-dictionary-alist'' being built after the info > > provided by the package maintainers. > > I must say that I generally prefer if there aren't any hooks and when we > don't use dynamic scoping, so I'm not thrilled about this code. > I understand that there might be a need for some hook, but I'd rather it > doesn't use dynamic scoping. Could you get away with a normal hook run > at the end of ispell-set-spellchecker-params, which would work by > modifying ispell-dictionary-alist? Disclaimer: Although I do some elisp hacking, I am far from being an elisp expert, so do not be surprised if I need some reading before understanding some details, or even finally do not fully understand them. Thanks in advance for your patience. I think the important point is at which time is this extra distro info to be processed if present (or of course if minimal support for this possible extra info belongs to pristine ispell.el or is something expected from distros). I think this is better done as currently, just in the middle, that is, after parsed aspell dicts, but before base-dicts. You do not know where things come from if things are done at the end, and if you need to check it you may end reusing half of the function. If the problem is about using a hook there, something like (when (fboundp 'ispell-distro-may-modify-dictionary-alist) (ispell-distro-may-modify-dictionary-alist)) will also do the work, although may look a bit ugly. If the problem is both hooks and dynamic scoping, something like (let ... (distro-fallback-dicts-alist (when (fboundp 'ispell-may-get-distro-fallback-dicts) (ispell-may-get-distro-fallback-dicts))) in (ispell-set-spellchecker-params), where (ispell-may-get-distro-fallback-dicts), if present, returns the alist, may work. Of course, is also possible to consider that this kind of distro things should not go in pristine ispell.el. > > Should I document the hook just in the function, or there is a better place? > > Add a defvar for the hook, where you can document it. Thanks > >> - (setq ispell-last-program-name ispell-program-name) should be done > >> right after checking if they're equal, not at the end of the function. > > > I usually do this kind of things after the work is done, so is only changed > > if nothing wrong happened. > > In case of an error, I'd rather avoid doing it > over-and-over-and-over-and-over ... also it's good to have it all in > a single place. But I won't insist. Is not bad to insist. As a matter of fact you have convinced me in this case. I usually prefer the other way, so errors are evident and noisy, but here most error-possible things are condition-case protected, so there would be no noise, just extra computing work for no good reason. Thanks a lot for your feedback, Regards, -- Agustin