diff options
| author | Stefan Monnier | 2013-03-01 12:46:57 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-03-01 12:46:57 -0500 |
| commit | b5a5723d4e4bcc88d5b67a0edc59eb37e364296c (patch) | |
| tree | 7318733faead421caf7f2f00b5b41cc96c93794d | |
| parent | 7944eaa3362860c1afd7cc9d0d2ea4d71c289989 (diff) | |
| download | emacs-b5a5723d4e4bcc88d5b67a0edc59eb37e364296c.tar.gz emacs-b5a5723d4e4bcc88d5b67a0edc59eb37e364296c.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 371 |
2 files changed, 194 insertions, 184 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3183743db3e..604435bfc61 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-03-01 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * textmodes/ispell.el: Fix nitpicks and byte-compiler warnings. | ||
| 4 | (ispell-print-if-debug): Build `format' in. Avoid end-of-buffer. | ||
| 5 | (ispell-parse-hunspell-affix-file): Avoid beginning-of-buffer. | ||
| 6 | Use dict-key rather than dict-name for the error message. | ||
| 7 | |||
| 1 | 2013-03-01 Thierry Volpiatto <thierry.volpiatto@gmail.com> | 8 | 2013-03-01 Thierry Volpiatto <thierry.volpiatto@gmail.com> |
| 2 | 9 | ||
| 3 | * net/net-utils.el (net-utils-run-simple): Don't display-buffer | 10 | * net/net-utils.el (net-utils-run-simple): Don't display-buffer |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 7b26b2f8479..92e21c300c7 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -749,8 +749,10 @@ OTHERCHARS slots of the alist should contain the same character | |||
| 749 | set as casechars and otherchars in the LANGUAGE.aff file \(e.g., | 749 | set as casechars and otherchars in the LANGUAGE.aff file \(e.g., |
| 750 | english.aff\). aspell and hunspell don't have this limitation.") | 750 | english.aff\). aspell and hunspell don't have this limitation.") |
| 751 | 751 | ||
| 752 | (defvar ispell-really-aspell nil) ; Non-nil if we can use aspell extensions. | 752 | (defvar ispell-really-aspell nil |
| 753 | (defvar ispell-really-hunspell nil) ; Non-nil if we can use hunspell extensions. | 753 | "Non-nil if we can use aspell extensions.") |
| 754 | (defvar ispell-really-hunspell nil | ||
| 755 | "Non-nil if we can use hunspell extensions.") | ||
| 754 | (defvar ispell-encoding8-command nil | 756 | (defvar ispell-encoding8-command nil |
| 755 | "Command line option prefix to select encoding if supported, nil otherwise. | 757 | "Command line option prefix to select encoding if supported, nil otherwise. |
| 756 | If setting the encoding is supported by spellchecker and is selectable from | 758 | 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." | |||
| 860 | (if (string-match "\\`aspell" speller) "-v" "-vv")))) | 862 | (if (string-match "\\`aspell" speller) "-v" "-vv")))) |
| 861 | (goto-char (point-min)) | 863 | (goto-char (point-min)) |
| 862 | (if interactivep | 864 | (if interactivep |
| 863 | ;; report version information of ispell and ispell.el | 865 | ;; Report version information of ispell and ispell.el |
| 864 | (progn | 866 | (progn |
| 865 | (end-of-line) | 867 | (end-of-line) |
| 866 | (setq result (concat (buffer-substring-no-properties (point-min) | 868 | (setq result (concat (buffer-substring-no-properties (point-min) |
| @@ -955,12 +957,12 @@ See `ispell-buffer-with-debug' for an example of use." | |||
| 955 | (erase-buffer))) | 957 | (erase-buffer))) |
| 956 | ispell-debug-buffer)) | 958 | ispell-debug-buffer)) |
| 957 | 959 | ||
| 958 | (defsubst ispell-print-if-debug (string) | 960 | (defsubst ispell-print-if-debug (format &rest args) |
| 959 | "Print STRING to `ispell-debug-buffer' buffer if enabled." | 961 | "Print message to `ispell-debug-buffer' buffer if enabled." |
| 960 | (if (boundp 'ispell-debug-buffer) | 962 | (if (boundp 'ispell-debug-buffer) |
| 961 | (with-current-buffer ispell-debug-buffer | 963 | (with-current-buffer ispell-debug-buffer |
| 962 | (end-of-buffer) | 964 | (goto-char (point-max)) |
| 963 | (insert string)))) | 965 | (insert (apply #'format format args))))) |
| 964 | 966 | ||
| 965 | 967 | ||
| 966 | ;; The preparation of the menu bar menu must be autoloaded | 968 | ;; The preparation of the menu bar menu must be autoloaded |
| @@ -1133,13 +1135,13 @@ Return the new dictionary alist." | |||
| 1133 | ;; Make ispell.el work better with hunspell. | 1135 | ;; Make ispell.el work better with hunspell. |
| 1134 | 1136 | ||
| 1135 | (defvar ispell-hunspell-dict-paths-alist nil | 1137 | (defvar ispell-hunspell-dict-paths-alist nil |
| 1136 | "Alist of parsed hunspell dicts and associated affix files. | 1138 | "Alist of parsed hunspell dicts and associated affix files. |
| 1137 | Will be used to parse corresponding .aff file and create associated | 1139 | Will be used to parse corresponding .aff file and create associated |
| 1138 | parameters to be inserted into `ispell-hunspell-dictionary-alist'. | 1140 | parameters to be inserted into `ispell-hunspell-dictionary-alist'. |
| 1139 | Internal use.") | 1141 | Internal use.") |
| 1140 | 1142 | ||
| 1141 | (defvar ispell-hunspell-dictionary-alist nil | 1143 | (defvar ispell-hunspell-dictionary-alist nil |
| 1142 | "Alist of parsed hunspell dicts and associated parameters. | 1144 | "Alist of parsed hunspell dicts and associated parameters. |
| 1143 | This alist will initially contain names of found dicts. Associated | 1145 | This alist will initially contain names of found dicts. Associated |
| 1144 | parameters will be added when dict is used for the first time. | 1146 | parameters will be added when dict is used for the first time. |
| 1145 | Internal use.") | 1147 | Internal use.") |
| @@ -1150,7 +1152,8 @@ Value will be extracted from hunspell affix file and used for | |||
| 1150 | all uninitialized dicts using that affix file." | 1152 | all uninitialized dicts using that affix file." |
| 1151 | (if (cadr (assoc dict ispell-dictionary-alist)) | 1153 | (if (cadr (assoc dict ispell-dictionary-alist)) |
| 1152 | (message "ispell-hfde: Non void entry for %s. Skipping.\n" dict) | 1154 | (message "ispell-hfde: Non void entry for %s. Skipping.\n" dict) |
| 1153 | (let ((dict-alias (cadr (assoc dict ispell-hunspell-dictionary-equivs-alist))) | 1155 | (let ((dict-alias |
| 1156 | (cadr (assoc dict ispell-hunspell-dictionary-equivs-alist))) | ||
| 1154 | (use-for-dicts (list dict)) | 1157 | (use-for-dicts (list dict)) |
| 1155 | (dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict))) | 1158 | (dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict))) |
| 1156 | newlist) | 1159 | newlist) |
| @@ -1162,10 +1165,12 @@ all uninitialized dicts using that affix file." | |||
| 1162 | (member dict-alias dict-equiv-alist-entry)) | 1165 | (member dict-alias dict-equiv-alist-entry)) |
| 1163 | (dolist ( tmp-dict (list dict-equiv-key dict-equiv-value)) | 1166 | (dolist ( tmp-dict (list dict-equiv-key dict-equiv-value)) |
| 1164 | (if (cadr (assoc tmp-dict ispell-dictionary-alist)) | 1167 | (if (cadr (assoc tmp-dict ispell-dictionary-alist)) |
| 1165 | (ispell-print-if-debug (format "ispell-hfde: %s already expanded. Skipping.\n" tmp-dict)) | 1168 | (ispell-print-if-debug |
| 1169 | "ispell-hfde: %s already expanded. Skipping.\n" tmp-dict) | ||
| 1166 | (add-to-list 'use-for-dicts tmp-dict)))))) | 1170 | (add-to-list 'use-for-dicts tmp-dict)))))) |
| 1167 | (ispell-print-if-debug (format "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts)) | 1171 | (ispell-print-if-debug |
| 1168 | ;; The final loop | 1172 | "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts) |
| 1173 | ;; The final loop. | ||
| 1169 | (dolist (entry ispell-dictionary-alist) | 1174 | (dolist (entry ispell-dictionary-alist) |
| 1170 | (if (member (car entry) use-for-dicts) | 1175 | (if (member (car entry) use-for-dicts) |
| 1171 | (add-to-list 'newlist | 1176 | (add-to-list 'newlist |
| @@ -1178,39 +1183,41 @@ all uninitialized dicts using that affix file." | |||
| 1178 | Return a list in `ispell-dictionary-alist' format." | 1183 | Return a list in `ispell-dictionary-alist' format." |
| 1179 | (let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist)))) | 1184 | (let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist)))) |
| 1180 | (unless affix-file | 1185 | (unless affix-file |
| 1181 | (error "ispell-phaf: No matching entry for %s.\n" dict-name)) | 1186 | (error "ispell-phaf: No matching entry for %s.\n" dict-key)) |
| 1182 | (if (file-exists-p affix-file) | 1187 | (if (not (file-exists-p affix-file)) |
| 1183 | (let ((dict-name (file-name-sans-extension (file-name-nondirectory affix-file))) | 1188 | (error "ispell-phaf: File \"%s\" not found.\n" affix-file)) |
| 1184 | otherchars-string otherchars-list) | 1189 | (let ((dict-name (file-name-sans-extension |
| 1185 | (with-temp-buffer | 1190 | (file-name-nondirectory affix-file))) |
| 1186 | (insert-file-contents affix-file) | 1191 | otherchars-string otherchars-list) |
| 1187 | (setq otherchars-string | 1192 | (with-temp-buffer |
| 1188 | (save-excursion | 1193 | (insert-file-contents affix-file) |
| 1189 | (beginning-of-buffer) | 1194 | (setq otherchars-string |
| 1190 | (if (search-forward-regexp "^WORDCHARS +" nil t ) | 1195 | (save-excursion |
| 1191 | (buffer-substring (point) | 1196 | (goto-char (point-min)) |
| 1192 | (progn (end-of-line) (point)))))) | 1197 | (if (search-forward-regexp "^WORDCHARS +" nil t ) |
| 1193 | ;; Remove trailing whitespace and extra stuff. Make list if non-nil. | 1198 | (buffer-substring (point) |
| 1194 | (setq otherchars-list | 1199 | (progn (end-of-line) (point)))))) |
| 1195 | (if otherchars-string | 1200 | ;; Remove trailing whitespace and extra stuff. Make list if |
| 1196 | (split-string | 1201 | ;; non-nil. |
| 1197 | (if (string-match " +.*$" otherchars-string) | 1202 | (setq otherchars-list |
| 1198 | (replace-match "" nil nil otherchars-string) | 1203 | (if otherchars-string |
| 1199 | otherchars-string) | 1204 | (split-string |
| 1200 | "" t))) | 1205 | (if (string-match " +.*$" otherchars-string) |
| 1201 | 1206 | (replace-match "" nil nil otherchars-string) | |
| 1202 | ;; Fill dict entry | 1207 | otherchars-string) |
| 1203 | (list dict-key | 1208 | "" t))) |
| 1204 | "[[:alpha:]]" | 1209 | |
| 1205 | "[^[:alpha:]]" | 1210 | ;; Fill dict entry |
| 1206 | (if otherchars-list | 1211 | (list dict-key |
| 1207 | (regexp-opt otherchars-list) | 1212 | "[[:alpha:]]" |
| 1208 | "") | 1213 | "[^[:alpha:]]" |
| 1209 | t ;; many-otherchars-p: We can't tell, set to t | 1214 | (if otherchars-list |
| 1210 | (list "-d" dict-name) | 1215 | (regexp-opt otherchars-list) |
| 1211 | nil ;; extended-char-mode: not supported by hunspell | 1216 | "") |
| 1212 | 'utf-8))) | 1217 | t ; many-otherchars-p: We can't tell, set to t. |
| 1213 | (error "ispell-phaf: File \"%s\" not found.\n" affix-file)))) | 1218 | (list "-d" dict-name) |
| 1219 | nil ; extended-char-mode: not supported by hunspell! | ||
| 1220 | 'utf-8))))) | ||
| 1214 | 1221 | ||
| 1215 | (defun ispell-find-hunspell-dictionaries () | 1222 | (defun ispell-find-hunspell-dictionaries () |
| 1216 | "Look for installed hunspell dictionaries. | 1223 | "Look for installed hunspell dictionaries. |
| @@ -1247,19 +1254,19 @@ entries if a specific dict was found." | |||
| 1247 | ;; Entry has an associated .aff file and no previous value. | 1254 | ;; Entry has an associated .aff file and no previous value. |
| 1248 | (let ((affix-file (expand-file-name affix-file))) | 1255 | (let ((affix-file (expand-file-name affix-file))) |
| 1249 | (ispell-print-if-debug | 1256 | (ispell-print-if-debug |
| 1250 | (format "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n" | 1257 | "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n" |
| 1251 | dict full-name basename affix-file)) | 1258 | dict full-name basename affix-file) |
| 1252 | (add-to-list 'ispell-hunspell-dict-paths-alist | 1259 | (add-to-list 'ispell-hunspell-dict-paths-alist |
| 1253 | (list basename affix-file))) | 1260 | (list basename affix-file))) |
| 1254 | (ispell-print-if-debug | 1261 | (ispell-print-if-debug |
| 1255 | (format "-- ispell-fhd: Skipping entry: %s\n" dict)))))) | 1262 | "-- ispell-fhd: Skipping entry: %s\n" dict))))) |
| 1256 | ;; Remove entry from aliases alist if explicit dict was found. | 1263 | ;; Remove entry from aliases alist if explicit dict was found. |
| 1257 | (let (newlist) | 1264 | (let (newlist) |
| 1258 | (dolist (dict ispell-hunspell-dictionary-equivs-alist) | 1265 | (dolist (dict ispell-hunspell-dictionary-equivs-alist) |
| 1259 | (if (assoc (car dict) ispell-hunspell-dict-paths-alist) | 1266 | (if (assoc (car dict) ispell-hunspell-dict-paths-alist) |
| 1260 | (ispell-print-if-debug | 1267 | (ispell-print-if-debug |
| 1261 | (format "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" | 1268 | "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" |
| 1262 | (car dict))) | 1269 | (car dict)) |
| 1263 | (add-to-list 'newlist dict))) | 1270 | (add-to-list 'newlist dict))) |
| 1264 | (setq ispell-hunspell-dictionary-equivs-alist newlist)) | 1271 | (setq ispell-hunspell-dictionary-equivs-alist newlist)) |
| 1265 | ;; Add known hunspell aliases | 1272 | ;; Add known hunspell aliases |
| @@ -1274,9 +1281,10 @@ entries if a specific dict was found." | |||
| 1274 | (if (and (assoc dict-equiv-value ispell-hunspell-dict-paths-alist) | 1281 | (if (and (assoc dict-equiv-value ispell-hunspell-dict-paths-alist) |
| 1275 | (not (assoc dict-equiv-key ispell-hunspell-dict-paths-alist)) | 1282 | (not (assoc dict-equiv-key ispell-hunspell-dict-paths-alist)) |
| 1276 | (not (member dict-equiv-key exclude-aliases))) | 1283 | (not (member dict-equiv-key exclude-aliases))) |
| 1277 | (let ((affix-file (cadr (assoc dict-equiv-value ispell-hunspell-dict-paths-alist)))) | 1284 | (let ((affix-file (cadr (assoc dict-equiv-value |
| 1278 | (ispell-print-if-debug (format "++ ispell-fhd: Adding alias %s -> %s.\n" | 1285 | ispell-hunspell-dict-paths-alist)))) |
| 1279 | dict-equiv-key affix-file)) | 1286 | (ispell-print-if-debug "++ ispell-fhd: Adding alias %s -> %s.\n" |
| 1287 | dict-equiv-key affix-file) | ||
| 1280 | (add-to-list | 1288 | (add-to-list |
| 1281 | 'ispell-hunspell-dict-paths-alist | 1289 | 'ispell-hunspell-dict-paths-alist |
| 1282 | (list dict-equiv-key affix-file)))))) | 1290 | (list dict-equiv-key affix-file)))))) |
| @@ -3207,29 +3215,25 @@ amount for last line processed." | |||
| 3207 | (query-fcc t) | 3215 | (query-fcc t) |
| 3208 | in-comment key) | 3216 | in-comment key) |
| 3209 | (ispell-print-if-debug | 3217 | (ispell-print-if-debug |
| 3210 | (concat | 3218 | "ispell-region: (ispell-skip-region-list):\n%s |
| 3211 | (format | 3219 | ispell-region: (ispell-begin-skip-region-regexp):\n%s |
| 3212 | "ispell-region: (ispell-skip-region-list):\n%s\n" | 3220 | ispell-region: Search for first region to skip after (ispell-begin-skip-region-regexp)\n" |
| 3213 | (ispell-skip-region-list)) | 3221 | (ispell-skip-region-list) |
| 3214 | (format | 3222 | (ispell-begin-skip-region-regexp)) |
| 3215 | "ispell-region: (ispell-begin-skip-region-regexp):\n%s\n" | ||
| 3216 | (ispell-begin-skip-region-regexp)) | ||
| 3217 | "ispell-region: Search for first region to skip after (ispell-begin-skip-region-regexp)\n")) | ||
| 3218 | (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) | 3223 | (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) |
| 3219 | (progn | 3224 | (progn |
| 3220 | (setq key (match-string-no-properties 0)) | 3225 | (setq key (match-string-no-properties 0)) |
| 3221 | (set-marker skip-region-start (- (point) (length key))) | 3226 | (set-marker skip-region-start (- (point) (length key))) |
| 3222 | (goto-char reg-start) | 3227 | (goto-char reg-start) |
| 3223 | (ispell-print-if-debug | 3228 | (ispell-print-if-debug |
| 3224 | (format "ispell-region: First skip: %s at (pos,line,column): (%s,%s,%s).\n" | 3229 | "ispell-region: First skip: %s at (pos,line,column): (%s,%s,%s).\n" |
| 3225 | key | 3230 | key |
| 3226 | (save-excursion (goto-char skip-region-start) (point)) | 3231 | (save-excursion (goto-char skip-region-start) (point)) |
| 3227 | (line-number-at-pos skip-region-start) | 3232 | (line-number-at-pos skip-region-start) |
| 3228 | (save-excursion (goto-char skip-region-start) (current-column)))))) | 3233 | (save-excursion (goto-char skip-region-start) (current-column))))) |
| 3229 | (ispell-print-if-debug | 3234 | (ispell-print-if-debug |
| 3230 | (format | 3235 | "ispell-region: Continue spell-checking with %s and %s dictionary...\n" |
| 3231 | "ispell-region: Continue spell-checking with %s and %s dictionary...\n" | 3236 | program-basename dictionary) |
| 3232 | program-basename dictionary)) | ||
| 3233 | (set-marker rstart reg-start) | 3237 | (set-marker rstart reg-start) |
| 3234 | (set-marker ispell-region-end reg-end) | 3238 | (set-marker ispell-region-end reg-end) |
| 3235 | (while (and (not ispell-quit) | 3239 | (while (and (not ispell-quit) |
| @@ -3264,11 +3268,11 @@ amount for last line processed." | |||
| 3264 | (- (point) (length key))) | 3268 | (- (point) (length key))) |
| 3265 | (goto-char rstart) | 3269 | (goto-char rstart) |
| 3266 | (ispell-print-if-debug | 3270 | (ispell-print-if-debug |
| 3267 | (format "ispell-region: Next skip: %s at (pos,line,column): (%s,%s,%s).\n" | 3271 | "ispell-region: Next skip: %s at (pos,line,column): (%s,%s,%s).\n" |
| 3268 | key | 3272 | key |
| 3269 | (save-excursion (goto-char skip-region-start) (point)) | 3273 | (save-excursion (goto-char skip-region-start) (point)) |
| 3270 | (line-number-at-pos skip-region-start) | 3274 | (line-number-at-pos skip-region-start) |
| 3271 | (save-excursion (goto-char skip-region-start) (current-column))))) | 3275 | (save-excursion (goto-char skip-region-start) (current-column)))) |
| 3272 | (set-marker skip-region-start nil)))) | 3276 | (set-marker skip-region-start nil)))) |
| 3273 | (setq reg-end (max (point) | 3277 | (setq reg-end (max (point) |
| 3274 | (if (marker-position skip-region-start) | 3278 | (if (marker-position skip-region-start) |
| @@ -3287,9 +3291,8 @@ amount for last line processed." | |||
| 3287 | (string (ispell-get-line | 3291 | (string (ispell-get-line |
| 3288 | ispell-start ispell-end add-comment))) | 3292 | ispell-start ispell-end add-comment))) |
| 3289 | (ispell-print-if-debug | 3293 | (ispell-print-if-debug |
| 3290 | (format | 3294 | "ispell-region: string pos (%s->%s), eol: %s, [in-comment]: [%s], [add-comment]: [%s], [string]: [%s]\n" |
| 3291 | "ispell-region: string pos (%s->%s), eol: %s, [in-comment]: [%s], [add-comment]: [%s], [string]: [%s]\n" | 3295 | ispell-start ispell-end (point-at-eol) in-comment add-comment string) |
| 3292 | ispell-start ispell-end (point-at-eol) in-comment add-comment string)) | ||
| 3293 | (if add-comment ; account for comment chars added | 3296 | (if add-comment ; account for comment chars added |
| 3294 | (setq ispell-start (- ispell-start (length add-comment)) | 3297 | (setq ispell-start (- ispell-start (length add-comment)) |
| 3295 | add-comment nil)) | 3298 | add-comment nil)) |
| @@ -3576,118 +3579,118 @@ Returns the sum SHIFT due to changes in word replacements." | |||
| 3576 | (let* ((ispell-pipe-word (car poss)) | 3579 | (let* ((ispell-pipe-word (car poss)) |
| 3577 | (actual-point (marker-position word-start)) | 3580 | (actual-point (marker-position word-start)) |
| 3578 | (actual-line (line-number-at-pos actual-point)) | 3581 | (actual-line (line-number-at-pos actual-point)) |
| 3579 | (actual-column (save-excursion (goto-char actual-point) (current-column)))) | 3582 | (actual-column (save-excursion (goto-char actual-point) |
| 3583 | (current-column)))) | ||
| 3580 | (ispell-print-if-debug | 3584 | (ispell-print-if-debug |
| 3581 | (concat | 3585 | "ispell-process-line: Ispell misalignment error: |
| 3582 | "ispell-process-line: Ispell misalignment error:\n" | 3586 | [Word from ispell pipe]: [%s], actual (point,line,column): (%s,%s,%s)\n" |
| 3583 | (format " [Word from ispell pipe]: [%s], actual (point,line,column): (%s,%s,%s)\n" | 3587 | ispell-pipe-word actual-point actual-line actual-column) |
| 3584 | ispell-pipe-word actual-point actual-line actual-column))) | 3588 | (error (concat "Ispell misalignment: word " |
| 3585 | (error (concat "Ispell misalignment: word " | 3589 | "`%s' point %d; probably incompatible versions") |
| 3586 | "`%s' point %d; probably incompatible versions") | 3590 | ispell-pipe-word actual-point))) |
| 3587 | ispell-pipe-word actual-point))) | 3591 | ;; ispell-cmd-loop can go recursive & change buffer |
| 3588 | ;; ispell-cmd-loop can go recursive & change buffer | 3592 | (if ispell-keep-choices-win |
| 3589 | (if ispell-keep-choices-win | 3593 | (setq replace (ispell-command-loop |
| 3590 | (setq replace (ispell-command-loop | 3594 | (car (cdr (cdr poss))) |
| 3591 | (car (cdr (cdr poss))) | 3595 | (car (cdr (cdr (cdr poss)))) |
| 3592 | (car (cdr (cdr (cdr poss)))) | 3596 | (car poss) (marker-position word-start) |
| 3593 | (car poss) (marker-position word-start) | 3597 | (+ word-len (marker-position word-start)))) |
| 3594 | (+ word-len (marker-position word-start)))) | 3598 | (save-window-excursion |
| 3595 | (save-window-excursion | 3599 | (setq replace (ispell-command-loop |
| 3596 | (setq replace (ispell-command-loop | 3600 | (car (cdr (cdr poss))) |
| 3597 | (car (cdr (cdr poss))) | 3601 | (car (cdr (cdr (cdr poss)))) |
| 3598 | (car (cdr (cdr (cdr poss)))) | 3602 | (car poss) (marker-position word-start) |
| 3599 | (car poss) (marker-position word-start) | 3603 | (+ word-len (marker-position word-start)))))) |
| 3600 | (+ word-len (marker-position word-start)))))) | 3604 | |
| 3601 | 3605 | (goto-char word-start) | |
| 3602 | (goto-char word-start) | 3606 | ;; Recheck when query replace edit changes misspelled word. |
| 3603 | ;; Recheck when query replace edit changes misspelled word. | 3607 | ;; Error in tex mode when a potential math mode change exists. |
| 3604 | ;; Error in tex mode when a potential math mode change exists. | 3608 | (if (and replace (listp replace) (= 2 (length replace))) |
| 3605 | (if (and replace (listp replace) (= 2 (length replace))) | 3609 | (if (and (eq ispell-parser 'tex) |
| 3606 | (if (and (eq ispell-parser 'tex) | 3610 | (string-match "[\\\\][]()[]\\|\\\\begin\\|\\$" |
| 3607 | (string-match "[\\\\][]()[]\\|\\\\begin\\|\\$" | 3611 | (regexp-quote string))) |
| 3608 | (regexp-quote string))) | 3612 | (error |
| 3609 | (error | 3613 | "Don't start query replace on a line with math characters" |
| 3610 | "Don't start query replace on a line with math characters" | 3614 | ) |
| 3611 | ) | 3615 | (set-marker line-end (point)) |
| 3612 | (set-marker line-end (point)) | 3616 | (setq ispell-filter nil |
| 3613 | (setq ispell-filter nil | 3617 | recheck-region t))) |
| 3614 | recheck-region t))) | 3618 | |
| 3615 | 3619 | ;; Insert correction if needed. | |
| 3616 | ;; insert correction if needed | 3620 | (cond |
| 3617 | (cond | 3621 | ((or (null replace) |
| 3618 | ((or (null replace) | 3622 | (equal 0 replace)) ; ACCEPT/INSERT |
| 3619 | (equal 0 replace)) ; ACCEPT/INSERT | 3623 | (if (equal 0 replace) ; BUFFER-LOCAL DICT ADD |
| 3620 | (if (equal 0 replace) ; BUFFER-LOCAL DICT ADD | 3624 | (ispell-add-per-file-word-list (car poss))) |
| 3621 | (ispell-add-per-file-word-list (car poss))) | 3625 | ;; Do not recheck accepted word on this line. |
| 3622 | ;; do not recheck accepted word on this line | 3626 | (setq accept-list (cons (car poss) accept-list))) |
| 3623 | (setq accept-list (cons (car poss) accept-list))) | 3627 | (t ; Replacement word selected or entered. |
| 3624 | (t ; replacement word selected or entered | 3628 | (delete-region (point) (+ word-len (point))) |
| 3625 | (delete-region (point) (+ word-len (point))) | 3629 | (if (not (listp replace)) |
| 3626 | (if (not (listp replace)) | 3630 | (progn |
| 3627 | (progn | 3631 | (insert replace) ; Insert dictionary word. |
| 3628 | (insert replace) ; insert dictionary word | 3632 | (ispell-send-replacement (car poss) replace) |
| 3629 | (ispell-send-replacement (car poss) replace) | 3633 | (setq accept-list (cons replace accept-list))) |
| 3630 | (setq accept-list (cons replace accept-list))) | 3634 | (let ((replace-word (car replace))) |
| 3631 | (let ((replace-word (car replace))) | 3635 | ;; Recheck hand entered replacement word. |
| 3632 | ;; Recheck hand entered replacement word | 3636 | (insert replace-word) |
| 3633 | (insert replace-word) | 3637 | (ispell-send-replacement (car poss) replace-word) |
| 3634 | (ispell-send-replacement (car poss) replace-word) | 3638 | (if (car (cdr replace)) |
| 3635 | (if (car (cdr replace)) | 3639 | (save-window-excursion |
| 3636 | (save-window-excursion | 3640 | (delete-other-windows) ; to correctly show help. |
| 3637 | (delete-other-windows) ; to correctly show help. | 3641 | ;; Assume case-replace & |
| 3638 | ;; Assume case-replace & | 3642 | ;; case-fold-search correct? |
| 3639 | ;; case-fold-search correct? | 3643 | (query-replace (car poss) (car replace) t))) |
| 3640 | (query-replace (car poss) (car replace) t))) | 3644 | (goto-char word-start) |
| 3641 | (goto-char word-start) | 3645 | ;; Do not recheck if already accepted. |
| 3642 | ;; do not recheck if already accepted | 3646 | (if (member replace-word accept-list) |
| 3643 | (if (member replace-word accept-list) | 3647 | (setq accept-list (cons replace-word accept-list) |
| 3644 | (setq accept-list (cons replace-word accept-list) | 3648 | replace replace-word) |
| 3645 | replace replace-word) | 3649 | (let ((region-end (copy-marker ispell-region-end))) |
| 3646 | (let ((region-end (copy-marker ispell-region-end))) | 3650 | (setq recheck-region ispell-filter |
| 3647 | (setq recheck-region ispell-filter | 3651 | ispell-filter nil ; Save filter. |
| 3648 | ispell-filter nil ; save filter | 3652 | shift 0 ; Already accounted. |
| 3649 | shift 0 ; already accounted | 3653 | shift (ispell-region |
| 3650 | shift (ispell-region | 3654 | word-start |
| 3651 | word-start | 3655 | (+ word-start (length replace-word)) |
| 3652 | (+ word-start (length replace-word)) | 3656 | t shift)) |
| 3653 | t shift)) | 3657 | (if (null shift) ; Quitting check. |
| 3654 | (if (null shift) ; quitting check. | 3658 | (setq shift 0)) |
| 3655 | (setq shift 0)) | 3659 | (set-marker ispell-region-end region-end) |
| 3656 | (set-marker ispell-region-end region-end) | 3660 | (set-marker region-end nil) |
| 3657 | (set-marker region-end nil) | 3661 | (setq ispell-filter recheck-region |
| 3658 | (setq ispell-filter recheck-region | 3662 | recheck-region nil |
| 3659 | recheck-region nil | 3663 | replace replace-word))))) |
| 3660 | replace replace-word))))) | 3664 | |
| 3661 | 3665 | (setq shift (+ shift (- (length replace) word-len))) | |
| 3662 | (setq shift (+ shift (- (length replace) word-len))) | 3666 | |
| 3663 | 3667 | ;; Move line-start across word... | |
| 3664 | ;; Move line-start across word... | 3668 | ;; new shift function does this now... |
| 3665 | ;; new shift function does this now... | 3669 | ;;(set-marker line-start (+ line-start |
| 3666 | ;;(set-marker line-start (+ line-start | 3670 | ;; (- (length replace) |
| 3667 | ;; (- (length replace) | 3671 | ;; (length (car poss))))) |
| 3668 | ;; (length (car poss))))) | 3672 | )) |
| 3669 | )) | 3673 | (if (not ispell-quit) |
| 3670 | (if (not ispell-quit) | ||
| 3671 | ;; FIXME: remove redundancy with identical code above. | 3674 | ;; FIXME: remove redundancy with identical code above. |
| 3672 | (let (message-log-max) | 3675 | (let (message-log-max) |
| 3673 | (message | 3676 | (message |
| 3674 | "Continuing spelling check using %s with %s dictionary..." | 3677 | "Continuing spelling check using %s with %s dictionary..." |
| 3675 | (file-name-nondirectory ispell-program-name) | 3678 | (file-name-nondirectory ispell-program-name) |
| 3676 | (or ispell-current-dictionary "default")))) | 3679 | (or ispell-current-dictionary "default")))) |
| 3677 | (sit-for 0) | 3680 | (sit-for 0) |
| 3678 | (setq ispell-start (marker-position line-start) | 3681 | (setq ispell-start (marker-position line-start) |
| 3679 | ispell-end (marker-position line-end)) | 3682 | ispell-end (marker-position line-end)) |
| 3680 | ;; Adjust markers when end of region lost from highlighting. | 3683 | ;; Adjust markers when end of region lost from highlighting. |
| 3681 | (if (and (not recheck-region) | 3684 | (if (and (not recheck-region) |
| 3682 | (< ispell-end (+ word-start word-len))) | 3685 | (< ispell-end (+ word-start word-len))) |
| 3683 | (setq ispell-end (+ word-start word-len))) | 3686 | (setq ispell-end (+ word-start word-len))) |
| 3684 | (if (= word-start ispell-region-end) | 3687 | (if (= word-start ispell-region-end) |
| 3685 | (set-marker ispell-region-end (+ word-start word-len))) | 3688 | (set-marker ispell-region-end (+ word-start word-len))) |
| 3686 | ;; going out of scope - unneeded | 3689 | ;; Going out of scope - unneeded. |
| 3687 | (set-marker line-start nil) | 3690 | (set-marker line-start nil) |
| 3688 | (set-marker word-start nil) | 3691 | (set-marker word-start nil) |
| 3689 | (set-marker line-end nil))) | 3692 | (set-marker line-end nil))) |
| 3690 | ;; finished with misspelling! | 3693 | ;; Finished with misspelling! |
| 3691 | (setq ispell-filter (cdr ispell-filter))) | 3694 | (setq ispell-filter (cdr ispell-filter))) |
| 3692 | shift)) | 3695 | shift)) |
| 3693 | 3696 | ||