aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustín Martín2013-04-17 20:03:46 +0200
committerAgustín Martín2013-04-17 20:03:46 +0200
commitffe54a139dddefdfd3f0837281ebb62d7cc0a912 (patch)
treef17d3982c373193eb45cecf7f0e5cebe55834dad
parentec7e39f24707268201a444fc4bbc42b2dffae6c5 (diff)
downloademacs-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).
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/textmodes/flyspell.el25
2 files changed, 22 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cdb8fe5d36c..ffa0c840554 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12013-04-17 Michal Nazarewicz <mina86@mina86.com>
2
3 * textmodes/flyspell.el (flyspell-check-pre-word-p): Return nil if
4 command changed buffer (ie. `flyspell-pre-buffer' is not current
5 buffer), which prevents making decisions based on invalid value of
6 `flyspell-pre-point' in the wrong buffer. Most notably, this used to
7 cause an error when `flyspell-pre-point' was nil after switching
8 buffers
9 (flyspell-post-command-hook): No longer needs to change buffers when
10 checking pre-word. While at it remove unnecessary progn.
11
12013-04-17 Nicolas Richard <theonewiththeevillook@yahoo.fr> (tiny change) 122013-04-17 Nicolas Richard <theonewiththeevillook@yahoo.fr> (tiny change)
2 13
3 * textmodes/ispell.el (ispell-add-per-file-word-list): 14 * textmodes/ispell.el (ispell-add-per-file-word-list):
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))))