unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Agustin Martin <agustin.martin@hispalinux.es>
To: 13019@debbugs.gnu.org
Cc: Akim Demaille <akim.demaille@gmail.com>
Subject: bug#13019: 24.2; ispell: use of local ispell-personal-dictionary
Date: Fri, 30 Nov 2012 18:59:47 +0100	[thread overview]
Message-ID: <20121130175947.GA17506@agmartin.aq.upm.es> (raw)
In-Reply-To: <20121130171156.GA5521@agmartin.aq.upm.es>

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

On Fri, Nov 30, 2012 at 06:11:56PM +0100, Agustin Martin wrote:
> On Wed, Nov 28, 2012 at 04:16:53PM -0500, Glenn Morris wrote:
> > Akim Demaille wrote:
> > 
> > > I have recently upgraded my Emacs from 22.2.1 to 24.2.1, and there is
> > > a feature I lost: I could use ispell-personal-dictionary to specify a
> > > per-document *local* (i.e., relative to the directory of the file)
> > > dictionary.
> > 
> > Presumably due to 2010-09-02 changes to ispell-init-process for
> > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6143
> > 
> > Perhaps a file-name-absolute-p check for various variables could be
> > file-local could be added to that.
> > 
> > > | %%% ispell-dictionary: "american"
> > > | %%% ispell-personal-dictionary: "../en.dict"
> 
> Actual problem happens in `ispell-start-process' where the string to be
> passed to the spellchecker as personal dictionary is expanded,
> 
> (if ispell-current-personal-dictionary ; Use specified pers dict.
>     (list "-p" (expand-file-name ispell-current-personal-dictionary)))
> 
> and is indeed affected by the changes in `default-dictionary' coming from
> `ispell-init-process`.
> 
> I think the only reason for that `expand-file-name' is the tilde expansion
> in non-UNIX systems. In UNIX systems tilde can be explicitly passed. 
> Not sure if the directory {forward,back}slash is also related to this.
> 
> I am thinking about expanding `ispell-current-personal-dictionary' string
> only if it contains a tilde prefix.

I am now playing with something different, preserve original value of
`default-directory' in `current-ispell-directory' variable and expand 
personal dictionary after it if no absolute path or tilde is used. 

I think this is a better approach, see attached patch.

Let me test this a bit more before committing. Feel free to test it too.

-- 
Agustin

[-- Attachment #2: ispell.el_honour-personal-dictionary-path.diff --]
[-- Type: text/x-diff, Size: 2226 bytes --]

--- ispell.el.orig	2012-11-30 17:07:14.641701686 +0100
+++ ispell.el	2012-11-30 18:50:08.725283277 +0100
@@ -2669,7 +2669,8 @@
            orig-args
            (if ispell-current-personal-dictionary ; Use specified pers dict.
                (list "-p"
-                     (expand-file-name ispell-current-personal-dictionary)))
+                     (expand-file-name ispell-current-personal-dictionary
+				       current-ispell-directory)))
            ;; If we are using recent aspell or hunspell, make sure we use the
            ;; right encoding for communication. ispell or older aspell/hunspell
            ;; does not support this.
@@ -2706,18 +2707,21 @@
   (let* (;; Basename of dictionary used by the spell-checker
 	 (dict-bname (or (car (cdr (member "-d" (ispell-get-ispell-args))))
 			 ispell-current-dictionary))
+	 ;; The directory where process was started.
+	 (current-ispell-directory default-directory)
+	 ;; The default directory for the process.
 	 ;; Use "~/" as default-directory unless using Ispell with per-dir
 	 ;; personal dictionaries and not in a minibuffer under XEmacs
 	 (default-directory
 	   (if (or ispell-really-aspell
 		   ispell-really-hunspell
 		   ;; Protect against bad default-directory
-		   (not (and (file-directory-p default-directory)
-			     (file-readable-p default-directory)))
+                   (not (and (file-directory-p current-ispell-directory)
+                             (file-readable-p current-ispell-directory)))
 		   ;; Ispell and per-dir personal dicts available
-		   (not (or (file-readable-p (concat default-directory
+		   (not (or (file-readable-p (concat current-ispell-directory
 						     ".ispell_words"))
-			    (file-readable-p (concat default-directory
+			    (file-readable-p (concat current-ispell-directory
 						     ".ispell_"
 						     (or dict-bname
 							 "default")))))
@@ -2725,7 +2729,7 @@
 		   (and (window-minibuffer-p)
 			(not (fboundp 'minibuffer-selected-window))))
 	       (expand-file-name "~/")
-	     (expand-file-name default-directory))))
+	     (expand-file-name current-ispell-directory))))
     ;; Check if process needs restart
     (if (and ispell-process
 	     (eq (ispell-process-status) 'run)

  reply	other threads:[~2012-11-30 17:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 10:16 bug#13019: 24.2; ispell: use of local ispell-personal-dictionary Akim Demaille
2012-11-28 21:16 ` Glenn Morris
     [not found] ` <11368004.8066.1354137417393.JavaMail.root@mx1-new.spamfiltro.es>
2012-11-30 17:11   ` Agustin Martin
2012-11-30 17:59     ` Agustin Martin [this message]
2012-11-30 18:49       ` Stefan Monnier
2012-12-03 16:59         ` Agustin Martin
2012-12-03 17:35           ` Agustin Martin
2012-11-30 18:53     ` Eli Zaretskii

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=20121130175947.GA17506@agmartin.aq.upm.es \
    --to=agustin.martin@hispalinux.es \
    --cc=13019@debbugs.gnu.org \
    --cc=akim.demaille@gmail.com \
    /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).