emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r106058: * lisp/textmodes/flyspell.el


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r106058: * lisp/textmodes/flyspell.el (flyspell-word): Move with-local-quit from here...
Date: Tue, 11 Oct 2011 22:48:40 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 106058
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2011-10-11 22:48:40 -0400
message:
  * lisp/textmodes/flyspell.el (flyspell-word): Move with-local-quit from 
here...
  (flyspell-post-command-hook): ...to here.
modified:
  lisp/ChangeLog
  lisp/textmodes/flyspell.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-10-11 21:31:22 +0000
+++ b/lisp/ChangeLog    2011-10-12 02:48:40 +0000
@@ -1,3 +1,9 @@
+2011-10-12  Stefan Monnier  <address@hidden>
+
+       * textmodes/flyspell.el (flyspell-word): Move with-local-quit
+       from here...
+       (flyspell-post-command-hook): ...to here.
+
 2011-10-11  Stefan Monnier  <address@hidden>
 
        * mail/sendmail.el (send-mail-function): Don't use sendmail-query-once

=== modified file 'lisp/textmodes/flyspell.el'
--- a/lisp/textmodes/flyspell.el        2011-09-11 02:14:10 +0000
+++ b/lisp/textmodes/flyspell.el        2011-10-12 02:48:40 +0000
@@ -931,49 +931,52 @@
 ;;*       previous word nor the current word                            */
 ;;*---------------------------------------------------------------------*/
 (defun flyspell-post-command-hook ()
-  "The `post-command-hook' used by flyspell to check a word in-the-fly."
+  "The `post-command-hook' used by flyspell to check a word on-the-fly."
   (interactive)
   (when flyspell-mode
-    (let ((command this-command)
-         ;; Prevent anything we do from affecting the mark.
-         deactivate-mark)
-      (if (flyspell-check-pre-word-p)
-         (with-current-buffer flyspell-pre-buffer
-           '(flyspell-debug-signal-pre-word-checked)
-           (save-excursion
-             (goto-char flyspell-pre-point)
-             (flyspell-word))))
-      (if (flyspell-check-word-p)
-         (progn
-           '(flyspell-debug-signal-word-checked)
-           (flyspell-word)
-           ;; we remember which word we have just checked.
-           ;; this will be used next time we will check a word
-           ;; to compare the next current word with the word
-           ;; that as been registered in the pre-command-hook
-           ;; that is these variables are used within the predicate
-           ;; FLYSPELL-CHECK-PRE-WORD-P
-           (setq flyspell-pre-pre-buffer (current-buffer))
-           (setq flyspell-pre-pre-point  (point)))
-       (progn
-         (setq flyspell-pre-pre-buffer nil)
-         (setq flyspell-pre-pre-point  nil)
-         ;; when a word is not checked because of a delayed command
-         ;; we do not disable the ispell cache.
-         (if (and (symbolp this-command) (get this-command 'flyspell-delayed))
-             (progn
-               (setq flyspell-word-cache-end -1)
-               (setq flyspell-word-cache-result '_)))))
-      (while (and (not (input-pending-p)) (consp flyspell-changes))
-       (let ((start (car (car flyspell-changes)))
-             (stop  (cdr (car flyspell-changes))))
-         (if (flyspell-check-changed-word-p start stop)
-             (save-excursion
-               '(flyspell-debug-signal-changed-checked)
-               (goto-char start)
-               (flyspell-word)))
-         (setq flyspell-changes (cdr flyspell-changes))))
-      (setq flyspell-previous-command command))))
+    (with-local-quit
+      (let ((command this-command)
+            ;; Prevent anything we do from affecting the mark.
+            deactivate-mark)
+        (if (flyspell-check-pre-word-p)
+            (with-current-buffer flyspell-pre-buffer
+              '(flyspell-debug-signal-pre-word-checked)
+              (save-excursion
+                (goto-char flyspell-pre-point)
+                (flyspell-word))))
+        (if (flyspell-check-word-p)
+            (progn
+              '(flyspell-debug-signal-word-checked)
+              ;; FIXME: This should be asynchronous!
+              (flyspell-word)
+              ;; we remember which word we have just checked.
+              ;; this will be used next time we will check a word
+              ;; to compare the next current word with the word
+              ;; that as been registered in the pre-command-hook
+              ;; that is these variables are used within the predicate
+              ;; FLYSPELL-CHECK-PRE-WORD-P
+              (setq flyspell-pre-pre-buffer (current-buffer))
+              (setq flyspell-pre-pre-point  (point)))
+          (progn
+            (setq flyspell-pre-pre-buffer nil)
+            (setq flyspell-pre-pre-point  nil)
+            ;; when a word is not checked because of a delayed command
+            ;; we do not disable the ispell cache.
+            (if (and (symbolp this-command)
+                     (get this-command 'flyspell-delayed))
+                (progn
+                  (setq flyspell-word-cache-end -1)
+                  (setq flyspell-word-cache-result '_)))))
+        (while (and (not (input-pending-p)) (consp flyspell-changes))
+          (let ((start (car (car flyspell-changes)))
+                (stop  (cdr (car flyspell-changes))))
+            (if (flyspell-check-changed-word-p start stop)
+                (save-excursion
+                  '(flyspell-debug-signal-changed-checked)
+                  (goto-char start)
+                  (flyspell-word)))
+            (setq flyspell-changes (cdr flyspell-changes))))
+        (setq flyspell-previous-command command)))))
 
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-notify-misspell ...                                     */
@@ -1100,14 +1103,10 @@
                   ;; we mark the ispell process so it can be killed
                   ;; when emacs is exited without query
                   (set-process-query-on-exit-flag ispell-process nil)
-                  ;; Wait until ispell has processed word.  Since this
-                  ;; code is often executed from post-command-hook but
-                  ;; the ispell process may not be responsive, it's
-                  ;; important to make sure we re-enable C-g.
-                  (with-local-quit
-                    (while (progn
-                             (accept-process-output ispell-process)
-                             (not (string= "" (car ispell-filter))))))
+                  ;; Wait until ispell has processed word.
+                  (while (progn
+                           (accept-process-output ispell-process)
+                           (not (string= "" (car ispell-filter)))))
                   ;; (ispell-send-string "!\n")
                   ;; back to terse mode.
                   ;; Remove leading empty element


reply via email to

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