comparison lisp/packages/ispell.el @ 161:28f395d8dc7a r20-3b7

Import from CVS: tag r20-3b7
author cvs
date Mon, 13 Aug 2007 09:42:26 +0200
parents 1370575f1259
children
comparison
equal deleted inserted replaced
160:1c55655d6702 161:28f395d8dc7a
1064 (setq line (1+ line))) 1064 (setq line (1+ line)))
1065 line) 1065 line)
1066 max-lines)) 1066 max-lines))
1067 ;; not so good if there are over 20 or 30 options, but then, if 1067 ;; not so good if there are over 20 or 30 options, but then, if
1068 ;; there are that many you don't want to scan them all anyway... 1068 ;; there are that many you don't want to scan them all anyway...
1069 (when (integerp count)
1070 (setq count (int-char count)))
1069 (while (memq count command-characters) ; skip command characters. 1071 (while (memq count command-characters) ; skip command characters.
1070 (setq count (1+ count) 1072 (setq count (int-char (1+ count))
1071 skipped (1+ skipped))) 1073 skipped (1+ skipped)))
1072 (insert "(" count ") " (car choices) " ") 1074 (insert "(" count ") " (car choices) " ")
1073 (setq choices (cdr choices) 1075 (setq choices (cdr choices)
1074 count (1+ count))) 1076 count (1+ count)))
1075 (setq count (- count ?0 skipped))) 1077 (setq count (int-char (- count ?0 skipped))))
1076 1078
1077 ;; Assure word is visible 1079 ;; Assure word is visible
1078 (if (not (pos-visible-in-window-p end)) 1080 (if (not (pos-visible-in-window-p end))
1079 (sit-for 0)) 1081 (sit-for 0))
1080 ;; Display choices for misspelled word. 1082 ;; Display choices for misspelled word.
1122 (let ((inhibit-quit t)) 1124 (let ((inhibit-quit t))
1123 (setq char (if (fboundp 'read-char-exclusive) 1125 (setq char (if (fboundp 'read-char-exclusive)
1124 (read-char-exclusive) 1126 (read-char-exclusive)
1125 (read-char)) 1127 (read-char))
1126 skipped 0) 1128 skipped 0)
1127 (if (or quit-flag (= char ?\C-g)) ; C-g is like typing X 1129 (if (or quit-flag (eq char ?\C-g)) ; C-g is like typing X
1128 (setq char ?X 1130 (setq char ?X
1129 quit-flag nil))) 1131 quit-flag nil)))
1130 ;; Adjust num to array offset skipping command characters. 1132 ;; Adjust num to array offset skipping command characters.
1131 (let ((com-chars command-characters)) 1133 (let ((com-chars command-characters))
1132 (while com-chars 1134 (while com-chars
1134 (setq skipped (1+ skipped))) 1136 (setq skipped (1+ skipped)))
1135 (setq com-chars (cdr com-chars))) 1137 (setq com-chars (cdr com-chars)))
1136 (setq num (- char ?0 skipped))) 1138 (setq num (- char ?0 skipped)))
1137 1139
1138 (cond 1140 (cond
1139 ((= char ? ) nil) ; accept word this time only 1141 ((eq char ? ) nil) ; accept word this time only
1140 ((= char ?i) ; accept and insert word into pers dict 1142 ((eq char ?i) ; accept and insert word into pers dict
1141 (process-send-string ispell-process (concat "*" word "\n")) 1143 (process-send-string ispell-process (concat "*" word "\n"))
1142 (setq ispell-pdict-modified-p '(t)) ; dictionary modified! 1144 (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1143 nil) 1145 nil)
1144 ((or (= char ?a) (= char ?A)) ; accept word without insert 1146 ((or (eq char ?a) (eq char ?A)) ; accept word without insert
1145 (process-send-string ispell-process (concat "@" word "\n")) 1147 (process-send-string ispell-process (concat "@" word "\n"))
1146 (if (null ispell-pdict-modified-p) 1148 (if (null ispell-pdict-modified-p)
1147 (setq ispell-pdict-modified-p 1149 (setq ispell-pdict-modified-p
1148 (list ispell-pdict-modified-p))) 1150 (list ispell-pdict-modified-p)))
1149 (if (= char ?A) 0)) ; return 0 for ispell-add buffer-local 1151 (if (eq char ?A) 0)) ; return 0 for ispell-add buffer-local
1150 ((or (= char ?r) (= char ?R)) ; type in replacement 1152 ((or (eq char ?r) (eq char ?R)) ; type in replacement
1151 (if (or (= char ?R) ispell-query-replace-choices) 1153 (if (or (eq char ?R) ispell-query-replace-choices)
1152 (list (read-string "Query-replacement for: " word) t) 1154 (list (read-string "Query-replacement for: " word) t)
1153 (cons (read-string "Replacement for: " word) nil))) 1155 (cons (read-string "Replacement for: " word) nil)))
1154 ((or (= char ??) 1156 ((or (eq char ??)
1155 ;; XEmacs change: help-char may not be an int. 1157 ;; XEmacs change: help-char may not be an int.
1156 (eq char (event-to-character 1158 (eq char (event-to-character
1157 (character-to-event help-char))) 1159 (character-to-event help-char)))
1158 (= char ?\C-h)) 1160 (eq char ?\C-h))
1159 (ispell-help) 1161 (ispell-help)
1160 t) 1162 t)
1161 ;; Quit and move point back. 1163 ;; Quit and move point back.
1162 ((= char ?x) 1164 ((eq char ?x)
1163 (ispell-pdict-save ispell-silently-savep) 1165 (ispell-pdict-save ispell-silently-savep)
1164 (message "Exited spell-checking") 1166 (message "Exited spell-checking")
1165 (setq ispell-quit t) 1167 (setq ispell-quit t)
1166 nil) 1168 nil)
1167 ;; Quit and preserve point. 1169 ;; Quit and preserve point.
1168 ((= char ?X) 1170 ((eq char ?X)
1169 (ispell-pdict-save ispell-silently-savep) 1171 (ispell-pdict-save ispell-silently-savep)
1170 (message "%s" 1172 (message "%s"
1171 (substitute-command-keys 1173 (substitute-command-keys
1172 (concat "Spell-checking suspended;" 1174 (concat "Spell-checking suspended;"
1173 " use C-u \\[ispell-word] to resume"))) 1175 " use C-u \\[ispell-word] to resume")))
1174 (setq ispell-quit (max (point-min) 1176 (setq ispell-quit (max (point-min)
1175 (- (point) (length word)))) 1177 (- (point) (length word))))
1176 nil) 1178 nil)
1177 ((= char ?q) 1179 ((eq char ?q)
1178 (if (y-or-n-p "Really kill Ispell process? ") 1180 (if (y-or-n-p "Really kill Ispell process? ")
1179 (progn 1181 (progn
1180 (ispell-kill-ispell t) ; terminate process. 1182 (ispell-kill-ispell t) ; terminate process.
1181 (setq ispell-quit (or (not ispell-checking-message) 1183 (setq ispell-quit (or (not ispell-checking-message)
1182 (point)) 1184 (point))
1183 ispell-pdict-modified-p nil)) 1185 ispell-pdict-modified-p nil))
1184 t)) ; continue if they don't quit. 1186 t)) ; continue if they don't quit.
1185 ((= char ?l) 1187 ((eq char ?l)
1186 (let ((new-word (read-string 1188 (let ((new-word (read-string
1187 "Lookup string (`*' is wildcard): " 1189 "Lookup string (`*' is wildcard): "
1188 word)) 1190 word))
1189 (new-line 2)) 1191 (new-line 2))
1190 (if new-word 1192 (if new-word
1210 (setq new-line 1212 (setq new-line
1211 (1+ new-line))) 1213 (1+ new-line)))
1212 new-line) 1214 new-line)
1213 max-lines)) 1215 max-lines))
1214 (while (memq count command-characters) 1216 (while (memq count command-characters)
1215 (setq count (1+ count) 1217 (setq count (int-char (1+ count))
1216 skipped (1+ skipped))) 1218 skipped (1+ skipped)))
1217 (insert "(" count ") " (car choices) " ") 1219 (insert "(" count ") " (car choices) " ")
1218 (setq choices (cdr choices) 1220 (setq choices (cdr choices)
1219 count (1+ count))) 1221 count (1+ count)))
1220 (setq count (- count ?0 skipped))) 1222 (setq count (- count ?0 skipped)))
1233 (enlarge-window (- new-line line gr-bl)) 1235 (enlarge-window (- new-line line gr-bl))
1234 (shrink-window (- line new-line shr-bl))) 1236 (shrink-window (- line new-line shr-bl)))
1235 (setq line new-line))) 1237 (setq line new-line)))
1236 (select-window (next-window))))) 1238 (select-window (next-window)))))
1237 t) ; reselect from new choices 1239 t) ; reselect from new choices
1238 ((= char ?u) 1240 ((eq char ?u)
1239 (process-send-string ispell-process 1241 (process-send-string ispell-process
1240 (concat "*" (downcase word) "\n")) 1242 (concat "*" (downcase word) "\n"))
1241 (setq ispell-pdict-modified-p '(t)) ; dictionary modified! 1243 (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1242 nil) 1244 nil)
1243 ((= char ?m) ; type in what to insert 1245 ((eq char ?m) ; type in what to insert
1244 (process-send-string 1246 (process-send-string
1245 ispell-process (concat "*" (read-string "Insert: " word) 1247 ispell-process (concat "*" (read-string "Insert: " word)
1246 "\n")) 1248 "\n"))
1247 (setq ispell-pdict-modified-p '(t)) 1249 (setq ispell-pdict-modified-p '(t))
1248 (cons word nil)) 1250 (cons word nil))
1249 ((and (>= num 0) (< num count)) 1251 ((and (>= num 0) (< num count))
1250 (if ispell-query-replace-choices ; Query replace flag 1252 (if ispell-query-replace-choices ; Query replace flag
1251 (list (nth num miss) 'query-replace) 1253 (list (nth num miss) 'query-replace)
1252 (nth num miss))) 1254 (nth num miss)))
1253 ((= char ?\C-l) 1255 ((eq char ?\C-l)
1254 (redraw-display) t) 1256 (redraw-display) t)
1255 ((= char ?\C-r) 1257 ((eq char ?\C-r)
1256 (save-window-excursion (recursive-edit)) t) 1258 (save-window-excursion (recursive-edit)) t)
1257 ((= char ?\C-z) 1259 ((eq char ?\C-z)
1258 (funcall (key-binding "\C-z")) 1260 (funcall (key-binding "\C-z"))
1259 t) 1261 t)
1260 (t (ding) t)))))) 1262 (t (ding) t))))))
1261 result) 1263 result)
1262 ;; protected 1264 ;; protected