aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorAgustín Martín2012-05-18 09:04:04 +0200
committerAgustín Martín2012-05-18 09:04:04 +0200
commit3f1b25b580bf45f92c4ee4750771a987e5524299 (patch)
tree1d0dff473ccdaf2ddd9df451281ee8fc7be530da /lisp/textmodes
parented0ba302d34b9cc74dc2499cfa664fcb06e361b2 (diff)
downloademacs-3f1b25b580bf45f92c4ee4750771a987e5524299.tar.gz
emacs-3f1b25b580bf45f92c4ee4750771a987e5524299.zip
textmodes/flyspell.el: Protect delay handling for otherchars against empty otherchars.
(flyspell-check-pre-word-p, flyspell-check-word-p,flyspell-debug-signal-word-checked)
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/flyspell.el142
1 files changed, 76 insertions, 66 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 156a7e532e8..89134a1d355 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -730,45 +730,50 @@ not the very same deplacement command."
730 "Return non-nil if we should check the word before point. 730 "Return non-nil if we should check the word before point.
731More precisely, it applies to the word that was before point 731More precisely, it applies to the word that was before point
732before the current command." 732before the current command."
733 (cond 733 (let ((ispell-otherchars (ispell-get-otherchars)))
734 ((or (not (numberp flyspell-pre-point)) 734 (cond
735 (not (bufferp flyspell-pre-buffer)) 735 ((or (not (numberp flyspell-pre-point))
736 (not (buffer-live-p flyspell-pre-buffer))) 736 (not (bufferp flyspell-pre-buffer))
737 nil) 737 (not (buffer-live-p flyspell-pre-buffer)))
738 ((and (eq flyspell-pre-pre-point flyspell-pre-point) 738 nil)
739 (eq flyspell-pre-pre-buffer flyspell-pre-buffer)) 739 ((and (eq flyspell-pre-pre-point flyspell-pre-point)
740 nil) 740 (eq flyspell-pre-pre-buffer flyspell-pre-buffer))
741 ((or (and (= flyspell-pre-point (- (point) 1)) 741 nil)
742 (or (eq (char-syntax (char-after flyspell-pre-point)) ?w) 742 ((or (and (= flyspell-pre-point (- (point) 1))
743 (string-match-p (ispell-get-otherchars) 743 (or (eq (char-syntax (char-after flyspell-pre-point)) ?w)
744 (buffer-substring-no-properties 744 (and (not (string= "" ispell-otherchars))
745 flyspell-pre-point (1+ flyspell-pre-point))))) 745 (string-match-p
746 (= flyspell-pre-point (point)) 746 ispell-otherchars
747 (= flyspell-pre-point (+ (point) 1))) 747 (buffer-substring-no-properties
748 nil) 748 flyspell-pre-point (1+ flyspell-pre-point))))))
749 ((and (symbolp this-command) 749 (= flyspell-pre-point (point))
750 (not executing-kbd-macro) 750 (= flyspell-pre-point (+ (point) 1)))
751 (or (get this-command 'flyspell-delayed) 751 nil)
752 (and (get this-command 'flyspell-deplacement) 752 ((and (symbolp this-command)
753 (eq flyspell-previous-command this-command))) 753 (not executing-kbd-macro)
754 (or (= (current-column) 0) 754 (or (get this-command 'flyspell-delayed)
755 (= (current-column) flyspell-pre-column) 755 (and (get this-command 'flyspell-deplacement)
756 ;; If other post-command-hooks change the buffer, 756 (eq flyspell-previous-command this-command)))
757 ;; flyspell-pre-point can lie past eob (bug#468). 757 (or (= (current-column) 0)
758 (null (char-after flyspell-pre-point)) 758 (= (current-column) flyspell-pre-column)
759 (or (eq (char-syntax (char-after flyspell-pre-point)) ?w) 759 ;; If other post-command-hooks change the buffer,
760 (string-match-p (ispell-get-otherchars) 760 ;; flyspell-pre-point can lie past eob (bug#468).
761 (buffer-substring-no-properties 761 (null (char-after flyspell-pre-point))
762 flyspell-pre-point (1+ flyspell-pre-point)))))) 762 (or (eq (char-syntax (char-after flyspell-pre-point)) ?w)
763 nil) 763 (and (not (string= "" ispell-otherchars))
764 ((not (eq (current-buffer) flyspell-pre-buffer)) 764 (string-match-p
765 t) 765 ispell-otherchars
766 ((not (and (numberp flyspell-word-cache-start) 766 (buffer-substring-no-properties
767 (numberp flyspell-word-cache-end))) 767 flyspell-pre-point (1+ flyspell-pre-point)))))))
768 t) 768 nil)
769 (t 769 ((not (eq (current-buffer) flyspell-pre-buffer))
770 (or (< flyspell-pre-point flyspell-word-cache-start) 770 t)
771 (> flyspell-pre-point flyspell-word-cache-end))))) 771 ((not (and (numberp flyspell-word-cache-start)
772 (numberp flyspell-word-cache-end)))
773 t)
774 (t
775 (or (< flyspell-pre-point flyspell-word-cache-start)
776 (> flyspell-pre-point flyspell-word-cache-end))))))
772 777
773;;*---------------------------------------------------------------------*/ 778;;*---------------------------------------------------------------------*/
774;;* The flyspell after-change-hook, store the change position. In */ 779;;* The flyspell after-change-hook, store the change position. In */
@@ -812,31 +817,33 @@ Mostly we check word delimiters."
812 "Return t when the word at `point' has to be checked. 817 "Return t when the word at `point' has to be checked.
813The answer depends of several criteria. 818The answer depends of several criteria.
814Mostly we check word delimiters." 819Mostly we check word delimiters."
815 (cond 820 (let ((ispell-otherchars (ispell-get-otherchars)))
816 ((<= (- (point-max) 1) (point-min))
817 ;; the buffer is not filled enough
818 nil)
819 ((and (and (> (current-column) 0)
820 (not (eq (current-column) flyspell-pre-column)))
821 (save-excursion
822 (backward-char 1)
823 (and (looking-at (flyspell-get-not-casechars))
824 (not (looking-at (ispell-get-otherchars)))
825 (or flyspell-consider-dash-as-word-delimiter-flag
826 (not (looking-at "-"))))))
827 ;; yes because we have reached or typed a word delimiter.
828 t)
829 ((symbolp this-command)
830 (cond 821 (cond
831 ((get this-command 'flyspell-deplacement) 822 ((<= (- (point-max) 1) (point-min))
832 (not (eq flyspell-previous-command this-command))) 823 ;; the buffer is not filled enough
833 ((get this-command 'flyspell-delayed) 824 nil)
834 ;; the current command is not delayed, that 825 ((and (and (> (current-column) 0)
835 ;; is that we must check the word now 826 (not (eq (current-column) flyspell-pre-column)))
836 (and (not unread-command-events) 827 (save-excursion
837 (sit-for flyspell-delay))) 828 (backward-char 1)
838 (t t))) 829 (and (looking-at (flyspell-get-not-casechars))
839 (t t))) 830 (or (string= "" ispell-otherchars)
831 (not (looking-at (ispell-get-otherchars))))
832 (or flyspell-consider-dash-as-word-delimiter-flag
833 (not (looking-at "-"))))))
834 ;; yes because we have reached or typed a word delimiter.
835 t)
836 ((symbolp this-command)
837 (cond
838 ((get this-command 'flyspell-deplacement)
839 (not (eq flyspell-previous-command this-command)))
840 ((get this-command 'flyspell-delayed)
841 ;; the current command is not delayed, that
842 ;; is that we must check the word now
843 (and (not unread-command-events)
844 (sit-for flyspell-delay)))
845 (t t)))
846 (t t))))
840 847
841;;*---------------------------------------------------------------------*/ 848;;*---------------------------------------------------------------------*/
842;;* flyspell-debug-signal-no-check ... */ 849;;* flyspell-debug-signal-no-check ... */
@@ -866,7 +873,8 @@ Mostly we check word delimiters."
866;;*---------------------------------------------------------------------*/ 873;;*---------------------------------------------------------------------*/
867(defun flyspell-debug-signal-word-checked () 874(defun flyspell-debug-signal-word-checked ()
868 (setq debug-on-error t) 875 (setq debug-on-error t)
869 (let ((oldbuf (current-buffer)) 876 (let ((ispell-otherchars (ispell-get-otherchars))
877 (oldbuf (current-buffer))
870 (point (point))) 878 (point (point)))
871 (with-current-buffer (get-buffer-create "*flyspell-debug*") 879 (with-current-buffer (get-buffer-create "*flyspell-debug*")
872 (insert "WORD:\n") 880 (insert "WORD:\n")
@@ -887,7 +895,8 @@ Mostly we check word delimiters."
887 (save-excursion 895 (save-excursion
888 (backward-char 1) 896 (backward-char 1)
889 (and (and (looking-at (flyspell-get-not-casechars)) 1) 897 (and (and (looking-at (flyspell-get-not-casechars)) 1)
890 (not (looking-at (ispell-get-otherchars))) 898 (or (string= "" ispell-otherchars)
899 (not (looking-at (ispell-get-otherchars))))
891 (and (or flyspell-consider-dash-as-word-delimiter-flag 900 (and (or flyspell-consider-dash-as-word-delimiter-flag
892 (not (looking-at "\\-"))) 2)))))) 901 (not (looking-at "\\-"))) 2))))))
893 c)))) 902 c))))
@@ -903,7 +912,8 @@ Mostly we check word delimiters."
903 (save-excursion 912 (save-excursion
904 (backward-char 1) 913 (backward-char 1)
905 (and (looking-at (flyspell-get-not-casechars)) 914 (and (looking-at (flyspell-get-not-casechars))
906 (not (looking-at (ispell-get-otherchars))) 915 (or (string= "" ispell-otherchars)
916 (not (looking-at (ispell-get-otherchars))))
907 (or flyspell-consider-dash-as-word-delimiter-flag 917 (or flyspell-consider-dash-as-word-delimiter-flag
908 (not (looking-at "\\-")))))))) 918 (not (looking-at "\\-"))))))))
909 c)) 919 c))