unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Agustin Martin <agustin.martin@hispalinux.es>
Subject: Re: {ispell,flyspell}.el and coexistence of ispell and aspell
Date: Fri, 6 Oct 2006 12:19:51 +0200	[thread overview]
Message-ID: <20061006101951.GA4583@agmartin.aq.upm.es> (raw)
In-Reply-To: <E1GU9kp-0000D9-C6@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1791 bytes --]

On Sun, Oct 01, 2006 at 06:25:47PM -0400, Richard Stallman wrote:
> It looks good at first read, but I don't have a printer and I find
> it hard to really study it.  Anyway, since this is to support
> a peculiar mode of operation, let's put it off until after
> the release.

OK, 

I am attaching ispell.el patch with fixed docstrings and re-attaching
flyspell patch (small). I am also adding proposed changelog entries, so
everything is kept in the same mail and can be later retrieved after the
release.

In the meantime comments are welcome.

--------------------------------------------------------
flyspell.el:
(flyspell-large-region), (flyspell-mode)
   Call (ispell-initialize-program-params) instead of (ispell-check-version)
   and (ispell-maybe-find-aspell-dictionaries)

ispell.el:
(ispell-initialize-program-params)
   New function. Set value for ispell-dictionary-alist to the base or the
   aspell one as appropriate. Kill ispell process if ispell-program-name is
   changed.
(ispell-last-program-name) 
   Used by the above function.
(ispell-base-dictionary-alist)
   Formerly (ispell-dictionary-alist) 
(ispell-aspell-dictionary-alist)
   New alist for aspell specific values
(ispell-dictionary-alist)
   Set to (ispell-base-dictionary-alist) or (ispell-aspell-dictionary-alist)
   from (ispell-initialize-program-params)
(ispell-have-aspell-dictionaries), (ispell-maybe-find-aspell-dictionaries)
   Removed, obsolete
(ispell-find-aspell-dictionaries)
   Modified to use (ispell-base-dictionary-alist) and set
   (ispell-aspell-dictionary-alist)
(ispell-valid-dictionary-list), (ispell-word), (ispell-region)
   Use (ispell-initialize-program-params) instead of
   (ispell-maybe-find-aspell-dictionaries)
--------------------------------------------------------

-- 
Agustin

[-- Attachment #2: flyspell.el_ispell-initialize-program-params.diff --]
[-- Type: text/plain, Size: 836 bytes --]

--- flyspell.el.orig	2006-09-14 14:57:12.000000000 +0200
+++ flyspell.el	2006-09-14 14:57:26.000000000 +0200
@@ -556,7 +556,7 @@
 ;;*---------------------------------------------------------------------*/
 (defun flyspell-mode-on ()
   "Turn Flyspell mode on.  Do not use this; use `flyspell-mode' instead."
-  (ispell-maybe-find-aspell-dictionaries)
+  (ispell-initialize-program-params)
   (setq ispell-highlight-face 'flyspell-incorrect)
   ;; local dictionaries setup
   (or ispell-local-dictionary ispell-dictionary
@@ -1476,7 +1476,7 @@
     ;; this is done, we can start checking...
     (if flyspell-issue-message-flag (message "Checking region..."))
     (set-buffer curbuf)
-    (ispell-check-version)
+    (ispell-initialize-program-params)
     (let ((c (apply 'call-process-region beg
 		    end
 		    ispell-program-name

[-- Attachment #3: ispell.el_ispell-initialize-program-params.diff2 --]
[-- Type: text/plain, Size: 5674 bytes --]

--- ispell.el.orig	2006-09-14 14:59:04.000000000 +0200
+++ ispell.el	2006-10-04 11:08:08.000000000 +0200
@@ -659,11 +659,11 @@
 
 
 ;;;###autoload
-(defvar ispell-dictionary-alist
+(defvar ispell-base-dictionary-alist
   (append ispell-dictionary-alist-1 ispell-dictionary-alist-2
 	  ispell-dictionary-alist-3 ispell-dictionary-alist-4
 	  ispell-dictionary-alist-5 ispell-dictionary-alist-6)
-  "An alist of dictionaries and their associated parameters.
+  "Base alist of dictionaries and their associated parameters.
 
 Each element of this list is also a list:
 
@@ -716,6 +716,14 @@
 contain the same character set as casechars and otherchars in the
 LANGUAGE.aff file \(e.g., english.aff\).")
 
+;;;###autoload
+(defvar ispell-dictionary-alist ispell-base-dictionary-alist
+  "Runtime alist of dictionaries and their associated parameters.
+This alist will be modified to match current spellchecker.")
+
+(defvar ispell-aspell-dictionary-alist nil
+  "Parsed alist of aspell dicts and their associated parameters.")
+
 (defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used
 
 (defvar ispell-aspell-supports-utf8 nil
@@ -725,8 +733,6 @@
 Earlier aspell versions do not consistently support UTF-8.  Handling
 this would require some extra guessing in `ispell-aspell-find-dictionary'.")
 
-
-
 ;;; **********************************************************************
 ;;; The following are used by ispell, and should not be changed.
 ;;; **********************************************************************
@@ -876,18 +882,29 @@
 
 ;; Make ispell.el work better with aspell.
 
-(defvar ispell-have-aspell-dictionaries nil
-  "Non-nil if we have queried Aspell for dictionaries at least once.")
+(defvar ispell-last-program-name nil
+  "`ispell-program-name' value used in last spellchecking command.")
 
-(defun ispell-maybe-find-aspell-dictionaries ()
-  "Find Aspell's dictionaries, unless already done."
-  (when (and (not ispell-have-aspell-dictionaries)
-	     (condition-case ()
-		 (progn (ispell-check-version) t)
+(defun ispell-initialize-program-params ( &optional force )
+  "Set right alist of dict params for current spellchecker.
+This will be run if not yet done or `ispell-program-name' is
+changed. FORCE will run this unconditionally"
+  (when (or (not (eq ispell-last-program-name ispell-program-name))
+	    force)
+    (ispell-kill-ispell t)
+    (if (and (condition-case ()
+		 (progn
+		   (setq ispell-library-directory (ispell-check-version))
+		   t)
 	       (error nil))
 	     ispell-really-aspell
 	     ispell-aspell-supports-utf8)
-    (ispell-find-aspell-dictionaries)))
+	(progn
+	  (if (not ispell-aspell-dictionary-alist)
+	      (ispell-find-aspell-dictionaries))
+	  (setq ispell-dictionary-alist ispell-aspell-dictionary-alist))
+      (setq ispell-dictionary-alist ispell-base-dictionary-alist))
+    (setq ispell-last-program-name ispell-program-name)))
 
 (defun ispell-find-aspell-dictionaries ()
   "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."
@@ -907,17 +924,16 @@
     (setq found (ispell-aspell-add-aliases found))
     ;; Merge into FOUND any elements from the standard ispell-dictionary-alist
     ;; which have no element in FOUND at all.    
-    (dolist (dict ispell-dictionary-alist)
+    (dolist (dict ispell-base-dictionary-alist)
       (unless (assoc (car dict) found)
 	(setq found (nconc found (list dict)))))
-    (setq ispell-dictionary-alist found)
+    (setq ispell-aspell-dictionary-alist found)
     ;; Add a default entry
-    (let* ((english-dict (assoc "en" ispell-dictionary-alist))
+    (let* ((english-dict (assoc "en" ispell-aspell-dictionary-alist))
 	   (default-dict
 	     (cons nil (or (cdr english-dict)
 			   (cdr (car ispell-dictionary-alist-1))))))
-      (push default-dict ispell-dictionary-alist))
-    (setq ispell-have-aspell-dictionaries t)))
+      (push default-dict ispell-aspell-dictionary-alist))))
 
 (defvar ispell-aspell-data-dir nil
   "Data directory of Aspell.")
@@ -1002,8 +1018,8 @@
 (defun ispell-valid-dictionary-list ()
   "Returns a list of valid dictionaries.
 The variable `ispell-library-directory' defines the library location."
-  ;; If Ispell is really Aspell, query it for the dictionary list.
-  (ispell-maybe-find-aspell-dictionaries)
+  ;; Make sure ispell program is initialized (right dicts lists, paths, ...)
+  (ispell-initialize-program-params)
   (let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist))
 	(dict-list (cons "default" nil))
 	name load-dict)
@@ -1582,7 +1598,7 @@
   (interactive (list ispell-following-word ispell-quietly current-prefix-arg))
   (if continue
       (ispell-continue)
-    (ispell-maybe-find-aspell-dictionaries)
+    (ispell-initialize-program-params)
     (ispell-accept-buffer-local-defs)	; use the correct dictionary
     (let ((cursor-location (point))	; retain cursor location
 	  (word (ispell-get-word following))
@@ -2600,6 +2616,7 @@
 Without a prefix arg, set it \"locally\", just for this buffer.
 
 By just answering RET you can find out what the current dictionary is."
+  (ispell-initialize-program-params)
   (interactive
    (list (completing-read
 	  "Use new dictionary (RET for current, SPC to complete): "
@@ -2656,7 +2673,7 @@
 Return nil if spell session is quit,
  otherwise returns shift offset amount for last line processed."
   (interactive "r")			; Don't flag errors on read-only bufs.
-  (ispell-maybe-find-aspell-dictionaries)
+  (ispell-initialize-program-params)
   (if (not recheckp)
       (ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc.
   (let ((skip-region-start (make-marker))

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

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

      reply	other threads:[~2006-10-06 10:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-28 10:06 {ispell,flyspell}.el and coexistence of ispell and aspell Agustin Martin
2006-10-01 22:25 ` Richard Stallman
2006-10-06 10:19   ` Agustin Martin [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=20061006101951.GA4583@agmartin.aq.upm.es \
    --to=agustin.martin@hispalinux.es \
    /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 public inbox

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

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).