mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-16 02:50:26 -08:00
* lisp/textmodes/ispell.el: Fix nitpicks and byte-compiler warnings.
(ispell-print-if-debug): Build `format' in. Avoid end-of-buffer. (ispell-parse-hunspell-affix-file): Avoid beginning-of-buffer. Use dict-key rather than dict-name for the error message.
This commit is contained in:
parent
7944eaa336
commit
b5a5723d4e
2 changed files with 189 additions and 179 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
2013-03-01 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||||
|
|
||||||
|
* textmodes/ispell.el: Fix nitpicks and byte-compiler warnings.
|
||||||
|
(ispell-print-if-debug): Build `format' in. Avoid end-of-buffer.
|
||||||
|
(ispell-parse-hunspell-affix-file): Avoid beginning-of-buffer.
|
||||||
|
Use dict-key rather than dict-name for the error message.
|
||||||
|
|
||||||
2013-03-01 Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
2013-03-01 Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
||||||
|
|
||||||
* net/net-utils.el (net-utils-run-simple): Don't display-buffer
|
* net/net-utils.el (net-utils-run-simple): Don't display-buffer
|
||||||
|
|
|
||||||
|
|
@ -749,8 +749,10 @@ OTHERCHARS slots of the alist should contain the same character
|
||||||
set as casechars and otherchars in the LANGUAGE.aff file \(e.g.,
|
set as casechars and otherchars in the LANGUAGE.aff file \(e.g.,
|
||||||
english.aff\). aspell and hunspell don't have this limitation.")
|
english.aff\). aspell and hunspell don't have this limitation.")
|
||||||
|
|
||||||
(defvar ispell-really-aspell nil) ; Non-nil if we can use aspell extensions.
|
(defvar ispell-really-aspell nil
|
||||||
(defvar ispell-really-hunspell nil) ; Non-nil if we can use hunspell extensions.
|
"Non-nil if we can use aspell extensions.")
|
||||||
|
(defvar ispell-really-hunspell nil
|
||||||
|
"Non-nil if we can use hunspell extensions.")
|
||||||
(defvar ispell-encoding8-command nil
|
(defvar ispell-encoding8-command nil
|
||||||
"Command line option prefix to select encoding if supported, nil otherwise.
|
"Command line option prefix to select encoding if supported, nil otherwise.
|
||||||
If setting the encoding is supported by spellchecker and is selectable from
|
If setting the encoding is supported by spellchecker and is selectable from
|
||||||
|
|
@ -860,7 +862,7 @@ Otherwise returns the library directory name, if that is defined."
|
||||||
(if (string-match "\\`aspell" speller) "-v" "-vv"))))
|
(if (string-match "\\`aspell" speller) "-v" "-vv"))))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if interactivep
|
(if interactivep
|
||||||
;; report version information of ispell and ispell.el
|
;; Report version information of ispell and ispell.el
|
||||||
(progn
|
(progn
|
||||||
(end-of-line)
|
(end-of-line)
|
||||||
(setq result (concat (buffer-substring-no-properties (point-min)
|
(setq result (concat (buffer-substring-no-properties (point-min)
|
||||||
|
|
@ -955,12 +957,12 @@ See `ispell-buffer-with-debug' for an example of use."
|
||||||
(erase-buffer)))
|
(erase-buffer)))
|
||||||
ispell-debug-buffer))
|
ispell-debug-buffer))
|
||||||
|
|
||||||
(defsubst ispell-print-if-debug (string)
|
(defsubst ispell-print-if-debug (format &rest args)
|
||||||
"Print STRING to `ispell-debug-buffer' buffer if enabled."
|
"Print message to `ispell-debug-buffer' buffer if enabled."
|
||||||
(if (boundp 'ispell-debug-buffer)
|
(if (boundp 'ispell-debug-buffer)
|
||||||
(with-current-buffer ispell-debug-buffer
|
(with-current-buffer ispell-debug-buffer
|
||||||
(end-of-buffer)
|
(goto-char (point-max))
|
||||||
(insert string))))
|
(insert (apply #'format format args)))))
|
||||||
|
|
||||||
|
|
||||||
;; The preparation of the menu bar menu must be autoloaded
|
;; The preparation of the menu bar menu must be autoloaded
|
||||||
|
|
@ -1133,13 +1135,13 @@ Return the new dictionary alist."
|
||||||
;; Make ispell.el work better with hunspell.
|
;; Make ispell.el work better with hunspell.
|
||||||
|
|
||||||
(defvar ispell-hunspell-dict-paths-alist nil
|
(defvar ispell-hunspell-dict-paths-alist nil
|
||||||
"Alist of parsed hunspell dicts and associated affix files.
|
"Alist of parsed hunspell dicts and associated affix files.
|
||||||
Will be used to parse corresponding .aff file and create associated
|
Will be used to parse corresponding .aff file and create associated
|
||||||
parameters to be inserted into `ispell-hunspell-dictionary-alist'.
|
parameters to be inserted into `ispell-hunspell-dictionary-alist'.
|
||||||
Internal use.")
|
Internal use.")
|
||||||
|
|
||||||
(defvar ispell-hunspell-dictionary-alist nil
|
(defvar ispell-hunspell-dictionary-alist nil
|
||||||
"Alist of parsed hunspell dicts and associated parameters.
|
"Alist of parsed hunspell dicts and associated parameters.
|
||||||
This alist will initially contain names of found dicts. Associated
|
This alist will initially contain names of found dicts. Associated
|
||||||
parameters will be added when dict is used for the first time.
|
parameters will be added when dict is used for the first time.
|
||||||
Internal use.")
|
Internal use.")
|
||||||
|
|
@ -1150,7 +1152,8 @@ Value will be extracted from hunspell affix file and used for
|
||||||
all uninitialized dicts using that affix file."
|
all uninitialized dicts using that affix file."
|
||||||
(if (cadr (assoc dict ispell-dictionary-alist))
|
(if (cadr (assoc dict ispell-dictionary-alist))
|
||||||
(message "ispell-hfde: Non void entry for %s. Skipping.\n" dict)
|
(message "ispell-hfde: Non void entry for %s. Skipping.\n" dict)
|
||||||
(let ((dict-alias (cadr (assoc dict ispell-hunspell-dictionary-equivs-alist)))
|
(let ((dict-alias
|
||||||
|
(cadr (assoc dict ispell-hunspell-dictionary-equivs-alist)))
|
||||||
(use-for-dicts (list dict))
|
(use-for-dicts (list dict))
|
||||||
(dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict)))
|
(dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict)))
|
||||||
newlist)
|
newlist)
|
||||||
|
|
@ -1162,10 +1165,12 @@ all uninitialized dicts using that affix file."
|
||||||
(member dict-alias dict-equiv-alist-entry))
|
(member dict-alias dict-equiv-alist-entry))
|
||||||
(dolist ( tmp-dict (list dict-equiv-key dict-equiv-value))
|
(dolist ( tmp-dict (list dict-equiv-key dict-equiv-value))
|
||||||
(if (cadr (assoc tmp-dict ispell-dictionary-alist))
|
(if (cadr (assoc tmp-dict ispell-dictionary-alist))
|
||||||
(ispell-print-if-debug (format "ispell-hfde: %s already expanded. Skipping.\n" tmp-dict))
|
(ispell-print-if-debug
|
||||||
|
"ispell-hfde: %s already expanded. Skipping.\n" tmp-dict)
|
||||||
(add-to-list 'use-for-dicts tmp-dict))))))
|
(add-to-list 'use-for-dicts tmp-dict))))))
|
||||||
(ispell-print-if-debug (format "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts))
|
(ispell-print-if-debug
|
||||||
;; The final loop
|
"ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts)
|
||||||
|
;; The final loop.
|
||||||
(dolist (entry ispell-dictionary-alist)
|
(dolist (entry ispell-dictionary-alist)
|
||||||
(if (member (car entry) use-for-dicts)
|
(if (member (car entry) use-for-dicts)
|
||||||
(add-to-list 'newlist
|
(add-to-list 'newlist
|
||||||
|
|
@ -1178,39 +1183,41 @@ all uninitialized dicts using that affix file."
|
||||||
Return a list in `ispell-dictionary-alist' format."
|
Return a list in `ispell-dictionary-alist' format."
|
||||||
(let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist))))
|
(let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist))))
|
||||||
(unless affix-file
|
(unless affix-file
|
||||||
(error "ispell-phaf: No matching entry for %s.\n" dict-name))
|
(error "ispell-phaf: No matching entry for %s.\n" dict-key))
|
||||||
(if (file-exists-p affix-file)
|
(if (not (file-exists-p affix-file))
|
||||||
(let ((dict-name (file-name-sans-extension (file-name-nondirectory affix-file)))
|
(error "ispell-phaf: File \"%s\" not found.\n" affix-file))
|
||||||
otherchars-string otherchars-list)
|
(let ((dict-name (file-name-sans-extension
|
||||||
(with-temp-buffer
|
(file-name-nondirectory affix-file)))
|
||||||
(insert-file-contents affix-file)
|
otherchars-string otherchars-list)
|
||||||
(setq otherchars-string
|
(with-temp-buffer
|
||||||
(save-excursion
|
(insert-file-contents affix-file)
|
||||||
(beginning-of-buffer)
|
(setq otherchars-string
|
||||||
(if (search-forward-regexp "^WORDCHARS +" nil t )
|
(save-excursion
|
||||||
(buffer-substring (point)
|
(goto-char (point-min))
|
||||||
(progn (end-of-line) (point))))))
|
(if (search-forward-regexp "^WORDCHARS +" nil t )
|
||||||
;; Remove trailing whitespace and extra stuff. Make list if non-nil.
|
(buffer-substring (point)
|
||||||
(setq otherchars-list
|
(progn (end-of-line) (point))))))
|
||||||
(if otherchars-string
|
;; Remove trailing whitespace and extra stuff. Make list if
|
||||||
(split-string
|
;; non-nil.
|
||||||
(if (string-match " +.*$" otherchars-string)
|
(setq otherchars-list
|
||||||
(replace-match "" nil nil otherchars-string)
|
(if otherchars-string
|
||||||
otherchars-string)
|
(split-string
|
||||||
"" t)))
|
(if (string-match " +.*$" otherchars-string)
|
||||||
|
(replace-match "" nil nil otherchars-string)
|
||||||
|
otherchars-string)
|
||||||
|
"" t)))
|
||||||
|
|
||||||
;; Fill dict entry
|
;; Fill dict entry
|
||||||
(list dict-key
|
(list dict-key
|
||||||
"[[:alpha:]]"
|
"[[:alpha:]]"
|
||||||
"[^[:alpha:]]"
|
"[^[:alpha:]]"
|
||||||
(if otherchars-list
|
(if otherchars-list
|
||||||
(regexp-opt otherchars-list)
|
(regexp-opt otherchars-list)
|
||||||
"")
|
"")
|
||||||
t ;; many-otherchars-p: We can't tell, set to t
|
t ; many-otherchars-p: We can't tell, set to t.
|
||||||
(list "-d" dict-name)
|
(list "-d" dict-name)
|
||||||
nil ;; extended-char-mode: not supported by hunspell
|
nil ; extended-char-mode: not supported by hunspell!
|
||||||
'utf-8)))
|
'utf-8)))))
|
||||||
(error "ispell-phaf: File \"%s\" not found.\n" affix-file))))
|
|
||||||
|
|
||||||
(defun ispell-find-hunspell-dictionaries ()
|
(defun ispell-find-hunspell-dictionaries ()
|
||||||
"Look for installed hunspell dictionaries.
|
"Look for installed hunspell dictionaries.
|
||||||
|
|
@ -1247,19 +1254,19 @@ entries if a specific dict was found."
|
||||||
;; Entry has an associated .aff file and no previous value.
|
;; Entry has an associated .aff file and no previous value.
|
||||||
(let ((affix-file (expand-file-name affix-file)))
|
(let ((affix-file (expand-file-name affix-file)))
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n"
|
"++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n"
|
||||||
dict full-name basename affix-file))
|
dict full-name basename affix-file)
|
||||||
(add-to-list 'ispell-hunspell-dict-paths-alist
|
(add-to-list 'ispell-hunspell-dict-paths-alist
|
||||||
(list basename affix-file)))
|
(list basename affix-file)))
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format "-- ispell-fhd: Skipping entry: %s\n" dict))))))
|
"-- ispell-fhd: Skipping entry: %s\n" dict)))))
|
||||||
;; Remove entry from aliases alist if explicit dict was found.
|
;; Remove entry from aliases alist if explicit dict was found.
|
||||||
(let (newlist)
|
(let (newlist)
|
||||||
(dolist (dict ispell-hunspell-dictionary-equivs-alist)
|
(dolist (dict ispell-hunspell-dictionary-equivs-alist)
|
||||||
(if (assoc (car dict) ispell-hunspell-dict-paths-alist)
|
(if (assoc (car dict) ispell-hunspell-dict-paths-alist)
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n"
|
"-- ispell-fhd: Excluding %s alias. Standalone dict found.\n"
|
||||||
(car dict)))
|
(car dict))
|
||||||
(add-to-list 'newlist dict)))
|
(add-to-list 'newlist dict)))
|
||||||
(setq ispell-hunspell-dictionary-equivs-alist newlist))
|
(setq ispell-hunspell-dictionary-equivs-alist newlist))
|
||||||
;; Add known hunspell aliases
|
;; Add known hunspell aliases
|
||||||
|
|
@ -1274,9 +1281,10 @@ entries if a specific dict was found."
|
||||||
(if (and (assoc dict-equiv-value ispell-hunspell-dict-paths-alist)
|
(if (and (assoc dict-equiv-value ispell-hunspell-dict-paths-alist)
|
||||||
(not (assoc dict-equiv-key ispell-hunspell-dict-paths-alist))
|
(not (assoc dict-equiv-key ispell-hunspell-dict-paths-alist))
|
||||||
(not (member dict-equiv-key exclude-aliases)))
|
(not (member dict-equiv-key exclude-aliases)))
|
||||||
(let ((affix-file (cadr (assoc dict-equiv-value ispell-hunspell-dict-paths-alist))))
|
(let ((affix-file (cadr (assoc dict-equiv-value
|
||||||
(ispell-print-if-debug (format "++ ispell-fhd: Adding alias %s -> %s.\n"
|
ispell-hunspell-dict-paths-alist))))
|
||||||
dict-equiv-key affix-file))
|
(ispell-print-if-debug "++ ispell-fhd: Adding alias %s -> %s.\n"
|
||||||
|
dict-equiv-key affix-file)
|
||||||
(add-to-list
|
(add-to-list
|
||||||
'ispell-hunspell-dict-paths-alist
|
'ispell-hunspell-dict-paths-alist
|
||||||
(list dict-equiv-key affix-file))))))
|
(list dict-equiv-key affix-file))))))
|
||||||
|
|
@ -3207,29 +3215,25 @@ amount for last line processed."
|
||||||
(query-fcc t)
|
(query-fcc t)
|
||||||
in-comment key)
|
in-comment key)
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(concat
|
"ispell-region: (ispell-skip-region-list):\n%s
|
||||||
(format
|
ispell-region: (ispell-begin-skip-region-regexp):\n%s
|
||||||
"ispell-region: (ispell-skip-region-list):\n%s\n"
|
ispell-region: Search for first region to skip after (ispell-begin-skip-region-regexp)\n"
|
||||||
(ispell-skip-region-list))
|
(ispell-skip-region-list)
|
||||||
(format
|
(ispell-begin-skip-region-regexp))
|
||||||
"ispell-region: (ispell-begin-skip-region-regexp):\n%s\n"
|
|
||||||
(ispell-begin-skip-region-regexp))
|
|
||||||
"ispell-region: Search for first region to skip after (ispell-begin-skip-region-regexp)\n"))
|
|
||||||
(if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t)
|
(if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t)
|
||||||
(progn
|
(progn
|
||||||
(setq key (match-string-no-properties 0))
|
(setq key (match-string-no-properties 0))
|
||||||
(set-marker skip-region-start (- (point) (length key)))
|
(set-marker skip-region-start (- (point) (length key)))
|
||||||
(goto-char reg-start)
|
(goto-char reg-start)
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format "ispell-region: First skip: %s at (pos,line,column): (%s,%s,%s).\n"
|
"ispell-region: First skip: %s at (pos,line,column): (%s,%s,%s).\n"
|
||||||
key
|
key
|
||||||
(save-excursion (goto-char skip-region-start) (point))
|
(save-excursion (goto-char skip-region-start) (point))
|
||||||
(line-number-at-pos skip-region-start)
|
(line-number-at-pos skip-region-start)
|
||||||
(save-excursion (goto-char skip-region-start) (current-column))))))
|
(save-excursion (goto-char skip-region-start) (current-column)))))
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format
|
"ispell-region: Continue spell-checking with %s and %s dictionary...\n"
|
||||||
"ispell-region: Continue spell-checking with %s and %s dictionary...\n"
|
program-basename dictionary)
|
||||||
program-basename dictionary))
|
|
||||||
(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)
|
||||||
|
|
@ -3264,11 +3268,11 @@ amount for last line processed."
|
||||||
(- (point) (length key)))
|
(- (point) (length key)))
|
||||||
(goto-char rstart)
|
(goto-char rstart)
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format "ispell-region: Next skip: %s at (pos,line,column): (%s,%s,%s).\n"
|
"ispell-region: Next skip: %s at (pos,line,column): (%s,%s,%s).\n"
|
||||||
key
|
key
|
||||||
(save-excursion (goto-char skip-region-start) (point))
|
(save-excursion (goto-char skip-region-start) (point))
|
||||||
(line-number-at-pos skip-region-start)
|
(line-number-at-pos skip-region-start)
|
||||||
(save-excursion (goto-char skip-region-start) (current-column)))))
|
(save-excursion (goto-char skip-region-start) (current-column))))
|
||||||
(set-marker skip-region-start nil))))
|
(set-marker skip-region-start nil))))
|
||||||
(setq reg-end (max (point)
|
(setq reg-end (max (point)
|
||||||
(if (marker-position skip-region-start)
|
(if (marker-position skip-region-start)
|
||||||
|
|
@ -3287,9 +3291,8 @@ amount for last line processed."
|
||||||
(string (ispell-get-line
|
(string (ispell-get-line
|
||||||
ispell-start ispell-end add-comment)))
|
ispell-start ispell-end add-comment)))
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(format
|
"ispell-region: string pos (%s->%s), eol: %s, [in-comment]: [%s], [add-comment]: [%s], [string]: [%s]\n"
|
||||||
"ispell-region: string pos (%s->%s), eol: %s, [in-comment]: [%s], [add-comment]: [%s], [string]: [%s]\n"
|
ispell-start ispell-end (point-at-eol) in-comment add-comment string)
|
||||||
ispell-start ispell-end (point-at-eol) in-comment add-comment string))
|
|
||||||
(if add-comment ; account for comment chars added
|
(if add-comment ; account for comment chars added
|
||||||
(setq ispell-start (- ispell-start (length add-comment))
|
(setq ispell-start (- ispell-start (length add-comment))
|
||||||
add-comment nil))
|
add-comment nil))
|
||||||
|
|
@ -3576,118 +3579,118 @@ Returns the sum SHIFT due to changes in word replacements."
|
||||||
(let* ((ispell-pipe-word (car poss))
|
(let* ((ispell-pipe-word (car poss))
|
||||||
(actual-point (marker-position word-start))
|
(actual-point (marker-position word-start))
|
||||||
(actual-line (line-number-at-pos actual-point))
|
(actual-line (line-number-at-pos actual-point))
|
||||||
(actual-column (save-excursion (goto-char actual-point) (current-column))))
|
(actual-column (save-excursion (goto-char actual-point)
|
||||||
|
(current-column))))
|
||||||
(ispell-print-if-debug
|
(ispell-print-if-debug
|
||||||
(concat
|
"ispell-process-line: Ispell misalignment error:
|
||||||
"ispell-process-line: Ispell misalignment error:\n"
|
[Word from ispell pipe]: [%s], actual (point,line,column): (%s,%s,%s)\n"
|
||||||
(format " [Word from ispell pipe]: [%s], actual (point,line,column): (%s,%s,%s)\n"
|
ispell-pipe-word actual-point actual-line actual-column)
|
||||||
ispell-pipe-word actual-point actual-line actual-column)))
|
(error (concat "Ispell misalignment: word "
|
||||||
(error (concat "Ispell misalignment: word "
|
"`%s' point %d; probably incompatible versions")
|
||||||
"`%s' point %d; probably incompatible versions")
|
ispell-pipe-word actual-point)))
|
||||||
ispell-pipe-word actual-point)))
|
;; ispell-cmd-loop can go recursive & change buffer
|
||||||
;; ispell-cmd-loop can go recursive & change buffer
|
(if ispell-keep-choices-win
|
||||||
(if ispell-keep-choices-win
|
(setq replace (ispell-command-loop
|
||||||
(setq replace (ispell-command-loop
|
(car (cdr (cdr poss)))
|
||||||
(car (cdr (cdr poss)))
|
(car (cdr (cdr (cdr poss))))
|
||||||
(car (cdr (cdr (cdr poss))))
|
(car poss) (marker-position word-start)
|
||||||
(car poss) (marker-position word-start)
|
(+ word-len (marker-position word-start))))
|
||||||
(+ word-len (marker-position word-start))))
|
(save-window-excursion
|
||||||
(save-window-excursion
|
(setq replace (ispell-command-loop
|
||||||
(setq replace (ispell-command-loop
|
(car (cdr (cdr poss)))
|
||||||
(car (cdr (cdr poss)))
|
(car (cdr (cdr (cdr poss))))
|
||||||
(car (cdr (cdr (cdr poss))))
|
(car poss) (marker-position word-start)
|
||||||
(car poss) (marker-position word-start)
|
(+ word-len (marker-position word-start))))))
|
||||||
(+ word-len (marker-position word-start))))))
|
|
||||||
|
|
||||||
(goto-char word-start)
|
(goto-char word-start)
|
||||||
;; Recheck when query replace edit changes misspelled word.
|
;; Recheck when query replace edit changes misspelled word.
|
||||||
;; Error in tex mode when a potential math mode change exists.
|
;; Error in tex mode when a potential math mode change exists.
|
||||||
(if (and replace (listp replace) (= 2 (length replace)))
|
(if (and replace (listp replace) (= 2 (length replace)))
|
||||||
(if (and (eq ispell-parser 'tex)
|
(if (and (eq ispell-parser 'tex)
|
||||||
(string-match "[\\\\][]()[]\\|\\\\begin\\|\\$"
|
(string-match "[\\\\][]()[]\\|\\\\begin\\|\\$"
|
||||||
(regexp-quote string)))
|
(regexp-quote string)))
|
||||||
(error
|
(error
|
||||||
"Don't start query replace on a line with math characters"
|
"Don't start query replace on a line with math characters"
|
||||||
)
|
)
|
||||||
(set-marker line-end (point))
|
(set-marker line-end (point))
|
||||||
(setq ispell-filter nil
|
(setq ispell-filter nil
|
||||||
recheck-region t)))
|
recheck-region t)))
|
||||||
|
|
||||||
;; insert correction if needed
|
;; Insert correction if needed.
|
||||||
(cond
|
(cond
|
||||||
((or (null replace)
|
((or (null replace)
|
||||||
(equal 0 replace)) ; ACCEPT/INSERT
|
(equal 0 replace)) ; ACCEPT/INSERT
|
||||||
(if (equal 0 replace) ; BUFFER-LOCAL DICT ADD
|
(if (equal 0 replace) ; BUFFER-LOCAL DICT ADD
|
||||||
(ispell-add-per-file-word-list (car poss)))
|
(ispell-add-per-file-word-list (car poss)))
|
||||||
;; do not recheck accepted word on this line
|
;; Do not recheck accepted word on this line.
|
||||||
(setq accept-list (cons (car poss) accept-list)))
|
(setq accept-list (cons (car poss) accept-list)))
|
||||||
(t ; replacement word selected or entered
|
(t ; Replacement word selected or entered.
|
||||||
(delete-region (point) (+ word-len (point)))
|
(delete-region (point) (+ word-len (point)))
|
||||||
(if (not (listp replace))
|
(if (not (listp replace))
|
||||||
(progn
|
(progn
|
||||||
(insert replace) ; insert dictionary word
|
(insert replace) ; Insert dictionary word.
|
||||||
(ispell-send-replacement (car poss) replace)
|
(ispell-send-replacement (car poss) replace)
|
||||||
(setq accept-list (cons replace accept-list)))
|
(setq accept-list (cons replace accept-list)))
|
||||||
(let ((replace-word (car replace)))
|
(let ((replace-word (car replace)))
|
||||||
;; Recheck hand entered replacement word
|
;; Recheck hand entered replacement word.
|
||||||
(insert replace-word)
|
(insert replace-word)
|
||||||
(ispell-send-replacement (car poss) replace-word)
|
(ispell-send-replacement (car poss) replace-word)
|
||||||
(if (car (cdr replace))
|
(if (car (cdr replace))
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(delete-other-windows) ; to correctly show help.
|
(delete-other-windows) ; to correctly show help.
|
||||||
;; Assume case-replace &
|
;; Assume case-replace &
|
||||||
;; case-fold-search correct?
|
;; case-fold-search correct?
|
||||||
(query-replace (car poss) (car replace) t)))
|
(query-replace (car poss) (car replace) t)))
|
||||||
(goto-char word-start)
|
(goto-char word-start)
|
||||||
;; do not recheck if already accepted
|
;; Do not recheck if already accepted.
|
||||||
(if (member replace-word accept-list)
|
(if (member replace-word accept-list)
|
||||||
(setq accept-list (cons replace-word accept-list)
|
(setq accept-list (cons replace-word accept-list)
|
||||||
replace replace-word)
|
replace replace-word)
|
||||||
(let ((region-end (copy-marker ispell-region-end)))
|
(let ((region-end (copy-marker ispell-region-end)))
|
||||||
(setq recheck-region ispell-filter
|
(setq recheck-region ispell-filter
|
||||||
ispell-filter nil ; save filter
|
ispell-filter nil ; Save filter.
|
||||||
shift 0 ; already accounted
|
shift 0 ; Already accounted.
|
||||||
shift (ispell-region
|
shift (ispell-region
|
||||||
word-start
|
word-start
|
||||||
(+ word-start (length replace-word))
|
(+ word-start (length replace-word))
|
||||||
t shift))
|
t shift))
|
||||||
(if (null shift) ; quitting check.
|
(if (null shift) ; Quitting check.
|
||||||
(setq shift 0))
|
(setq shift 0))
|
||||||
(set-marker ispell-region-end region-end)
|
(set-marker ispell-region-end region-end)
|
||||||
(set-marker region-end nil)
|
(set-marker region-end nil)
|
||||||
(setq ispell-filter recheck-region
|
(setq ispell-filter recheck-region
|
||||||
recheck-region nil
|
recheck-region nil
|
||||||
replace replace-word)))))
|
replace replace-word)))))
|
||||||
|
|
||||||
(setq shift (+ shift (- (length replace) word-len)))
|
(setq shift (+ shift (- (length replace) word-len)))
|
||||||
|
|
||||||
;; Move line-start across word...
|
;; Move line-start across word...
|
||||||
;; new shift function does this now...
|
;; new shift function does this now...
|
||||||
;;(set-marker line-start (+ line-start
|
;;(set-marker line-start (+ line-start
|
||||||
;; (- (length replace)
|
;; (- (length replace)
|
||||||
;; (length (car poss)))))
|
;; (length (car poss)))))
|
||||||
))
|
))
|
||||||
(if (not ispell-quit)
|
(if (not ispell-quit)
|
||||||
;; FIXME: remove redundancy with identical code above.
|
;; FIXME: remove redundancy with identical code above.
|
||||||
(let (message-log-max)
|
(let (message-log-max)
|
||||||
(message
|
(message
|
||||||
"Continuing spelling check using %s with %s dictionary..."
|
"Continuing spelling check using %s with %s dictionary..."
|
||||||
(file-name-nondirectory ispell-program-name)
|
(file-name-nondirectory ispell-program-name)
|
||||||
(or ispell-current-dictionary "default"))))
|
(or ispell-current-dictionary "default"))))
|
||||||
(sit-for 0)
|
(sit-for 0)
|
||||||
(setq ispell-start (marker-position line-start)
|
(setq ispell-start (marker-position line-start)
|
||||||
ispell-end (marker-position line-end))
|
ispell-end (marker-position line-end))
|
||||||
;; Adjust markers when end of region lost from highlighting.
|
;; Adjust markers when end of region lost from highlighting.
|
||||||
(if (and (not recheck-region)
|
(if (and (not recheck-region)
|
||||||
(< ispell-end (+ word-start word-len)))
|
(< ispell-end (+ word-start word-len)))
|
||||||
(setq ispell-end (+ word-start word-len)))
|
(setq ispell-end (+ word-start word-len)))
|
||||||
(if (= word-start ispell-region-end)
|
(if (= word-start ispell-region-end)
|
||||||
(set-marker ispell-region-end (+ word-start word-len)))
|
(set-marker ispell-region-end (+ word-start word-len)))
|
||||||
;; going out of scope - unneeded
|
;; Going out of scope - unneeded.
|
||||||
(set-marker line-start nil)
|
(set-marker line-start nil)
|
||||||
(set-marker word-start nil)
|
(set-marker word-start nil)
|
||||||
(set-marker line-end nil)))
|
(set-marker line-end nil)))
|
||||||
;; finished with misspelling!
|
;; Finished with misspelling!
|
||||||
(setq ispell-filter (cdr ispell-filter)))
|
(setq ispell-filter (cdr ispell-filter)))
|
||||||
shift))
|
shift))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue