comparison lisp/textmodes/=ispell4.el @ 2837:00f822101e49

(ispell): Deactivate mark before the Ispell run. (ispell-point): Delete the sit-for; it was confusing. (ispell): Don't use save-excursion; just restore current buffer. (ispell-next): Don't save-excursion or save-window-excursion. (ispell-point): Don't save-excursion. (ispell-window-configuration): New variable. (ispell-show-choices): Set it if not nil. (ispell-next): Initialize to nil. Restore at end.
author Richard M. Stallman <rms@gnu.org>
date Sun, 16 May 1993 21:31:39 +0000
parents b65cf676a09b
children e931a98b2f36
comparison
equal deleted inserted replaced
2836:d95acb2243f9 2837:00f822101e49
50 "A list of markers corresponding to the output of the ISPELL :file command.") 50 "A list of markers corresponding to the output of the ISPELL :file command.")
51 51
52 ;list of words that the user has accepted, but that might still 52 ;list of words that the user has accepted, but that might still
53 ;be on the bad-words list 53 ;be on the bad-words list
54 (defvar ispell-recently-accepted nil) 54 (defvar ispell-recently-accepted nil)
55
56 ;; Non-nil means we have started showing an alternatives window.
57 ;; This is the window config from before then.
58 (defvar ispell-window-configuration)
55 59
56 ;t when :dump command needed 60 ;t when :dump command needed
57 (defvar ispell-dump-needed nil) 61 (defvar ispell-dump-needed nil)
58 62
59 (defun ispell-flush-bad-words () 63 (defun ispell-flush-bad-words ()
223 (if (null buf) 227 (if (null buf)
224 (setq buf (current-buffer))) 228 (setq buf (current-buffer)))
225 (setq buf (get-buffer buf)) 229 (setq buf (get-buffer buf))
226 (if (null buf) 230 (if (null buf)
227 (error "Can't find buffer")) 231 (error "Can't find buffer"))
232 ;; Deactivate the mark, because we'll do it anyway if we change something,
233 ;; and a region highlight while in the Ispell loop is distracting.
234 (if transient-mark-mode
235 (progn
236 (setq mark-active nil)
237 (run-hooks 'deactivate-mark-hook)))
228 (save-excursion 238 (save-excursion
229 (set-buffer buf) 239 (set-buffer buf)
230 (let ((filename buffer-file-name) 240 (let ((filename buffer-file-name)
231 (delete-temp nil)) 241 (delete-temp nil))
232 (unwind-protect 242 (unwind-protect
233 (progn 243 (progn
234 (cond ((null filename) 244 (cond ((null filename)
235 (setq filename (make-temp-name "/usr/tmp/ispell")) 245 (setq filename (make-temp-name "/usr/tmp/ispell"))
236 (setq delete-temp t) 246 (setq delete-temp t)
242 (if (and ispell-enable-tex-parser 252 (if (and ispell-enable-tex-parser
243 (ispell-tex-buffer-p)) 253 (ispell-tex-buffer-p))
244 (ispell-cmd ":tex") 254 (ispell-cmd ":tex")
245 (ispell-cmd ":generic")) 255 (ispell-cmd ":generic"))
246 (ispell-cmd (format ":file %s %d %d" filename start end))) 256 (ispell-cmd (format ":file %s %d %d" filename start end)))
247 (if delete-temp 257 (if delete-temp
248 (condition-case () 258 (condition-case ()
249 (delete-file filename) 259 (delete-file filename)
250 (file-error nil))))) 260 (file-error nil)))))
251 (message "Parsing ispell output ...") 261 (message "Parsing ispell output ...")
252 (ispell-flush-bad-words) 262 (ispell-flush-bad-words)
253 (let (pos bad-words) 263 (let (pos bad-words)
254 (while (numberp (setq pos (ispell-next-message))) 264 (while (numberp (setq pos (ispell-next-message)))
255 ;;ispell may check the words on the line following the end 265 ;;ispell may check the words on the line following the end
271 (defalias 'ispell-buffer 'ispell) 281 (defalias 'ispell-buffer 'ispell)
272 282
273 (defun ispell-next () 283 (defun ispell-next ()
274 "Resume command loop for most recent ispell command." 284 "Resume command loop for most recent ispell command."
275 (interactive) 285 (interactive)
286 (setq ispell-window-configuration nil)
276 (unwind-protect 287 (unwind-protect
277 (catch 'quit 288 (catch 'quit
278 (save-window-excursion 289 ;; There used to be a save-excursion here,
279 (save-excursion 290 ;; but that was annoying: it's better if point doesn't move
280 (let (next) 291 ;; when you type q.
281 (while (markerp (setq next (car ispell-bad-words))) 292 (let (next)
282 (switch-to-buffer (marker-buffer next)) 293 (while (markerp (setq next (car ispell-bad-words)))
283 (push-mark) 294 (switch-to-buffer (marker-buffer next))
284 (ispell-point next "at saved position.") 295 (push-mark)
285 (setq ispell-bad-words (cdr ispell-bad-words)) 296 (ispell-point next "at saved position.")
286 (set-marker next nil)))))) 297 (setq ispell-bad-words (cdr ispell-bad-words))
298 (set-marker next nil))))
299 (if ispell-window-configuration
300 (set-window-configuration ispell-window-configuration))
287 (cond ((null ispell-bad-words) 301 (cond ((null ispell-bad-words)
288 (error "Ispell has not yet been run.")) 302 (error "Ispell has not yet been run."))
289 ((markerp (car ispell-bad-words)) 303 ((markerp (car ispell-bad-words))
290 (message (substitute-command-keys 304 (message (substitute-command-keys
291 "Type \\[ispell-next] to continue."))) 305 "Type \\[ispell-next] to continue.")))
366 ;start points, to the end of the word where end points 380 ;start points, to the end of the word where end points
367 (defun ispell-point (start message) 381 (defun ispell-point (start message)
368 (let ((wend (make-marker)) 382 (let ((wend (make-marker))
369 rescan 383 rescan
370 end) 384 end)
371 (save-excursion 385 ;; There used to be a save-excursion here,
386 ;; but that was annoying: it's better if point doesn't move
387 ;; when you type q.
372 (goto-char start) 388 (goto-char start)
373 (ispell-find-word-start) ;find correct word start 389 (ispell-find-word-start) ;find correct word start
374 (setq start (point-marker)) 390 (setq start (point-marker))
375 (ispell-find-word-end) ;now find correct end 391 (ispell-find-word-end) ;now find correct end
376 (setq end (point-marker)) 392 (setq end (point-marker))
384 ;that is more than one word 400 ;that is more than one word
385 (set-marker wend (point)) 401 (set-marker wend (point))
386 (setq rescan nil) 402 (setq rescan nil)
387 (setq word (buffer-substring start wend)) 403 (setq word (buffer-substring start wend))
388 (cond ((ispell-still-bad word) 404 (cond ((ispell-still-bad word)
389 (goto-char start);just to show user where we are working 405 ;;; This just causes confusion. -- rms.
390 (sit-for 0) 406 ;;; (goto-char start)
407 ;;; (sit-for 0)
391 (message (format "Ispell checking %s" word)) 408 (message (format "Ispell checking %s" word))
392 (ispell-cmd word) 409 (ispell-cmd word)
393 (let ((message (ispell-next-message))) 410 (let ((message (ispell-next-message)))
394 (cond ((eq message t) 411 (cond ((eq message t)
395 (message "%s: ok" word)) 412 (message "%s: ok" word))
409 (cond (buf 426 (cond (buf
410 (set-buffer buf) 427 (set-buffer buf)
411 (erase-buffer)))) 428 (erase-buffer))))
412 (set-marker start nil) 429 (set-marker start nil)
413 (set-marker end nil) 430 (set-marker end nil)
414 (set-marker wend nil)))) 431 (set-marker wend nil)))
415 432
416 (defun ispell-still-bad (word) 433 (defun ispell-still-bad (word)
417 (let ((words ispell-recently-accepted) 434 (let ((words ispell-recently-accepted)
418 (ret t) 435 (ret t)
419 (case-fold-search t)) 436 (case-fold-search t))
429 ;;messages winow be small. otherwise just use the other window 446 ;;messages winow be small. otherwise just use the other window
430 (let* ((selwin (selected-window)) 447 (let* ((selwin (selected-window))
431 (resize (eq selwin (next-window))) 448 (resize (eq selwin (next-window)))
432 (buf (get-buffer-create "*ispell choices*")) 449 (buf (get-buffer-create "*ispell choices*"))
433 w) 450 w)
451 (or ispell-window-configuration
452 (setq ispell-window-configuration (current-window-configuration)))
434 (setq w (display-buffer buf)) 453 (setq w (display-buffer buf))
435 (buffer-disable-undo buf) 454 (buffer-disable-undo buf)
436 (if resize 455 (if resize
437 (unwind-protect 456 (unwind-protect
438 (progn 457 (progn