diff options
| author | Richard M. Stallman | 2005-01-31 11:54:36 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-01-31 11:54:36 +0000 |
| commit | a6e7a34bef67e5e41932fb19e98f5f51e21f6fb8 (patch) | |
| tree | efc123a40314c6096fb1dc20d44da6c3d6ca1c5e | |
| parent | 84d77b1eb3a117e81a387fa829fe294e392fac6f (diff) | |
| download | emacs-a6e7a34bef67e5e41932fb19e98f5f51e21f6fb8.tar.gz emacs-a6e7a34bef67e5e41932fb19e98f5f51e21f6fb8.zip | |
(ispell-local-dictionary-overridden): New var.
(ispell-local-dictionary): Doc fix.
(ispell-dictionary-alist): Don't include ispell-local-dictionary-alist.
Don't reinitialize at run time. Don't defcustom.
All uses changed to append ispell-local-dictionary-alist,
or else check it first.
(ispell-current-dictionary): New variable for dictionary in use.
(ispell-dictionary): Now used only for global default.
(ispell-start-process): Set ispell-current-dictionary,
not ispell-dictionary.
(ispell-change-dictionary): Use this only for setting
user preferences.
(ispell-internal-change-dictionary): New function
to change the current dictionary in use.
(ispell-region, ispell-process-line, ispell-buffer-local-dict):
Use ispell-current-dictionary.
Handle ispell-local-dictionary-overridden.
(ispell-buffer-local-dict): Call ispell-internal-change-dictionary.
| -rw-r--r-- | lisp/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 201 |
2 files changed, 111 insertions, 111 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 16bf2e91af3..fcbfa0c2d4a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2005-01-31 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * textmodes/ispell.el (ispell-local-dictionary-overridden): New var. | ||
| 4 | (ispell-local-dictionary): Doc fix. | ||
| 5 | (ispell-dictionary-alist): Don't include ispell-local-dictionary-alist. | ||
| 6 | Don't reinitialize at run time. Don't defcustom. | ||
| 7 | All uses changed to append ispell-local-dictionary-alist, | ||
| 8 | or check it first. | ||
| 9 | (ispell-current-dictionary): New variable for dictionary in use. | ||
| 10 | (ispell-dictionary): Now used only for global default. | ||
| 11 | (ispell-start-process): Set ispell-current-dictionary, | ||
| 12 | not ispell-dictionary. | ||
| 13 | (ispell-change-dictionary): Use this only for setting | ||
| 14 | user preferences. | ||
| 15 | (ispell-internal-change-dictionary): New function | ||
| 16 | to change the current dictionary in use. | ||
| 17 | (ispell-region, ispell-process-line, ispell-buffer-local-dict): | ||
| 18 | Use ispell-current-dictionary. | ||
| 19 | Handle ispell-local-dictionary-overridden. | ||
| 20 | (ispell-buffer-local-dict): Call ispell-internal-change-dictionary. | ||
| 21 | |||
| 1 | 2005-01-31 Jay Belanger <belanger@truman.edu> | 22 | 2005-01-31 Jay Belanger <belanger@truman.edu> |
| 2 | 23 | ||
| 3 | * calc/calc-aent.el (math-read-token): Add support for LaTeX. | 24 | * calc/calc-aent.el (math-read-token): Add support for LaTeX. |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 11e81f0ad70..c403422801f 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -44,8 +44,8 @@ | |||
| 44 | ;; country and language. | 44 | ;; country and language. |
| 45 | ;; Most dictionary changes should be made in this file so all users can | 45 | ;; Most dictionary changes should be made in this file so all users can |
| 46 | ;; enjoy them. Local or modified dictionaries are supported in your .emacs | 46 | ;; enjoy them. Local or modified dictionaries are supported in your .emacs |
| 47 | ;; file. Modify the variable `ispell-local-dictionary-alist' to include | 47 | ;; file. Use the variable `ispell-local-dictionary-alist' to specify |
| 48 | ;; these dictionaries, and they will be installed when ispell.el is loaded. | 48 | ;; your own dictionaries. |
| 49 | 49 | ||
| 50 | ;; Depending on the mail system you use, you may want to include these: | 50 | ;; Depending on the mail system you use, you may want to include these: |
| 51 | ;; (add-hook 'news-inews-hook 'ispell-message) | 51 | ;; (add-hook 'news-inews-hook 'ispell-message) |
| @@ -428,29 +428,27 @@ where DICTNAME is the name of your default dictionary." | |||
| 428 | :type 'boolean | 428 | :type 'boolean |
| 429 | :group 'ispell) | 429 | :group 'ispell) |
| 430 | 430 | ||
| 431 | ;;; This is the local dictionary to use. When nil the default dictionary will | 431 | (defvar ispell-local-dictionary-overridden nil |
| 432 | ;;; be used. Change set-default call to use a new default dictionary. | 432 | "Non-nil means the user has explicitly set this buffer's Ispell dictionary.") |
| 433 | (make-variable-buffer-local 'ispell-local-dictionary) | ||
| 434 | |||
| 433 | (defcustom ispell-local-dictionary nil | 435 | (defcustom ispell-local-dictionary nil |
| 434 | "If non-nil, the dictionary to be used for Ispell commands. | 436 | "If non-nil, the dictionary to be used for Ispell commands in this buffer. |
| 435 | The value must be a string dictionary name in `ispell-dictionary-alist'. | 437 | The value must be a string dictionary name, |
| 438 | or nil, which means use the global setting in `ispell-dictionary'. | ||
| 439 | Dictionary names are defined in `ispell-local-dictionary-alist' | ||
| 440 | and `ispell-dictionary-alist', | ||
| 436 | 441 | ||
| 437 | Setting `ispell-local-dictionary' to a value has the same effect as | 442 | Setting `ispell-local-dictionary' to a value has the same effect as |
| 438 | calling \\[ispell-change-dictionary] with that value. This variable | 443 | calling \\[ispell-change-dictionary] with that value. This variable |
| 439 | is automatically set when defined in the file with either | 444 | is automatically set when defined in the file with either |
| 440 | `ispell-dictionary-keyword' or the Local Variable syntax. | 445 | `ispell-dictionary-keyword' or the Local Variable syntax." |
| 441 | |||
| 442 | To create a non-standard default dictionary (not from `ispell-dictionary-alist') | ||
| 443 | call function `set-default' with the new dictionary name." | ||
| 444 | :type '(choice string | 446 | :type '(choice string |
| 445 | (const :tag "default" nil)) | 447 | (const :tag "default" nil)) |
| 446 | :group 'ispell) | 448 | :group 'ispell) |
| 447 | 449 | ||
| 448 | (make-variable-buffer-local 'ispell-local-dictionary) | 450 | (make-variable-buffer-local 'ispell-local-dictionary) |
| 449 | 451 | ||
| 450 | ;; Call this function set up the default dictionary if not English. | ||
| 451 | ;;(set-default 'ispell-local-dictionary nil) | ||
| 452 | |||
| 453 | |||
| 454 | (defcustom ispell-extra-args nil | 452 | (defcustom ispell-extra-args nil |
| 455 | "*If non-nil, a list of extra switches to pass to the Ispell program. | 453 | "*If non-nil, a list of extra switches to pass to the Ispell program. |
| 456 | For example, (\"-W\" \"3\") to cause it to accept all 1-3 character | 454 | For example, (\"-W\" \"3\") to cause it to accept all 1-3 character |
| @@ -473,17 +471,14 @@ buffer's major mode." | |||
| 473 | (make-variable-buffer-local 'ispell-skip-html) | 471 | (make-variable-buffer-local 'ispell-skip-html) |
| 474 | 472 | ||
| 475 | 473 | ||
| 476 | ;;; Define definitions here only for personal dictionaries. | ||
| 477 | ;;;###autoload | 474 | ;;;###autoload |
| 478 | (defcustom ispell-local-dictionary-alist nil | 475 | (defcustom ispell-local-dictionary-alist nil |
| 479 | "*Contains local or customized dictionary definitions. | 476 | "*List of local or customized dictionary definitions. |
| 477 | These can override the values in `ispell-dictionary-alist'. | ||
| 480 | 478 | ||
| 481 | These will override the values in `ispell-dictionary-alist'. | 479 | To make permanent changes to your dictionary definitions, you |
| 482 | 480 | will need to make your changes in this variable, save, and then | |
| 483 | Customization changes made to `ispell-dictionary-alist' will not operate | 481 | re-start emacs." |
| 484 | over emacs sessions. To make permanent changes to your dictionary | ||
| 485 | definitions, you will need to make your changes in this variable, save, | ||
| 486 | and then re-start emacs." | ||
| 487 | :type '(repeat (list (choice :tag "Dictionary" | 482 | :type '(repeat (list (choice :tag "Dictionary" |
| 488 | (string :tag "Dictionary name") | 483 | (string :tag "Dictionary name") |
| 489 | (const :tag "default" nil)) | 484 | (const :tag "default" nil)) |
| @@ -646,9 +641,8 @@ and then re-start emacs." | |||
| 646 | 641 | ||
| 647 | 642 | ||
| 648 | ;;;###autoload | 643 | ;;;###autoload |
| 649 | (defcustom ispell-dictionary-alist | 644 | (defvar ispell-dictionary-alist |
| 650 | (append ispell-local-dictionary-alist ; dictionary customizations | 645 | (append ispell-dictionary-alist-1 ispell-dictionary-alist-2 |
| 651 | ispell-dictionary-alist-1 ispell-dictionary-alist-2 | ||
| 652 | ispell-dictionary-alist-3 ispell-dictionary-alist-4 | 646 | ispell-dictionary-alist-3 ispell-dictionary-alist-4 |
| 653 | ispell-dictionary-alist-5 ispell-dictionary-alist-6) | 647 | ispell-dictionary-alist-5 ispell-dictionary-alist-6) |
| 654 | "An alist of dictionaries and their associated parameters. | 648 | "An alist of dictionaries and their associated parameters. |
| @@ -696,33 +690,7 @@ CHARACTER-SET used for languages with multibyte characters. | |||
| 696 | 690 | ||
| 697 | Note that the CASECHARS and OTHERCHARS slots of the alist should | 691 | Note that the CASECHARS and OTHERCHARS slots of the alist should |
| 698 | contain the same character set as casechars and otherchars in the | 692 | contain the same character set as casechars and otherchars in the |
| 699 | LANGUAGE.aff file \(e.g., english.aff\)." | 693 | LANGUAGE.aff file \(e.g., english.aff\).") |
| 700 | :type '(repeat (list (choice :tag "Dictionary" | ||
| 701 | (string :tag "Dictionary name") | ||
| 702 | (const :tag "default" nil)) | ||
| 703 | (regexp :tag "Case characters") | ||
| 704 | (regexp :tag "Non case characters") | ||
| 705 | (regexp :tag "Other characters") | ||
| 706 | (boolean :tag "Many other characters") | ||
| 707 | (repeat :tag "Ispell command line args" | ||
| 708 | (string :tag "Arg")) | ||
| 709 | (choice :tag "Extended character mode" | ||
| 710 | (const "~tex") (const "~plaintex") | ||
| 711 | (const "~nroff") (const "~list") | ||
| 712 | (const "~latin1") (const "~latin3") | ||
| 713 | (const :tag "default" nil)) | ||
| 714 | (choice :tag "Coding System" | ||
| 715 | (const iso-8859-1) | ||
| 716 | (const iso-8859-2) | ||
| 717 | (const koi8-r)))) | ||
| 718 | :group 'ispell) | ||
| 719 | |||
| 720 | ;;; update the dictionaries at load time | ||
| 721 | (setq ispell-dictionary-alist | ||
| 722 | (append ispell-local-dictionary-alist ; dictionary customizations | ||
| 723 | ispell-dictionary-alist-1 ispell-dictionary-alist-2 | ||
| 724 | ispell-dictionary-alist-3 ispell-dictionary-alist-4 | ||
| 725 | ispell-dictionary-alist-5 ispell-dictionary-alist-6)) | ||
| 726 | 694 | ||
| 727 | (defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used | 695 | (defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used |
| 728 | 696 | ||
| @@ -877,7 +845,7 @@ and added as a submenu of the \"Edit\" menu.") | |||
| 877 | (defun ispell-valid-dictionary-list () | 845 | (defun ispell-valid-dictionary-list () |
| 878 | "Returns a list of valid dictionaries. | 846 | "Returns a list of valid dictionaries. |
| 879 | The variable `ispell-library-directory' defines the library location." | 847 | The variable `ispell-library-directory' defines the library location." |
| 880 | (let ((dicts ispell-dictionary-alist) | 848 | (let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist)) |
| 881 | (dict-list (cons "default" nil)) | 849 | (dict-list (cons "default" nil)) |
| 882 | name load-dict) | 850 | name load-dict) |
| 883 | (dolist (dict dicts) | 851 | (dolist (dict dicts) |
| @@ -899,11 +867,12 @@ The variable `ispell-library-directory' defines the library location." | |||
| 899 | (setq dict-list (cons name dict-list)))) | 867 | (setq dict-list (cons name dict-list)))) |
| 900 | dict-list)) | 868 | dict-list)) |
| 901 | 869 | ||
| 902 | |||
| 903 | ;;;###autoload | 870 | ;;;###autoload |
| 904 | (if ispell-menu-map-needed | 871 | (if ispell-menu-map-needed |
| 905 | (let ((dicts (if (fboundp 'ispell-valid-dictionary-list) | 872 | (let ((dicts (if (fboundp 'ispell-valid-dictionary-list) |
| 906 | (ispell-valid-dictionary-list) | 873 | (ispell-valid-dictionary-list) |
| 874 | ;; This case is used in loaddefs.el | ||
| 875 | ;; since ispell-valid-dictionary-list isn't defined then. | ||
| 907 | (mapcar (lambda (x) (or (car x) "default")) | 876 | (mapcar (lambda (x) (or (car x) "default")) |
| 908 | ispell-dictionary-alist))) | 877 | ispell-dictionary-alist))) |
| 909 | (dict-map (make-sparse-keymap "Dictionaries"))) | 878 | (dict-map (make-sparse-keymap "Dictionaries"))) |
| @@ -1054,14 +1023,14 @@ The variable `ispell-library-directory' defines the library location." | |||
| 1054 | 1023 | ||
| 1055 | 1024 | ||
| 1056 | ;;; This variable contains the current dictionary being used if the ispell | 1025 | ;;; This variable contains the current dictionary being used if the ispell |
| 1057 | ;;; process is running. Otherwise it contains the global default. | 1026 | ;;; process is running. |
| 1058 | (defvar ispell-dictionary nil | 1027 | (defvar ispell-current-dictionary nil |
| 1059 | "The name of the current dictionary, or nil for the default. | 1028 | "The name of the current dictionary, or nil for the default. |
| 1060 | When `ispell-local-dictionary' is nil, `ispell-dictionary' is used to select | ||
| 1061 | the dictionary for new buffers. | ||
| 1062 | |||
| 1063 | This is passed to the ispell process using the `-d' switch and is | 1029 | This is passed to the ispell process using the `-d' switch and is |
| 1064 | used as key in `ispell-dictionary-alist' (which see).") | 1030 | used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.") |
| 1031 | |||
| 1032 | (defvar ispell-dictionary nil | ||
| 1033 | "Default dictionary to use if `ispell-local-dictionary' is nil.") | ||
| 1065 | 1034 | ||
| 1066 | (defun ispell-decode-string (str) | 1035 | (defun ispell-decode-string (str) |
| 1067 | "Decodes multibyte character strings. | 1036 | "Decodes multibyte character strings. |
| @@ -1097,7 +1066,9 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs." | |||
| 1097 | ;; regular expression matching. | 1066 | ;; regular expression matching. |
| 1098 | 1067 | ||
| 1099 | (defun ispell-get-decoded-string (n) | 1068 | (defun ispell-get-decoded-string (n) |
| 1100 | (let* ((slot (assoc ispell-dictionary ispell-dictionary-alist)) | 1069 | (let* ((slot (or |
| 1070 | (assoc ispell-current-dictionary ispell-local-dictionary-alist) | ||
| 1071 | (assoc ispell-current-dictionary ispell-dictionary-alist))) | ||
| 1101 | (str (nth n slot))) | 1072 | (str (nth n slot))) |
| 1102 | (when (and (> (length str) 0) | 1073 | (when (and (> (length str) 0) |
| 1103 | (not (multibyte-string-p str))) | 1074 | (not (multibyte-string-p str))) |
| @@ -1123,13 +1094,17 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs." | |||
| 1123 | (defun ispell-get-otherchars () | 1094 | (defun ispell-get-otherchars () |
| 1124 | (ispell-get-decoded-string 3)) | 1095 | (ispell-get-decoded-string 3)) |
| 1125 | (defun ispell-get-many-otherchars-p () | 1096 | (defun ispell-get-many-otherchars-p () |
| 1126 | (nth 4 (assoc ispell-dictionary ispell-dictionary-alist))) | 1097 | (nth 4 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist) |
| 1098 | (assoc ispell-current-dictionary ispell-dictionary-alist)))) | ||
| 1127 | (defun ispell-get-ispell-args () | 1099 | (defun ispell-get-ispell-args () |
| 1128 | (nth 5 (assoc ispell-dictionary ispell-dictionary-alist))) | 1100 | (nth 5 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist) |
| 1101 | (assoc ispell-current-dictionary ispell-dictionary-alist)))) | ||
| 1129 | (defun ispell-get-extended-character-mode () | 1102 | (defun ispell-get-extended-character-mode () |
| 1130 | (nth 6 (assoc ispell-dictionary ispell-dictionary-alist))) | 1103 | (nth 6 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist) |
| 1104 | (assoc ispell-current-dictionary ispell-dictionary-alist)))) | ||
| 1131 | (defun ispell-get-coding-system () | 1105 | (defun ispell-get-coding-system () |
| 1132 | (nth 7 (assoc ispell-dictionary ispell-dictionary-alist))) | 1106 | (nth 7 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist) |
| 1107 | (assoc ispell-current-dictionary ispell-dictionary-alist)))) | ||
| 1133 | 1108 | ||
| 1134 | 1109 | ||
| 1135 | (defvar ispell-pdict-modified-p nil | 1110 | (defvar ispell-pdict-modified-p nil |
| @@ -1181,8 +1156,9 @@ There can be multiple of these keywords in the file.") | |||
| 1181 | 1156 | ||
| 1182 | (defconst ispell-dictionary-keyword "Local IspellDict: " | 1157 | (defconst ispell-dictionary-keyword "Local IspellDict: " |
| 1183 | "The keyword for a local dictionary to use. | 1158 | "The keyword for a local dictionary to use. |
| 1184 | The keyword must be followed by a correct dictionary name in | 1159 | The keyword must be followed by a valid dictionary name, defined in |
| 1185 | `ispell-dictionary-alist'. When multiple occurrences exist, the last keyword | 1160 | `ispell-local-dictionary-alist' or `ispell-dictionary-alist'. |
| 1161 | When multiple occurrences exist, the last keyword | ||
| 1186 | definition is used.") | 1162 | definition is used.") |
| 1187 | 1163 | ||
| 1188 | (defconst ispell-pdict-keyword "Local IspellPersDict: " | 1164 | (defconst ispell-pdict-keyword "Local IspellPersDict: " |
| @@ -1439,7 +1415,8 @@ when called interactively, non-corrective messages are suppressed. | |||
| 1439 | With a prefix argument (or if CONTINUE is non-nil), | 1415 | With a prefix argument (or if CONTINUE is non-nil), |
| 1440 | resume interrupted spell-checking of a buffer or region. | 1416 | resume interrupted spell-checking of a buffer or region. |
| 1441 | 1417 | ||
| 1442 | Word syntax described by `ispell-dictionary-alist' (which see). | 1418 | Word syntax is controlled by the definition of the chosen dictionary, |
| 1419 | which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'. | ||
| 1443 | 1420 | ||
| 1444 | This will check or reload the dictionary. Use \\[ispell-change-dictionary] | 1421 | This will check or reload the dictionary. Use \\[ispell-change-dictionary] |
| 1445 | or \\[ispell-region] to update the Ispell process. | 1422 | or \\[ispell-region] to update the Ispell process. |
| @@ -1549,7 +1526,8 @@ is non-nil when called interactively, then the following word | |||
| 1549 | Optional second argument contains otherchars that can be included in word | 1526 | Optional second argument contains otherchars that can be included in word |
| 1550 | many times. | 1527 | many times. |
| 1551 | 1528 | ||
| 1552 | Word syntax described by `ispell-dictionary-alist' (which see)." | 1529 | Word syntax is controlled by the definition of the chosen dictionary, |
| 1530 | which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'." | ||
| 1553 | (let* ((ispell-casechars (ispell-get-casechars)) | 1531 | (let* ((ispell-casechars (ispell-get-casechars)) |
| 1554 | (ispell-not-casechars (ispell-get-not-casechars)) | 1532 | (ispell-not-casechars (ispell-get-not-casechars)) |
| 1555 | (ispell-otherchars (ispell-get-otherchars)) | 1533 | (ispell-otherchars (ispell-get-otherchars)) |
| @@ -2309,13 +2287,13 @@ When asynchronous processes are not supported, `run' is always returned." | |||
| 2309 | Keeps argument list for future ispell invocations for no async support." | 2287 | Keeps argument list for future ispell invocations for no async support." |
| 2310 | (let (args) | 2288 | (let (args) |
| 2311 | ;; Local dictionary becomes the global dictionary in use. | 2289 | ;; Local dictionary becomes the global dictionary in use. |
| 2312 | (if ispell-local-dictionary | 2290 | (setq ispell-current-dictionary |
| 2313 | (setq ispell-dictionary ispell-local-dictionary)) | 2291 | (or ispell-local-dictionary ispell-dictionary)) |
| 2314 | (setq args (ispell-get-ispell-args)) | 2292 | (setq args (ispell-get-ispell-args)) |
| 2315 | (if (and ispell-dictionary ; use specified dictionary | 2293 | (if (and ispell-current-dictionary ; use specified dictionary |
| 2316 | (not (member "-d" args))) ; only define if not overridden | 2294 | (not (member "-d" args))) ; only define if not overridden |
| 2317 | (setq args | 2295 | (setq args |
| 2318 | (append (list "-d" ispell-dictionary) args))) | 2296 | (append (list "-d" ispell-current-dictionary) args))) |
| 2319 | (if ispell-personal-dictionary ; use specified pers dict | 2297 | (if ispell-personal-dictionary ; use specified pers dict |
| 2320 | (setq args | 2298 | (setq args |
| 2321 | (append args | 2299 | (append args |
| @@ -2431,9 +2409,7 @@ With NO-ERROR, just return non-nil if there was no Ispell running." | |||
| 2431 | 2409 | ||
| 2432 | ;;;###autoload | 2410 | ;;;###autoload |
| 2433 | (defun ispell-change-dictionary (dict &optional arg) | 2411 | (defun ispell-change-dictionary (dict &optional arg) |
| 2434 | "Change `ispell-dictionary' (q.v.) to DICT and kill old Ispell process. | 2412 | "Change to dictionary DICT for Ispell. |
| 2435 | A new one will be started as soon as necessary. | ||
| 2436 | |||
| 2437 | By just answering RET you can find out what the current dictionary is. | 2413 | By just answering RET you can find out what the current dictionary is. |
| 2438 | 2414 | ||
| 2439 | With prefix argument, set the default dictionary." | 2415 | With prefix argument, set the default dictionary." |
| @@ -2441,39 +2417,42 @@ With prefix argument, set the default dictionary." | |||
| 2441 | (list (completing-read | 2417 | (list (completing-read |
| 2442 | "Use new dictionary (RET for current, SPC to complete): " | 2418 | "Use new dictionary (RET for current, SPC to complete): " |
| 2443 | (and (fboundp 'ispell-valid-dictionary-list) | 2419 | (and (fboundp 'ispell-valid-dictionary-list) |
| 2444 | (mapcar (lambda (x)(cons x nil)) (ispell-valid-dictionary-list))) | 2420 | (mapcar 'list (ispell-valid-dictionary-list))) |
| 2445 | nil t) | 2421 | nil t) |
| 2446 | current-prefix-arg)) | 2422 | current-prefix-arg)) |
| 2423 | (unless arg (ispell-accept-buffer-local-defs)) | ||
| 2447 | (if (equal dict "default") (setq dict nil)) | 2424 | (if (equal dict "default") (setq dict nil)) |
| 2448 | ;; This relies on completing-read's bug of returning "" for no match | 2425 | ;; This relies on completing-read's bug of returning "" for no match |
| 2449 | (cond ((equal dict "") | 2426 | (cond ((equal dict "") |
| 2450 | (message "Using %s dictionary" | 2427 | (message "Using %s dictionary" |
| 2451 | (or ispell-local-dictionary ispell-dictionary "default"))) | 2428 | (or ispell-local-dictionary ispell-dictionary "default"))) |
| 2452 | ((and (equal dict ispell-dictionary) | 2429 | ((equal dict (or ispell-local-dictionary |
| 2453 | (or (null ispell-local-dictionary) | 2430 | ispell-dictionary "default")) |
| 2454 | (equal dict ispell-local-dictionary))) | ||
| 2455 | ;; Specified dictionary is the default already. No-op | 2431 | ;; Specified dictionary is the default already. No-op |
| 2456 | (and (interactive-p) | 2432 | (and (interactive-p) |
| 2457 | (message "No change, using %s dictionary" (or dict "default")))) | 2433 | (message "No change, using %s dictionary" dict))) |
| 2458 | (t ; reset dictionary! | 2434 | (t ; reset dictionary! |
| 2459 | (if (assoc dict ispell-dictionary-alist) | 2435 | (if (or (assoc dict ispell-local-dictionary-alist) |
| 2460 | (progn | 2436 | (assoc dict ispell-dictionary-alist)) |
| 2461 | (if (or arg (null dict)) ; set default dictionary | 2437 | (if arg |
| 2462 | (setq ispell-dictionary dict)) | 2438 | ;; set default dictionary |
| 2463 | (if (null arg) ; set local dictionary | 2439 | (setq ispell-dictionary dict) |
| 2464 | (setq ispell-local-dictionary dict))) | 2440 | ;; set local dictionary |
| 2441 | (setq ispell-local-dictionary dict) | ||
| 2442 | (setq ispell-local-dictionary-overridden t)) | ||
| 2465 | (error "Undefined dictionary: %s" dict)) | 2443 | (error "Undefined dictionary: %s" dict)) |
| 2466 | (ispell-kill-ispell t) | 2444 | (message "%s Ispell dictionary set to %s" |
| 2467 | (message "(Next %sIspell command will use %s dictionary)" | 2445 | (if arg "Global" "Local") |
| 2468 | (cond ((equal ispell-local-dictionary ispell-dictionary) | 2446 | dict)))) |
| 2469 | "") | 2447 | |
| 2470 | (arg "global ") | 2448 | (defun ispell-internal-change-dictionary () |
| 2471 | (t "local ")) | 2449 | "Update the dictionary actually used by Ispell. |
| 2472 | (or (if (or (equal ispell-local-dictionary ispell-dictionary) | 2450 | This may kill the Ispell process; if so, |
| 2473 | (null arg)) | 2451 | a new one will be started when needed." |
| 2474 | ispell-local-dictionary | 2452 | (let ((dict (or ispell-local-dictionary ispell-dictionary "default"))) |
| 2475 | ispell-dictionary) | 2453 | (unless (equal ispell-current-dictionary dict) |
| 2476 | "default"))))) | 2454 | (setq ispell-current-dictionary dict) |
| 2455 | (ispell-kill-ispell t)))) | ||
| 2477 | 2456 | ||
| 2478 | 2457 | ||
| 2479 | ;;; Spelling of comments are checked when ispell-check-comments is non-nil. | 2458 | ;;; Spelling of comments are checked when ispell-check-comments is non-nil. |
| @@ -2493,7 +2472,7 @@ Return nil if spell session is quit, | |||
| 2493 | (message "Spell checking %s using %s dictionary..." | 2472 | (message "Spell checking %s using %s dictionary..." |
| 2494 | (if (and (= reg-start (point-min)) (= reg-end (point-max))) | 2473 | (if (and (= reg-start (point-min)) (= reg-end (point-max))) |
| 2495 | (buffer-name) "region") | 2474 | (buffer-name) "region") |
| 2496 | (or ispell-dictionary "default")) | 2475 | (or ispell-current-dictionary "default")) |
| 2497 | ;; Returns cursor to original location. | 2476 | ;; Returns cursor to original location. |
| 2498 | (save-window-excursion | 2477 | (save-window-excursion |
| 2499 | (goto-char reg-start) | 2478 | (goto-char reg-start) |
| @@ -2511,7 +2490,7 @@ Return nil if spell session is quit, | |||
| 2511 | (goto-char reg-start))) | 2490 | (goto-char reg-start))) |
| 2512 | (let (message-log-max) | 2491 | (let (message-log-max) |
| 2513 | (message "Continuing spelling check using %s dictionary..." | 2492 | (message "Continuing spelling check using %s dictionary..." |
| 2514 | (or ispell-dictionary "default"))) | 2493 | (or ispell-current-dictionary "default"))) |
| 2515 | (set-marker rstart reg-start) | 2494 | (set-marker rstart reg-start) |
| 2516 | (set-marker ispell-region-end reg-end) | 2495 | (set-marker ispell-region-end reg-end) |
| 2517 | (while (and (not ispell-quit) | 2496 | (while (and (not ispell-quit) |
| @@ -2941,7 +2920,7 @@ Returns the sum shift due to changes in word replacements." | |||
| 2941 | (if (not ispell-quit) | 2920 | (if (not ispell-quit) |
| 2942 | (let (message-log-max) | 2921 | (let (message-log-max) |
| 2943 | (message "Continuing spelling check using %s dictionary..." | 2922 | (message "Continuing spelling check using %s dictionary..." |
| 2944 | (or ispell-dictionary "default")))) | 2923 | (or ispell-current-dictionary "default")))) |
| 2945 | (sit-for 0) | 2924 | (sit-for 0) |
| 2946 | (setq start (marker-position line-start) | 2925 | (setq start (marker-position line-start) |
| 2947 | end (marker-position line-end)) | 2926 | end (marker-position line-end)) |
| @@ -3511,14 +3490,15 @@ Both should not be used to define a buffer-local dictionary." | |||
| 3511 | ;; Override the local variable definition. | 3490 | ;; Override the local variable definition. |
| 3512 | ;; Uses last occurrence of ispell-dictionary-keyword. | 3491 | ;; Uses last occurrence of ispell-dictionary-keyword. |
| 3513 | (goto-char (point-max)) | 3492 | (goto-char (point-max)) |
| 3514 | (if (search-backward ispell-dictionary-keyword nil t) | 3493 | (unless ispell-local-dictionary-overridden |
| 3515 | (progn | 3494 | (if (search-backward ispell-dictionary-keyword nil t) |
| 3516 | (search-forward ispell-dictionary-keyword) | 3495 | (progn |
| 3517 | (setq end (save-excursion (end-of-line) (point))) | 3496 | (search-forward ispell-dictionary-keyword) |
| 3518 | (if (re-search-forward " *\\([^ \"]+\\)" end t) | 3497 | (setq end (save-excursion (end-of-line) (point))) |
| 3519 | (setq ispell-local-dictionary | 3498 | (if (re-search-forward " *\\([^ \"]+\\)" end t) |
| 3520 | (buffer-substring-no-properties (match-beginning 1) | 3499 | (setq ispell-local-dictionary |
| 3521 | (match-end 1)))))) | 3500 | (buffer-substring-no-properties (match-beginning 1) |
| 3501 | (match-end 1))))))) | ||
| 3522 | (goto-char (point-max)) | 3502 | (goto-char (point-max)) |
| 3523 | (if (search-backward ispell-pdict-keyword nil t) | 3503 | (if (search-backward ispell-pdict-keyword nil t) |
| 3524 | (progn | 3504 | (progn |
| @@ -3535,8 +3515,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 3535 | (ispell-kill-ispell t) | 3515 | (ispell-kill-ispell t) |
| 3536 | (setq ispell-personal-dictionary ispell-local-pdict))) | 3516 | (setq ispell-personal-dictionary ispell-local-pdict))) |
| 3537 | ;; Reload if new dictionary defined. | 3517 | ;; Reload if new dictionary defined. |
| 3538 | (if (not (equal ispell-local-dictionary ispell-dictionary)) | 3518 | (ispell-internal-change-dictionary)) |
| 3539 | (ispell-change-dictionary ispell-local-dictionary))) | ||
| 3540 | 3519 | ||
| 3541 | 3520 | ||
| 3542 | (defun ispell-buffer-local-words () | 3521 | (defun ispell-buffer-local-words () |