diff options
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 167 |
2 files changed, 102 insertions, 73 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bee82633f39..3c891027be5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-09-02 Agustín Martín <agustin.martin@hispalinux.es> | ||
| 2 | |||
| 3 | * textmodes/ispell.el (ispell-init-process): Use "~/" as | ||
| 4 | `default-directory' unless using Ispell per-directory personal | ||
| 5 | dictionaries and not in a mini-buffer under XEmacs. | ||
| 6 | (kill-buffer-hook): Do not kill ispell process on exit when | ||
| 7 | `ispell-process-directory' is "~/". (Bug#6143) | ||
| 8 | |||
| 1 | 2010-09-02 Jan Djärv <jan.h.d@swipnet.se> | 9 | 2010-09-02 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 10 | ||
| 3 | * simple.el (kill-new): Call interprogram-cut-function with only | 11 | * simple.el (kill-new): Call interprogram-cut-function with only |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index ad591eb0e7f..64253593a79 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -2622,79 +2622,98 @@ Keeps argument list for future ispell invocations for no async support." | |||
| 2622 | t))) | 2622 | t))) |
| 2623 | 2623 | ||
| 2624 | 2624 | ||
| 2625 | |||
| 2626 | (defun ispell-init-process () | 2625 | (defun ispell-init-process () |
| 2627 | "Check status of Ispell process and start if necessary." | 2626 | "Check status of Ispell process and start if necessary." |
| 2628 | (if (and ispell-process | 2627 | (let* (;; Basename of dictionary used by the spell-checker |
| 2629 | (eq (ispell-process-status) 'run) | 2628 | (dict-bname (or (car (cdr (member "-d" (ispell-get-ispell-args)))) |
| 2630 | ;; Unless we are using an explicit personal dictionary, | 2629 | ispell-current-dictionary)) |
| 2631 | ;; ensure we're in the same default directory! | 2630 | ;; Use "~/" as default-directory unless using Ispell with per-dir |
| 2632 | ;; Restart check for personal dictionary is done in | 2631 | ;; personal dictionaries and not in a minibuffer under XEmacs |
| 2633 | ;; `ispell-internal-change-dictionary', called from `ispell-buffer-local-dict' | 2632 | (default-directory |
| 2634 | (or (or ispell-local-pdict ispell-personal-dictionary) | 2633 | (if (or ispell-really-aspell |
| 2635 | (equal ispell-process-directory (expand-file-name default-directory)))) | 2634 | ispell-really-hunspell |
| 2636 | (setq ispell-filter nil ispell-filter-continue nil) | 2635 | ;; Protect against bad default-directory |
| 2637 | ;; may need to restart to select new personal dictionary. | 2636 | (not (and (file-directory-p default-directory) |
| 2638 | (ispell-kill-ispell t) | 2637 | (file-readable-p default-directory))) |
| 2639 | (message "Starting new Ispell process [%s] ..." | 2638 | ;; Ispell and per-dir personal dicts available |
| 2640 | (or ispell-local-dictionary ispell-dictionary "default")) | 2639 | (not (or (file-readable-p (concat default-directory |
| 2641 | (sit-for 0) | 2640 | ".ispell_words")) |
| 2642 | (setq ispell-library-directory (ispell-check-version) | 2641 | (file-readable-p (concat default-directory |
| 2643 | ispell-process (ispell-start-process) | 2642 | ".ispell_" |
| 2644 | ispell-filter nil | 2643 | (or dict-bname |
| 2645 | ispell-filter-continue nil) | 2644 | "default"))))) |
| 2646 | ;; When spellchecking minibuffer contents, make sure ispell process | 2645 | ;; Ispell, in a minibuffer, and XEmacs |
| 2647 | ;; is not restarted every time the minibuffer is killed. | 2646 | (and (window-minibuffer-p) |
| 2648 | (if (window-minibuffer-p) | 2647 | (not (fboundp 'minibuffer-selected-window)))) |
| 2649 | (if (fboundp 'minibuffer-selected-window) | 2648 | (expand-file-name "~/") |
| 2650 | ;; Assign ispell process to parent buffer | 2649 | (expand-file-name default-directory)))) |
| 2651 | (setq ispell-process-directory (expand-file-name default-directory) | 2650 | ;; Check if process needs restart |
| 2652 | ispell-process-buffer-name (window-buffer (minibuffer-selected-window))) | 2651 | (if (and ispell-process |
| 2653 | ;; Force `ispell-process-directory' to $HOME and use a dummy name | 2652 | (eq (ispell-process-status) 'run) |
| 2654 | (setq ispell-process-directory (expand-file-name "~/") | 2653 | ;; Unless we are using an explicit personal dictionary, |
| 2655 | ispell-process-buffer-name " * Minibuffer-has-spellcheck-enabled")) | 2654 | ;; ensure we're in the same default directory! |
| 2656 | ;; Not in a minibuffer | 2655 | ;; Restart check for personal dictionary is done in |
| 2657 | (setq ispell-process-directory (expand-file-name default-directory) | 2656 | ;; `ispell-internal-change-dictionary', called from `ispell-buffer-local-dict' |
| 2658 | ispell-process-buffer-name (buffer-name))) | 2657 | (or (or ispell-local-pdict ispell-personal-dictionary) |
| 2659 | (if ispell-async-processp | 2658 | (equal ispell-process-directory default-directory))) |
| 2660 | (set-process-filter ispell-process 'ispell-filter)) | 2659 | (setq ispell-filter nil ispell-filter-continue nil) |
| 2661 | ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs | 2660 | ;; may need to restart to select new personal dictionary. |
| 2662 | (if (and (or (featurep 'xemacs) | 2661 | (ispell-kill-ispell t) |
| 2663 | (and (boundp 'enable-multibyte-characters) | 2662 | (message "Starting new Ispell process [%s] ..." |
| 2664 | enable-multibyte-characters)) | 2663 | (or ispell-local-dictionary ispell-dictionary "default")) |
| 2665 | (fboundp 'set-process-coding-system)) | 2664 | (sit-for 0) |
| 2666 | (set-process-coding-system ispell-process (ispell-get-coding-system) | 2665 | (setq ispell-library-directory (ispell-check-version) |
| 2667 | (ispell-get-coding-system))) | 2666 | ispell-process (ispell-start-process) |
| 2668 | ;; Get version ID line | 2667 | ispell-filter nil |
| 2669 | (ispell-accept-output 3) | 2668 | ispell-filter-continue nil |
| 2670 | ;; get more output if filter empty? | 2669 | ispell-process-directory default-directory) |
| 2671 | (if (null ispell-filter) (ispell-accept-output 3)) | 2670 | ;; When spellchecking minibuffer contents, assign ispell process to parent |
| 2672 | (cond ((null ispell-filter) | 2671 | ;; buffer if known (not known for XEmacs). Use (buffer-name) otherwise. |
| 2673 | (error "%s did not output version line" ispell-program-name)) | 2672 | (setq ispell-process-buffer-name |
| 2674 | ((and | 2673 | (if (and (window-minibuffer-p) |
| 2675 | (stringp (car ispell-filter)) | 2674 | (fboundp 'minibuffer-selected-window)) ;; Not XEmacs |
| 2676 | (if (string-match "warning: " (car ispell-filter)) | 2675 | (window-buffer (minibuffer-selected-window)) |
| 2677 | (progn | 2676 | (buffer-name))) |
| 2678 | (ispell-accept-output 3) ; was warn msg. | 2677 | |
| 2679 | (stringp (car ispell-filter))) | 2678 | (if ispell-async-processp |
| 2680 | (null (cdr ispell-filter))) | 2679 | (set-process-filter ispell-process 'ispell-filter)) |
| 2681 | (string-match "^@(#) " (car ispell-filter))) | 2680 | ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs |
| 2682 | ;; got the version line as expected (we already know it's the right | 2681 | (if (and (or (featurep 'xemacs) |
| 2683 | ;; version, so don't bother checking again.) | 2682 | (and (boundp 'enable-multibyte-characters) |
| 2684 | nil) | 2683 | enable-multibyte-characters)) |
| 2685 | (t | 2684 | (fboundp 'set-process-coding-system)) |
| 2686 | ;; Otherwise, it must be an error message. Show the user. | 2685 | (set-process-coding-system ispell-process (ispell-get-coding-system) |
| 2687 | ;; But first wait to see if some more output is going to arrive. | 2686 | (ispell-get-coding-system))) |
| 2688 | ;; Otherwise we get cool errors like "Can't open ". | 2687 | ;; Get version ID line |
| 2689 | (sleep-for 1) | 2688 | (ispell-accept-output 3) |
| 2690 | (ispell-accept-output 3) | 2689 | ;; get more output if filter empty? |
| 2691 | (error "%s" (mapconcat 'identity ispell-filter "\n")))) | 2690 | (if (null ispell-filter) (ispell-accept-output 3)) |
| 2692 | (setq ispell-filter nil) ; Discard version ID line | 2691 | (cond ((null ispell-filter) |
| 2693 | (let ((extended-char-mode (ispell-get-extended-character-mode))) | 2692 | (error "%s did not output version line" ispell-program-name)) |
| 2694 | (if extended-char-mode ; ~ extended character mode | 2693 | ((and |
| 2695 | (ispell-send-string (concat extended-char-mode "\n")))) | 2694 | (stringp (car ispell-filter)) |
| 2696 | (if ispell-async-processp | 2695 | (if (string-match "warning: " (car ispell-filter)) |
| 2697 | (set-process-query-on-exit-flag ispell-process nil)))) | 2696 | (progn |
| 2697 | (ispell-accept-output 3) ; was warn msg. | ||
| 2698 | (stringp (car ispell-filter))) | ||
| 2699 | (null (cdr ispell-filter))) | ||
| 2700 | (string-match "^@(#) " (car ispell-filter))) | ||
| 2701 | ;; got the version line as expected (we already know it's the right | ||
| 2702 | ;; version, so don't bother checking again.) | ||
| 2703 | nil) | ||
| 2704 | (t | ||
| 2705 | ;; Otherwise, it must be an error message. Show the user. | ||
| 2706 | ;; But first wait to see if some more output is going to arrive. | ||
| 2707 | ;; Otherwise we get cool errors like "Can't open ". | ||
| 2708 | (sleep-for 1) | ||
| 2709 | (ispell-accept-output 3) | ||
| 2710 | (error "%s" (mapconcat 'identity ispell-filter "\n")))) | ||
| 2711 | (setq ispell-filter nil) ; Discard version ID line | ||
| 2712 | (let ((extended-char-mode (ispell-get-extended-character-mode))) | ||
| 2713 | (if extended-char-mode ; ~ extended character mode | ||
| 2714 | (ispell-send-string (concat extended-char-mode "\n")))) | ||
| 2715 | (if ispell-async-processp | ||
| 2716 | (set-process-query-on-exit-flag ispell-process nil))))) | ||
| 2698 | 2717 | ||
| 2699 | ;;;###autoload | 2718 | ;;;###autoload |
| 2700 | (defun ispell-kill-ispell (&optional no-error) | 2719 | (defun ispell-kill-ispell (&optional no-error) |
| @@ -2721,10 +2740,12 @@ With NO-ERROR, just return non-nil if there was no Ispell running." | |||
| 2721 | (message "Ispell process killed") | 2740 | (message "Ispell process killed") |
| 2722 | nil)) | 2741 | nil)) |
| 2723 | 2742 | ||
| 2724 | ;; Kill ispell process when killing its associated buffer | 2743 | ;; Kill ispell process when killing its associated buffer if using Ispell |
| 2744 | ;; per-directory personal dictionaries. | ||
| 2725 | (add-hook 'kill-buffer-hook | 2745 | (add-hook 'kill-buffer-hook |
| 2726 | '(lambda () | 2746 | '(lambda () |
| 2727 | (if (equal ispell-process-buffer-name (buffer-name)) | 2747 | (if (and (not (equal ispell-process-directory (expand-file-name "~/"))) |
| 2748 | (equal ispell-process-buffer-name (buffer-name))) | ||
| 2728 | (ispell-kill-ispell t)))) | 2749 | (ispell-kill-ispell t)))) |
| 2729 | 2750 | ||
| 2730 | ;;; ispell-change-dictionary is set in some people's hooks. Maybe this should | 2751 | ;;; ispell-change-dictionary is set in some people's hooks. Maybe this should |