[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r112317: textmodes/flyspell.el: Don't
From: |
Agustin Martin |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r112317: textmodes/flyspell.el: Don't check pre-word if buffer was switched. |
Date: |
Wed, 17 Apr 2013 20:03:46 +0200 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 112317
committer: Agustin Martin <address@hidden>
branch nick: trunk
timestamp: Wed 2013-04-17 20:03:46 +0200
message:
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).
modified:
lisp/ChangeLog
lisp/textmodes/flyspell.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-04-17 17:48:10 +0000
+++ b/lisp/ChangeLog 2013-04-17 18:03:46 +0000
@@ -1,3 +1,14 @@
+2013-04-17 Michal Nazarewicz <address@hidden>
+
+ * textmodes/flyspell.el (flyspell-check-pre-word-p): Return nil if
+ command changed buffer (ie. `flyspell-pre-buffer' is not current
+ buffer), which prevents making decisions based on invalid value of
+ `flyspell-pre-point' in the wrong buffer. Most notably, this used to
+ cause an error when `flyspell-pre-point' was nil after switching
+ buffers
+ (flyspell-post-command-hook): No longer needs to change buffers when
+ checking pre-word. While at it remove unnecessary progn.
+
2013-04-17 Nicolas Richard <address@hidden> (tiny change)
* textmodes/ispell.el (ispell-add-per-file-word-list):
=== modified file 'lisp/textmodes/flyspell.el'
--- a/lisp/textmodes/flyspell.el 2013-01-11 23:08:55 +0000
+++ b/lisp/textmodes/flyspell.el 2013-04-17 18:03:46 +0000
@@ -738,7 +738,7 @@
(let ((ispell-otherchars (ispell-get-otherchars)))
(cond
((not (and (numberp flyspell-pre-point)
- (buffer-live-p flyspell-pre-buffer)))
+ (eq flyspell-pre-buffer (current-buffer))))
nil)
((and (eq flyspell-pre-pre-point flyspell-pre-point)
(eq flyspell-pre-pre-buffer flyspell-pre-buffer))
@@ -956,11 +956,10 @@
;; Prevent anything we do from affecting the mark.
deactivate-mark)
(if (flyspell-check-pre-word-p)
- (with-current-buffer flyspell-pre-buffer
+ (save-excursion
'(flyspell-debug-signal-pre-word-checked)
- (save-excursion
- (goto-char flyspell-pre-point)
- (flyspell-word))))
+ (goto-char flyspell-pre-point)
+ (flyspell-word)))
(if (flyspell-check-word-p)
(progn
'(flyspell-debug-signal-word-checked)
@@ -974,16 +973,14 @@
;; 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)
+ (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.
+ (when (and (symbolp this-command)
(get this-command 'flyspell-delayed))
- (progn
- (setq flyspell-word-cache-end -1)
- (setq flyspell-word-cache-result '_)))))
+ (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))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r112317: textmodes/flyspell.el: Don't check pre-word if buffer was switched.,
Agustin Martin <=