From 52d3c2d04d2709030f251eda950a72ee11f1b030 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 2 May 2011 22:48:32 -0300 Subject: [PATCH] * lisp/textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal error directly rather via storing it into `results'. --- lisp/ChangeLog | 5 +++ 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 @@ +2011-05-03 Stefan Monnier + + * textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal + error directly rather via storing it into `results'. + 2011-05-02 Leo Liu * 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." (wild-p (string-match "\\*" word)) (look-p (and ispell-look-p ; Only use look for an exact match. (or ispell-have-new-look (not wild-p)))) - (ispell-grep-buffer (get-buffer-create "*Ispell-Temp*")) ; result buf (prog (if look-p ispell-look-command ispell-grep-command)) (args (if look-p ispell-look-options ispell-grep-options)) status results loc) - (unwind-protect - (save-window-excursion - (message "Starting \"%s\" process..." (file-name-nondirectory prog)) - (set-buffer ispell-grep-buffer) - (if look-p - nil - ;; convert * to .* - (insert "^" word "$") - (while (search-backward "*" nil t) (insert ".")) - (setq word (buffer-string)) - (erase-buffer)) - (setq status (apply 'ispell-call-process prog nil t nil - (nconc (if (and args (> (length args) 0)) - (list args) - (if look-p nil - (list "-e"))) - (list word) - (if lookup-dict (list lookup-dict))))) - ;; grep returns status 1 and no output when word not found, which - ;; is a perfectly normal thing. - (if (stringp status) - (setq results (cons (format "error: %s exited with signal %s" - (file-name-nondirectory prog) status) - results)) - ;; else collect words into `results' in FIFO order - (goto-char (point-max)) - ;; assure we've ended with \n - (or (bobp) (= (preceding-char) ?\n) (insert ?\n)) - (while (not (bobp)) - (setq loc (point)) - (forward-line -1) - (setq results (cons (buffer-substring-no-properties (point) - (1- loc)) - results))))) - ;; protected - (kill-buffer ispell-grep-buffer) - (if (and results (string-match ".+: " (car results))) - (error "%s error: %s" ispell-grep-command (car results)))) + (with-temp-buffer + (message "Starting \"%s\" process..." (file-name-nondirectory prog)) + (if look-p + nil + ;; Convert * to .* + (insert "^" word "$") + (while (search-backward "*" nil t) (insert ".")) + (setq word (buffer-string)) + (erase-buffer)) + (setq status (apply 'ispell-call-process prog nil t nil + (nconc (if (and args (> (length args) 0)) + (list args) + (if look-p nil + (list "-e"))) + (list word) + (if lookup-dict (list lookup-dict))))) + ;; `grep' returns status 1 and no output when word not found, which + ;; is a perfectly normal thing. + (if (stringp status) + (error "error: %s exited with signal %s" + (file-name-nondirectory prog) status) + ;; Else collect words into `results' in FIFO order. + (goto-char (point-max)) + ;; Assure we've ended with \n. + (or (bobp) (= (preceding-char) ?\n) (insert ?\n)) + (while (not (bobp)) + (setq loc (point)) + (forward-line -1) + (push (buffer-substring-no-properties (point) + (1- loc)) + results)))) + (if (and results (string-match ".+: " (car results))) + (error "%s error: %s" ispell-grep-command (car results))) results)) -- 2.39.2