diff options
| author | Stefan Monnier | 2011-05-02 22:48:32 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2011-05-02 22:48:32 -0300 |
| commit | 52d3c2d04d2709030f251eda950a72ee11f1b030 (patch) | |
| tree | 7f54828e1b62ad3764e21f571075139356e80564 | |
| parent | e2574f2c8e9e080f5f9d834c417cc1318df4e865 (diff) | |
| download | emacs-52d3c2d04d2709030f251eda950a72ee11f1b030.tar.gz emacs-52d3c2d04d2709030f251eda950a72ee11f1b030.zip | |
* lisp/textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal
error directly rather via storing it into `results'.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 72 |
2 files changed, 38 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 99ea84e77e4..ba3b7b62a98 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-05-03 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal | ||
| 4 | error directly rather via storing it into `results'. | ||
| 5 | |||
| 1 | 2011-05-02 Leo Liu <sdl.web@gmail.com> | 6 | 2011-05-02 Leo Liu <sdl.web@gmail.com> |
| 2 | 7 | ||
| 3 | * vc/diff.el: Fix description. | 8 | * vc/diff.el: Fix description. |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index ab31fed7069..35409d64289 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -2300,48 +2300,42 @@ if defined." | |||
| 2300 | (wild-p (string-match "\\*" word)) | 2300 | (wild-p (string-match "\\*" word)) |
| 2301 | (look-p (and ispell-look-p ; Only use look for an exact match. | 2301 | (look-p (and ispell-look-p ; Only use look for an exact match. |
| 2302 | (or ispell-have-new-look (not wild-p)))) | 2302 | (or ispell-have-new-look (not wild-p)))) |
| 2303 | (ispell-grep-buffer (get-buffer-create "*Ispell-Temp*")) ; result buf | ||
| 2304 | (prog (if look-p ispell-look-command ispell-grep-command)) | 2303 | (prog (if look-p ispell-look-command ispell-grep-command)) |
| 2305 | (args (if look-p ispell-look-options ispell-grep-options)) | 2304 | (args (if look-p ispell-look-options ispell-grep-options)) |
| 2306 | status results loc) | 2305 | status results loc) |
| 2307 | (unwind-protect | 2306 | (with-temp-buffer |
| 2308 | (save-window-excursion | 2307 | (message "Starting \"%s\" process..." (file-name-nondirectory prog)) |
| 2309 | (message "Starting \"%s\" process..." (file-name-nondirectory prog)) | 2308 | (if look-p |
| 2310 | (set-buffer ispell-grep-buffer) | 2309 | nil |
| 2311 | (if look-p | 2310 | ;; Convert * to .* |
| 2312 | nil | 2311 | (insert "^" word "$") |
| 2313 | ;; convert * to .* | 2312 | (while (search-backward "*" nil t) (insert ".")) |
| 2314 | (insert "^" word "$") | 2313 | (setq word (buffer-string)) |
| 2315 | (while (search-backward "*" nil t) (insert ".")) | 2314 | (erase-buffer)) |
| 2316 | (setq word (buffer-string)) | 2315 | (setq status (apply 'ispell-call-process prog nil t nil |
| 2317 | (erase-buffer)) | 2316 | (nconc (if (and args (> (length args) 0)) |
| 2318 | (setq status (apply 'ispell-call-process prog nil t nil | 2317 | (list args) |
| 2319 | (nconc (if (and args (> (length args) 0)) | 2318 | (if look-p nil |
| 2320 | (list args) | 2319 | (list "-e"))) |
| 2321 | (if look-p nil | 2320 | (list word) |
| 2322 | (list "-e"))) | 2321 | (if lookup-dict (list lookup-dict))))) |
| 2323 | (list word) | 2322 | ;; `grep' returns status 1 and no output when word not found, which |
| 2324 | (if lookup-dict (list lookup-dict))))) | 2323 | ;; is a perfectly normal thing. |
| 2325 | ;; grep returns status 1 and no output when word not found, which | 2324 | (if (stringp status) |
| 2326 | ;; is a perfectly normal thing. | 2325 | (error "error: %s exited with signal %s" |
| 2327 | (if (stringp status) | 2326 | (file-name-nondirectory prog) status) |
| 2328 | (setq results (cons (format "error: %s exited with signal %s" | 2327 | ;; Else collect words into `results' in FIFO order. |
| 2329 | (file-name-nondirectory prog) status) | 2328 | (goto-char (point-max)) |
| 2330 | results)) | 2329 | ;; Assure we've ended with \n. |
| 2331 | ;; else collect words into `results' in FIFO order | 2330 | (or (bobp) (= (preceding-char) ?\n) (insert ?\n)) |
| 2332 | (goto-char (point-max)) | 2331 | (while (not (bobp)) |
| 2333 | ;; assure we've ended with \n | 2332 | (setq loc (point)) |
| 2334 | (or (bobp) (= (preceding-char) ?\n) (insert ?\n)) | 2333 | (forward-line -1) |
| 2335 | (while (not (bobp)) | 2334 | (push (buffer-substring-no-properties (point) |
| 2336 | (setq loc (point)) | 2335 | (1- loc)) |
| 2337 | (forward-line -1) | 2336 | results)))) |
| 2338 | (setq results (cons (buffer-substring-no-properties (point) | 2337 | (if (and results (string-match ".+: " (car results))) |
| 2339 | (1- loc)) | 2338 | (error "%s error: %s" ispell-grep-command (car results))) |
| 2340 | results))))) | ||
| 2341 | ;; protected | ||
| 2342 | (kill-buffer ispell-grep-buffer) | ||
| 2343 | (if (and results (string-match ".+: " (car results))) | ||
| 2344 | (error "%s error: %s" ispell-grep-command (car results)))) | ||
| 2345 | results)) | 2339 | results)) |
| 2346 | 2340 | ||
| 2347 | 2341 | ||