Subject: bug#6143: ispell killing still not fixed

From: Agustin Martin <[email-masked]>
Date: Thu, 24 Jun 2010 17:23:45 +0200

On Thu, Jun 24, 2010 at 10:43:09PM +0800, [email-masked] wrote:
> AM> Has this fixed the over and over ispell process restart?
> 
> No. Anyway, as it is hard to detect just what is causing the problem,
> can we just have a flag, e.g., (setq ispell-never-kill 't) so that once
> ispell is started, it is never killed until emacs quits. And thus will
> be detected too, so no second ispell will be started.

I tend to disagree here (but have good news),

ispell process should not be restarted unless needed. And if needed should
be restarted. Other behavior may make more harm than good and hide
underlying problems.

The good news are that seems I found the underlying problem (at least for
the single extra ispell restart). Directory value, being the same, was 
sometimes set with unexpanded `~' and sometimes with it expanded, so they 
looked different to the comparison operator. 

I am testing attached patch that should make the expanded version to be
used everywhere. I am testing it along with a dirty hack in .emacs

(setq ispell-local-dictionary "american")
(load "ispell")
(setq ispell-program-name "aspell")
(ispell-set-spellchecker-params)
(ispell-start-process)

that should start an ispell process. With the attached changes at least
extra restart seems to be fixed.

If I see no further problems I will commit changes soon, so you can test
them in your box.

Thanks for your feedback,

-- 
Agustin
--- ispell.el.orig	2010-06-24 16:57:52.000000000 +0200
+++ ispell.el	2010-06-24 17:02:22.000000000 +0200
@@ -2622,7 +2622,7 @@
 	   ;; Restart check for personal dictionary is done in
 	   ;; `ispell-internal-change-dictionary', called from `ispell-buffer-local-dict'
 	   (or (or ispell-local-pdict ispell-personal-dictionary)
-	       (equal ispell-process-directory default-directory)))
+	       (equal ispell-process-directory (expand-file-name default-directory))))
       (setq ispell-filter nil ispell-filter-continue nil)
     ;; may need to restart to select new personal dictionary.
     (ispell-kill-ispell t)
@@ -2638,13 +2638,13 @@
     (if (window-minibuffer-p)
 	(if (fboundp 'minibuffer-selected-window)
 	    ;; Assign ispell process to parent buffer
-	    (setq ispell-process-directory default-directory
+	    (setq ispell-process-directory (expand-file-name default-directory)
 		  ispell-process-buffer-name (window-buffer (minibuffer-selected-window)))
 	  ;; Force `ispell-process-directory' to $HOME and use a dummy name
 	  (setq ispell-process-directory (expand-file-name "~/")
 		ispell-process-buffer-name " * Minibuffer-has-spellcheck-enabled"))
       ;; Not in a minibuffer
-      (setq ispell-process-directory default-directory
+      (setq ispell-process-directory (expand-file-name default-directory)
 	    ispell-process-buffer-name (buffer-name)))
     (if ispell-async-processp
 	(set-process-filter ispell-process 'ispell-filter))