--- ispell.el.orig 2007-06-19 15:04:13.000000000 +0200 +++ ispell.el 2007-06-19 15:04:37.000000000 +0200 @@ -1050,7 +1050,8 @@ '(menu-item "Change Dictionary..." ispell-change-dictionary :help "Supply explicit dictionary file name")) (define-key ispell-menu-map [ispell-kill-ispell] - '(menu-item "Kill Process" ispell-kill-ispell + '(menu-item "Kill Process" + (lambda () (interactive) (ispell-kill-ispell nil 'clear)) :enable (and (boundp 'ispell-process) ispell-process (eq (ispell-process-status) 'run)) :help "Terminate Ispell subprocess")) @@ -1132,7 +1133,7 @@ ["Continue Check" ispell-continue t] ["Complete Word Frag"ispell-complete-word-interior-frag t] ["Complete Word" ispell-complete-word t] - ["Kill Process" ispell-kill-ispell t] + ["Kill Process" ispell-kill-ispell t 'clear] ["Customize..." (customize-group 'ispell) t] ;; flyspell-mode may not be bound... ;;["flyspell" flyspell-mode @@ -1397,6 +1398,11 @@ "Contains the buffer name if local word definitions were used. Ispell is then restarted because the local words could conflict.") +(defvar ispell-buffer-session-localwords nil + "List of words accepted for session in this buffer.") + +(make-variable-buffer-local 'ispell-buffer-session-localwords) + (defvar ispell-parser 'use-mode-name "*Indicates whether ispell should parse the current buffer as TeX Code. Special value `use-mode-name' tries to guess using the name of `major-mode'. @@ -1875,6 +1881,9 @@ nil) ((or (= char ?a) (= char ?A)) ; accept word without insert (ispell-send-string (concat "@" word "\n")) + (add-to-list 'ispell-buffer-session-localwords word) + (or ispell-buffer-local-name ; session localwords might conflict + (setq ispell-buffer-local-name (buffer-name))) (if (null ispell-pdict-modified-p) (setq ispell-pdict-modified-p (list ispell-pdict-modified-p))) @@ -2554,13 +2563,16 @@ (set-process-query-on-exit-flag ispell-process nil)))) ;;;###autoload -(defun ispell-kill-ispell (&optional no-error) +(defun ispell-kill-ispell (&optional no-error clear) "Kill current Ispell process (so that you may start a fresh one). -With NO-ERROR, just return non-nil if there was no Ispell running." +With NO-ERROR, just return non-nil if there was no Ispell running. +With CLEAR, buffer session localwords are cleaned." (interactive) ;; This hook is typically used by flyspell to flush some variables used ;; to optimize the common cases. (run-hooks 'ispell-kill-ispell-hook) + (if (or clear (interactive-p)) + (setq ispell-buffer-session-localwords nil)) (if (not (and ispell-process (eq (ispell-process-status) 'run))) (or no-error @@ -2622,6 +2634,7 @@ (setq ispell-local-dictionary-overridden t)) (error "Undefined dictionary: %s" dict)) (ispell-internal-change-dictionary) + (setq ispell-buffer-session-localwords nil) (message "%s Ispell dictionary set to %s" (if arg "Global" "Local") dict)))) @@ -3708,6 +3721,11 @@ ;; Actually start a new ispell process, because we need ;; to send commands now to specify the local words to it. (ispell-init-process) + (dolist (session-localword ispell-buffer-session-localwords) + (ispell-send-string (concat "@" session-localword "\n"))) + (or ispell-buffer-local-name + (if ispell-buffer-session-localwords + (setq ispell-buffer-local-name (buffer-name)))) (save-excursion (goto-char (point-min)) (while (search-forward ispell-words-keyword nil t)