1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-17 11:20:39 -08:00

(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.
This commit is contained in:
Richard M. Stallman 2005-01-31 11:54:36 +00:00
parent 84d77b1eb3
commit a6e7a34bef
2 changed files with 111 additions and 111 deletions

View file

@ -1,3 +1,24 @@
2005-01-31 Richard M. Stallman <rms@gnu.org>
* textmodes/ispell.el (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 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.
2005-01-31 Jay Belanger <belanger@truman.edu> 2005-01-31 Jay Belanger <belanger@truman.edu>
* calc/calc-aent.el (math-read-token): Add support for LaTeX. * calc/calc-aent.el (math-read-token): Add support for LaTeX.

View file

@ -44,8 +44,8 @@
;; country and language. ;; country and language.
;; Most dictionary changes should be made in this file so all users can ;; Most dictionary changes should be made in this file so all users can
;; enjoy them. Local or modified dictionaries are supported in your .emacs ;; enjoy them. Local or modified dictionaries are supported in your .emacs
;; file. Modify the variable `ispell-local-dictionary-alist' to include ;; file. Use the variable `ispell-local-dictionary-alist' to specify
;; these dictionaries, and they will be installed when ispell.el is loaded. ;; your own dictionaries.
;; Depending on the mail system you use, you may want to include these: ;; Depending on the mail system you use, you may want to include these:
;; (add-hook 'news-inews-hook 'ispell-message) ;; (add-hook 'news-inews-hook 'ispell-message)
@ -428,29 +428,27 @@ where DICTNAME is the name of your default dictionary."
:type 'boolean :type 'boolean
:group 'ispell) :group 'ispell)
;;; This is the local dictionary to use. When nil the default dictionary will (defvar ispell-local-dictionary-overridden nil
;;; be used. Change set-default call to use a new default dictionary. "Non-nil means the user has explicitly set this buffer's Ispell dictionary.")
(make-variable-buffer-local 'ispell-local-dictionary)
(defcustom ispell-local-dictionary nil (defcustom ispell-local-dictionary nil
"If non-nil, the dictionary to be used for Ispell commands. "If non-nil, the dictionary to be used for Ispell commands in this buffer.
The value must be a string dictionary name in `ispell-dictionary-alist'. The value must be a string dictionary name,
or nil, which means use the global setting in `ispell-dictionary'.
Dictionary names are defined in `ispell-local-dictionary-alist'
and `ispell-dictionary-alist',
Setting `ispell-local-dictionary' to a value has the same effect as Setting `ispell-local-dictionary' to a value has the same effect as
calling \\[ispell-change-dictionary] with that value. This variable calling \\[ispell-change-dictionary] with that value. This variable
is automatically set when defined in the file with either is automatically set when defined in the file with either
`ispell-dictionary-keyword' or the Local Variable syntax. `ispell-dictionary-keyword' or the Local Variable syntax."
To create a non-standard default dictionary (not from `ispell-dictionary-alist')
call function `set-default' with the new dictionary name."
:type '(choice string :type '(choice string
(const :tag "default" nil)) (const :tag "default" nil))
:group 'ispell) :group 'ispell)
(make-variable-buffer-local 'ispell-local-dictionary) (make-variable-buffer-local 'ispell-local-dictionary)
;; Call this function set up the default dictionary if not English.
;;(set-default 'ispell-local-dictionary nil)
(defcustom ispell-extra-args nil (defcustom ispell-extra-args nil
"*If non-nil, a list of extra switches to pass to the Ispell program. "*If non-nil, a list of extra switches to pass to the Ispell program.
For example, (\"-W\" \"3\") to cause it to accept all 1-3 character For example, (\"-W\" \"3\") to cause it to accept all 1-3 character
@ -473,17 +471,14 @@ buffer's major mode."
(make-variable-buffer-local 'ispell-skip-html) (make-variable-buffer-local 'ispell-skip-html)
;;; Define definitions here only for personal dictionaries.
;;;###autoload ;;;###autoload
(defcustom ispell-local-dictionary-alist nil (defcustom ispell-local-dictionary-alist nil
"*Contains local or customized dictionary definitions. "*List of local or customized dictionary definitions.
These can override the values in `ispell-dictionary-alist'.
These will override the values in `ispell-dictionary-alist'. To make permanent changes to your dictionary definitions, you
will need to make your changes in this variable, save, and then
Customization changes made to `ispell-dictionary-alist' will not operate re-start emacs."
over emacs sessions. To make permanent changes to your dictionary
definitions, you will need to make your changes in this variable, save,
and then re-start emacs."
:type '(repeat (list (choice :tag "Dictionary" :type '(repeat (list (choice :tag "Dictionary"
(string :tag "Dictionary name") (string :tag "Dictionary name")
(const :tag "default" nil)) (const :tag "default" nil))
@ -646,9 +641,8 @@ and then re-start emacs."
;;;###autoload ;;;###autoload
(defcustom ispell-dictionary-alist (defvar ispell-dictionary-alist
(append ispell-local-dictionary-alist ; dictionary customizations (append ispell-dictionary-alist-1 ispell-dictionary-alist-2
ispell-dictionary-alist-1 ispell-dictionary-alist-2
ispell-dictionary-alist-3 ispell-dictionary-alist-4 ispell-dictionary-alist-3 ispell-dictionary-alist-4
ispell-dictionary-alist-5 ispell-dictionary-alist-6) ispell-dictionary-alist-5 ispell-dictionary-alist-6)
"An alist of dictionaries and their associated parameters. "An alist of dictionaries and their associated parameters.
@ -696,33 +690,7 @@ CHARACTER-SET used for languages with multibyte characters.
Note that the CASECHARS and OTHERCHARS slots of the alist should Note that the CASECHARS and OTHERCHARS slots of the alist should
contain the same character set as casechars and otherchars in the contain the same character set as casechars and otherchars in the
LANGUAGE.aff file \(e.g., english.aff\)." LANGUAGE.aff file \(e.g., english.aff\).")
:type '(repeat (list (choice :tag "Dictionary"
(string :tag "Dictionary name")
(const :tag "default" nil))
(regexp :tag "Case characters")
(regexp :tag "Non case characters")
(regexp :tag "Other characters")
(boolean :tag "Many other characters")
(repeat :tag "Ispell command line args"
(string :tag "Arg"))
(choice :tag "Extended character mode"
(const "~tex") (const "~plaintex")
(const "~nroff") (const "~list")
(const "~latin1") (const "~latin3")
(const :tag "default" nil))
(choice :tag "Coding System"
(const iso-8859-1)
(const iso-8859-2)
(const koi8-r))))
:group 'ispell)
;;; update the dictionaries at load time
(setq ispell-dictionary-alist
(append ispell-local-dictionary-alist ; dictionary customizations
ispell-dictionary-alist-1 ispell-dictionary-alist-2
ispell-dictionary-alist-3 ispell-dictionary-alist-4
ispell-dictionary-alist-5 ispell-dictionary-alist-6))
(defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used (defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used
@ -877,7 +845,7 @@ and added as a submenu of the \"Edit\" menu.")
(defun ispell-valid-dictionary-list () (defun ispell-valid-dictionary-list ()
"Returns a list of valid dictionaries. "Returns a list of valid dictionaries.
The variable `ispell-library-directory' defines the library location." The variable `ispell-library-directory' defines the library location."
(let ((dicts ispell-dictionary-alist) (let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist))
(dict-list (cons "default" nil)) (dict-list (cons "default" nil))
name load-dict) name load-dict)
(dolist (dict dicts) (dolist (dict dicts)
@ -899,11 +867,12 @@ The variable `ispell-library-directory' defines the library location."
(setq dict-list (cons name dict-list)))) (setq dict-list (cons name dict-list))))
dict-list)) dict-list))
;;;###autoload ;;;###autoload
(if ispell-menu-map-needed (if ispell-menu-map-needed
(let ((dicts (if (fboundp 'ispell-valid-dictionary-list) (let ((dicts (if (fboundp 'ispell-valid-dictionary-list)
(ispell-valid-dictionary-list) (ispell-valid-dictionary-list)
;; This case is used in loaddefs.el
;; since ispell-valid-dictionary-list isn't defined then.
(mapcar (lambda (x) (or (car x) "default")) (mapcar (lambda (x) (or (car x) "default"))
ispell-dictionary-alist))) ispell-dictionary-alist)))
(dict-map (make-sparse-keymap "Dictionaries"))) (dict-map (make-sparse-keymap "Dictionaries")))
@ -1054,14 +1023,14 @@ The variable `ispell-library-directory' defines the library location."
;;; This variable contains the current dictionary being used if the ispell ;;; This variable contains the current dictionary being used if the ispell
;;; process is running. Otherwise it contains the global default. ;;; process is running.
(defvar ispell-dictionary nil (defvar ispell-current-dictionary nil
"The name of the current dictionary, or nil for the default. "The name of the current dictionary, or nil for the default.
When `ispell-local-dictionary' is nil, `ispell-dictionary' is used to select
the dictionary for new buffers.
This is passed to the ispell process using the `-d' switch and is This is passed to the ispell process using the `-d' switch and is
used as key in `ispell-dictionary-alist' (which see).") used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.")
(defvar ispell-dictionary nil
"Default dictionary to use if `ispell-local-dictionary' is nil.")
(defun ispell-decode-string (str) (defun ispell-decode-string (str)
"Decodes multibyte character strings. "Decodes multibyte character strings.
@ -1097,7 +1066,9 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
;; regular expression matching. ;; regular expression matching.
(defun ispell-get-decoded-string (n) (defun ispell-get-decoded-string (n)
(let* ((slot (assoc ispell-dictionary ispell-dictionary-alist)) (let* ((slot (or
(assoc ispell-current-dictionary ispell-local-dictionary-alist)
(assoc ispell-current-dictionary ispell-dictionary-alist)))
(str (nth n slot))) (str (nth n slot)))
(when (and (> (length str) 0) (when (and (> (length str) 0)
(not (multibyte-string-p str))) (not (multibyte-string-p str)))
@ -1123,13 +1094,17 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
(defun ispell-get-otherchars () (defun ispell-get-otherchars ()
(ispell-get-decoded-string 3)) (ispell-get-decoded-string 3))
(defun ispell-get-many-otherchars-p () (defun ispell-get-many-otherchars-p ()
(nth 4 (assoc ispell-dictionary ispell-dictionary-alist))) (nth 4 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist)
(assoc ispell-current-dictionary ispell-dictionary-alist))))
(defun ispell-get-ispell-args () (defun ispell-get-ispell-args ()
(nth 5 (assoc ispell-dictionary ispell-dictionary-alist))) (nth 5 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist)
(assoc ispell-current-dictionary ispell-dictionary-alist))))
(defun ispell-get-extended-character-mode () (defun ispell-get-extended-character-mode ()
(nth 6 (assoc ispell-dictionary ispell-dictionary-alist))) (nth 6 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist)
(assoc ispell-current-dictionary ispell-dictionary-alist))))
(defun ispell-get-coding-system () (defun ispell-get-coding-system ()
(nth 7 (assoc ispell-dictionary ispell-dictionary-alist))) (nth 7 (or (assoc ispell-current-dictionary ispell-local-dictionary-alist)
(assoc ispell-current-dictionary ispell-dictionary-alist))))
(defvar ispell-pdict-modified-p nil (defvar ispell-pdict-modified-p nil
@ -1181,8 +1156,9 @@ There can be multiple of these keywords in the file.")
(defconst ispell-dictionary-keyword "Local IspellDict: " (defconst ispell-dictionary-keyword "Local IspellDict: "
"The keyword for a local dictionary to use. "The keyword for a local dictionary to use.
The keyword must be followed by a correct dictionary name in The keyword must be followed by a valid dictionary name, defined in
`ispell-dictionary-alist'. When multiple occurrences exist, the last keyword `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.
When multiple occurrences exist, the last keyword
definition is used.") definition is used.")
(defconst ispell-pdict-keyword "Local IspellPersDict: " (defconst ispell-pdict-keyword "Local IspellPersDict: "
@ -1439,7 +1415,8 @@ when called interactively, non-corrective messages are suppressed.
With a prefix argument (or if CONTINUE is non-nil), With a prefix argument (or if CONTINUE is non-nil),
resume interrupted spell-checking of a buffer or region. resume interrupted spell-checking of a buffer or region.
Word syntax described by `ispell-dictionary-alist' (which see). Word syntax is controlled by the definition of the chosen dictionary,
which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.
This will check or reload the dictionary. Use \\[ispell-change-dictionary] This will check or reload the dictionary. Use \\[ispell-change-dictionary]
or \\[ispell-region] to update the Ispell process. or \\[ispell-region] to update the Ispell process.
@ -1549,7 +1526,8 @@ is non-nil when called interactively, then the following word
Optional second argument contains otherchars that can be included in word Optional second argument contains otherchars that can be included in word
many times. many times.
Word syntax described by `ispell-dictionary-alist' (which see)." Word syntax is controlled by the definition of the chosen dictionary,
which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'."
(let* ((ispell-casechars (ispell-get-casechars)) (let* ((ispell-casechars (ispell-get-casechars))
(ispell-not-casechars (ispell-get-not-casechars)) (ispell-not-casechars (ispell-get-not-casechars))
(ispell-otherchars (ispell-get-otherchars)) (ispell-otherchars (ispell-get-otherchars))
@ -2309,13 +2287,13 @@ When asynchronous processes are not supported, `run' is always returned."
Keeps argument list for future ispell invocations for no async support." Keeps argument list for future ispell invocations for no async support."
(let (args) (let (args)
;; Local dictionary becomes the global dictionary in use. ;; Local dictionary becomes the global dictionary in use.
(if ispell-local-dictionary (setq ispell-current-dictionary
(setq ispell-dictionary ispell-local-dictionary)) (or ispell-local-dictionary ispell-dictionary))
(setq args (ispell-get-ispell-args)) (setq args (ispell-get-ispell-args))
(if (and ispell-dictionary ; use specified dictionary (if (and ispell-current-dictionary ; use specified dictionary
(not (member "-d" args))) ; only define if not overridden (not (member "-d" args))) ; only define if not overridden
(setq args (setq args
(append (list "-d" ispell-dictionary) args))) (append (list "-d" ispell-current-dictionary) args)))
(if ispell-personal-dictionary ; use specified pers dict (if ispell-personal-dictionary ; use specified pers dict
(setq args (setq args
(append args (append args
@ -2431,9 +2409,7 @@ With NO-ERROR, just return non-nil if there was no Ispell running."
;;;###autoload ;;;###autoload
(defun ispell-change-dictionary (dict &optional arg) (defun ispell-change-dictionary (dict &optional arg)
"Change `ispell-dictionary' (q.v.) to DICT and kill old Ispell process. "Change to dictionary DICT for Ispell.
A new one will be started as soon as necessary.
By just answering RET you can find out what the current dictionary is. By just answering RET you can find out what the current dictionary is.
With prefix argument, set the default dictionary." With prefix argument, set the default dictionary."
@ -2441,39 +2417,42 @@ With prefix argument, set the default dictionary."
(list (completing-read (list (completing-read
"Use new dictionary (RET for current, SPC to complete): " "Use new dictionary (RET for current, SPC to complete): "
(and (fboundp 'ispell-valid-dictionary-list) (and (fboundp 'ispell-valid-dictionary-list)
(mapcar (lambda (x)(cons x nil)) (ispell-valid-dictionary-list))) (mapcar 'list (ispell-valid-dictionary-list)))
nil t) nil t)
current-prefix-arg)) current-prefix-arg))
(unless arg (ispell-accept-buffer-local-defs))
(if (equal dict "default") (setq dict nil)) (if (equal dict "default") (setq dict nil))
;; This relies on completing-read's bug of returning "" for no match ;; This relies on completing-read's bug of returning "" for no match
(cond ((equal dict "") (cond ((equal dict "")
(message "Using %s dictionary" (message "Using %s dictionary"
(or ispell-local-dictionary ispell-dictionary "default"))) (or ispell-local-dictionary ispell-dictionary "default")))
((and (equal dict ispell-dictionary) ((equal dict (or ispell-local-dictionary
(or (null ispell-local-dictionary) ispell-dictionary "default"))
(equal dict ispell-local-dictionary)))
;; Specified dictionary is the default already. No-op ;; Specified dictionary is the default already. No-op
(and (interactive-p) (and (interactive-p)
(message "No change, using %s dictionary" (or dict "default")))) (message "No change, using %s dictionary" dict)))
(t ; reset dictionary! (t ; reset dictionary!
(if (assoc dict ispell-dictionary-alist) (if (or (assoc dict ispell-local-dictionary-alist)
(progn (assoc dict ispell-dictionary-alist))
(if (or arg (null dict)) ; set default dictionary (if arg
(setq ispell-dictionary dict)) ;; set default dictionary
(if (null arg) ; set local dictionary (setq ispell-dictionary dict)
(setq ispell-local-dictionary dict))) ;; set local dictionary
(setq ispell-local-dictionary dict)
(setq ispell-local-dictionary-overridden t))
(error "Undefined dictionary: %s" dict)) (error "Undefined dictionary: %s" dict))
(ispell-kill-ispell t) (message "%s Ispell dictionary set to %s"
(message "(Next %sIspell command will use %s dictionary)" (if arg "Global" "Local")
(cond ((equal ispell-local-dictionary ispell-dictionary) dict))))
"")
(arg "global ") (defun ispell-internal-change-dictionary ()
(t "local ")) "Update the dictionary actually used by Ispell.
(or (if (or (equal ispell-local-dictionary ispell-dictionary) This may kill the Ispell process; if so,
(null arg)) a new one will be started when needed."
ispell-local-dictionary (let ((dict (or ispell-local-dictionary ispell-dictionary "default")))
ispell-dictionary) (unless (equal ispell-current-dictionary dict)
"default"))))) (setq ispell-current-dictionary dict)
(ispell-kill-ispell t))))
;;; Spelling of comments are checked when ispell-check-comments is non-nil. ;;; Spelling of comments are checked when ispell-check-comments is non-nil.
@ -2493,7 +2472,7 @@ Return nil if spell session is quit,
(message "Spell checking %s using %s dictionary..." (message "Spell checking %s using %s dictionary..."
(if (and (= reg-start (point-min)) (= reg-end (point-max))) (if (and (= reg-start (point-min)) (= reg-end (point-max)))
(buffer-name) "region") (buffer-name) "region")
(or ispell-dictionary "default")) (or ispell-current-dictionary "default"))
;; Returns cursor to original location. ;; Returns cursor to original location.
(save-window-excursion (save-window-excursion
(goto-char reg-start) (goto-char reg-start)
@ -2511,7 +2490,7 @@ Return nil if spell session is quit,
(goto-char reg-start))) (goto-char reg-start)))
(let (message-log-max) (let (message-log-max)
(message "Continuing spelling check using %s dictionary..." (message "Continuing spelling check using %s dictionary..."
(or ispell-dictionary "default"))) (or ispell-current-dictionary "default")))
(set-marker rstart reg-start) (set-marker rstart reg-start)
(set-marker ispell-region-end reg-end) (set-marker ispell-region-end reg-end)
(while (and (not ispell-quit) (while (and (not ispell-quit)
@ -2941,7 +2920,7 @@ Returns the sum shift due to changes in word replacements."
(if (not ispell-quit) (if (not ispell-quit)
(let (message-log-max) (let (message-log-max)
(message "Continuing spelling check using %s dictionary..." (message "Continuing spelling check using %s dictionary..."
(or ispell-dictionary "default")))) (or ispell-current-dictionary "default"))))
(sit-for 0) (sit-for 0)
(setq start (marker-position line-start) (setq start (marker-position line-start)
end (marker-position line-end)) end (marker-position line-end))
@ -3511,14 +3490,15 @@ Both should not be used to define a buffer-local dictionary."
;; Override the local variable definition. ;; Override the local variable definition.
;; Uses last occurrence of ispell-dictionary-keyword. ;; Uses last occurrence of ispell-dictionary-keyword.
(goto-char (point-max)) (goto-char (point-max))
(if (search-backward ispell-dictionary-keyword nil t) (unless ispell-local-dictionary-overridden
(progn (if (search-backward ispell-dictionary-keyword nil t)
(search-forward ispell-dictionary-keyword) (progn
(setq end (save-excursion (end-of-line) (point))) (search-forward ispell-dictionary-keyword)
(if (re-search-forward " *\\([^ \"]+\\)" end t) (setq end (save-excursion (end-of-line) (point)))
(setq ispell-local-dictionary (if (re-search-forward " *\\([^ \"]+\\)" end t)
(buffer-substring-no-properties (match-beginning 1) (setq ispell-local-dictionary
(match-end 1)))))) (buffer-substring-no-properties (match-beginning 1)
(match-end 1)))))))
(goto-char (point-max)) (goto-char (point-max))
(if (search-backward ispell-pdict-keyword nil t) (if (search-backward ispell-pdict-keyword nil t)
(progn (progn
@ -3535,8 +3515,7 @@ Both should not be used to define a buffer-local dictionary."
(ispell-kill-ispell t) (ispell-kill-ispell t)
(setq ispell-personal-dictionary ispell-local-pdict))) (setq ispell-personal-dictionary ispell-local-pdict)))
;; Reload if new dictionary defined. ;; Reload if new dictionary defined.
(if (not (equal ispell-local-dictionary ispell-dictionary)) (ispell-internal-change-dictionary))
(ispell-change-dictionary ispell-local-dictionary)))
(defun ispell-buffer-local-words () (defun ispell-buffer-local-words ()