diff options
| author | Agustín Martín | 2013-04-17 20:03:46 +0200 |
|---|---|---|
| committer | Agustín Martín | 2013-04-17 20:03:46 +0200 |
| commit | ffe54a139dddefdfd3f0837281ebb62d7cc0a912 (patch) | |
| tree | f17d3982c373193eb45cecf7f0e5cebe55834dad /lisp/textmodes | |
| parent | ec7e39f24707268201a444fc4bbc42b2dffae6c5 (diff) | |
| download | emacs-ffe54a139dddefdfd3f0837281ebb62d7cc0a912.tar.gz emacs-ffe54a139dddefdfd3f0837281ebb62d7cc0a912.zip | |
textmodes/flyspell.el: Don't check pre-word if buffer was switched.
If command changed the buffer, the decision may be made based on the
current buffer even though it should based on the previous one. This
may lead to false positives and more importantly to errors since
`flyspell-pre-point' is buffer local so it may have unsanitised value
(such as nil) in previous buffer.
To be honest, I'm not sure how this can happen since
`flyspell-pre-point' is set in previous buffer, but nonetheless, I've
been encountering the error for quite some time and finally decided to
fix it. Interestingly, line making `flyspell-pre-point'
a buffer-local variable has a very revealing "Why?? --Stef" comment.
To avoid the problem, change flyspell-check-pre-word-p so that it does
not allow checking of pre-word if command changed buffer
(ie. `flyspell-pre-buffer' is not current buffer).
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/flyspell.el | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 6ab3e3d3f16..81f17c897eb 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -738,7 +738,7 @@ before the current command." | |||
| 738 | (let ((ispell-otherchars (ispell-get-otherchars))) | 738 | (let ((ispell-otherchars (ispell-get-otherchars))) |
| 739 | (cond | 739 | (cond |
| 740 | ((not (and (numberp flyspell-pre-point) | 740 | ((not (and (numberp flyspell-pre-point) |
| 741 | (buffer-live-p flyspell-pre-buffer))) | 741 | (eq flyspell-pre-buffer (current-buffer)))) |
| 742 | nil) | 742 | nil) |
| 743 | ((and (eq flyspell-pre-pre-point flyspell-pre-point) | 743 | ((and (eq flyspell-pre-pre-point flyspell-pre-point) |
| 744 | (eq flyspell-pre-pre-buffer flyspell-pre-buffer)) | 744 | (eq flyspell-pre-pre-buffer flyspell-pre-buffer)) |
| @@ -956,11 +956,10 @@ Mostly we check word delimiters." | |||
| 956 | ;; Prevent anything we do from affecting the mark. | 956 | ;; Prevent anything we do from affecting the mark. |
| 957 | deactivate-mark) | 957 | deactivate-mark) |
| 958 | (if (flyspell-check-pre-word-p) | 958 | (if (flyspell-check-pre-word-p) |
| 959 | (with-current-buffer flyspell-pre-buffer | 959 | (save-excursion |
| 960 | '(flyspell-debug-signal-pre-word-checked) | 960 | '(flyspell-debug-signal-pre-word-checked) |
| 961 | (save-excursion | 961 | (goto-char flyspell-pre-point) |
| 962 | (goto-char flyspell-pre-point) | 962 | (flyspell-word))) |
| 963 | (flyspell-word)))) | ||
| 964 | (if (flyspell-check-word-p) | 963 | (if (flyspell-check-word-p) |
| 965 | (progn | 964 | (progn |
| 966 | '(flyspell-debug-signal-word-checked) | 965 | '(flyspell-debug-signal-word-checked) |
| @@ -974,16 +973,14 @@ Mostly we check word delimiters." | |||
| 974 | ;; FLYSPELL-CHECK-PRE-WORD-P | 973 | ;; FLYSPELL-CHECK-PRE-WORD-P |
| 975 | (setq flyspell-pre-pre-buffer (current-buffer)) | 974 | (setq flyspell-pre-pre-buffer (current-buffer)) |
| 976 | (setq flyspell-pre-pre-point (point))) | 975 | (setq flyspell-pre-pre-point (point))) |
| 977 | (progn | 976 | (setq flyspell-pre-pre-buffer nil) |
| 978 | (setq flyspell-pre-pre-buffer nil) | 977 | (setq flyspell-pre-pre-point nil) |
| 979 | (setq flyspell-pre-pre-point nil) | 978 | ;; when a word is not checked because of a delayed command |
| 980 | ;; when a word is not checked because of a delayed command | 979 | ;; we do not disable the ispell cache. |
| 981 | ;; we do not disable the ispell cache. | 980 | (when (and (symbolp this-command) |
| 982 | (if (and (symbolp this-command) | ||
| 983 | (get this-command 'flyspell-delayed)) | 981 | (get this-command 'flyspell-delayed)) |
| 984 | (progn | 982 | (setq flyspell-word-cache-end -1) |
| 985 | (setq flyspell-word-cache-end -1) | 983 | (setq flyspell-word-cache-result '_))) |
| 986 | (setq flyspell-word-cache-result '_))))) | ||
| 987 | (while (and (not (input-pending-p)) (consp flyspell-changes)) | 984 | (while (and (not (input-pending-p)) (consp flyspell-changes)) |
| 988 | (let ((start (car (car flyspell-changes))) | 985 | (let ((start (car (car flyspell-changes))) |
| 989 | (stop (cdr (car flyspell-changes)))) | 986 | (stop (cdr (car flyspell-changes)))) |