emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104085: * lisp/textmodes/ispell.el (


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104085: * lisp/textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal
Date: Mon, 02 May 2011 22:48:32 -0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104085
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2011-05-02 22:48:32 -0300
message:
  * lisp/textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal
  error directly rather via storing it into `results'.
modified:
  lisp/ChangeLog
  lisp/textmodes/ispell.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-02 12:22:38 +0000
+++ b/lisp/ChangeLog    2011-05-03 01:48:32 +0000
@@ -1,3 +1,8 @@
+2011-05-03  Stefan Monnier  <address@hidden>
+
+       * textmodes/ispell.el (lookup-words): Use with-temp-buffer; signal
+       error directly rather via storing it into `results'.
+
 2011-05-02  Leo Liu  <address@hidden>
 
        * vc/diff.el: Fix description.

=== modified file 'lisp/textmodes/ispell.el'
--- a/lisp/textmodes/ispell.el  2011-01-26 08:36:39 +0000
+++ b/lisp/textmodes/ispell.el  2011-05-03 01:48:32 +0000
@@ -2300,48 +2300,42 @@
         (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))
 
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]